audio repeat gets louder

Problem: When sound is played twice, it gets louder.

In a quiz, user touches Start to hear the current question, an aiff held in variable currQ. Sound is played. User has option to repeat the sound by touching Repeat button. EventListeners below:

[code] --Start button code function newQuestion(e) if (e.phase == "began") then start\_down\_btn.alpha = 1; end if (e.phase == "moved") then start\_down\_btn.alpha = 0; end if (e.phase == "ended") then start\_down\_btn.alpha = 0; audio.play(currQ);--current question sound end     return true;             end --Repeat button code function repeatQuestion(e) if (e.phase == "began") then repeat\_down\_btn.alpha = 1; end if (e.phase == "moved") then repeat\_down\_btn.alpha = 0; end if (e.phase == "ended") then repeat\_down\_btn.alpha = 0; audio.play(currQ);--current question sound end return true;   end [/code]

Is there a quick way to clear and re-insert currQ sound between press of Start and Repeat buttons?

I’ve tried setting currQ to nil after first play and putting the repeat sound in a different variable. I assume that it’s somehow addressing 2 instances of the sound, and playing them simultaneously. Sound gets louder on the first press of Repeat button, but doesn’t continue to get any louder on subsequent presses.

App reverts to the original volume when it plays the answer which, in this case, points to the same aiff file with a different object name. I can test creating a separate set of objects for repeat call, but think there’s a better answer.

Thanks for any help that you can give.

LB

Hi @lbolduc,

Yes, basically it’s playing the sound overlapped which gives the impression that it’s louder. What you should probably do is play the sound on a dedicated audio channel, so that if it re-plays, it will simply reset the same channel and play again. In your current code, you are not requesting a specific channel, so Corona logically looks for any free channel and plays the sound there as well.

Hope this helps,

Brent

Thank you, Brent!

audio.play(currQ, {channel=1});

Works. Made 3 sets of audio; question, repeat, and answer; each set assigned to a different channel. 

The volume is constant. Response time to repeat a sound, more than once, is much slower.

In trying to reclaim the faster response time, I tried letting Corona auto-assign the repeat channel. It randomly plays a repeat louder than the others. Can you think of a trick to reclaim faster response time? If not, no worries. Thanks very  much for your help.

LB

Hi @lbolduc,

Yes, basically it’s playing the sound overlapped which gives the impression that it’s louder. What you should probably do is play the sound on a dedicated audio channel, so that if it re-plays, it will simply reset the same channel and play again. In your current code, you are not requesting a specific channel, so Corona logically looks for any free channel and plays the sound there as well.

Hope this helps,

Brent

Thank you, Brent!

audio.play(currQ, {channel=1});

Works. Made 3 sets of audio; question, repeat, and answer; each set assigned to a different channel. 

The volume is constant. Response time to repeat a sound, more than once, is much slower.

In trying to reclaim the faster response time, I tried letting Corona auto-assign the repeat channel. It randomly plays a repeat louder than the others. Can you think of a trick to reclaim faster response time? If not, no worries. Thanks very  much for your help.

LB