Volume level inconsistency [Solved]

Hello…
I am getting different volume level for same effects sound in cocosdenshion…
I am playing sound from different layer in same scane but setting same level…
Does anybody know what should be the problem…
Using cocos2dx latest release

It would be good, if you can provide more detail about the issue. I didn’t notice any such issue in my game. I am also using latest Cocos2dx version.

Are you changing the effectVolume anywhere?

I think the issue is with your audio files. Check them first using media players and see if they have the same volume.

Hello Lance Sound files are fine.. I have tried with same audio file coming different sound level at different place in the same scene.. I am making one demo and let you more clearParas…
Thanks for suggestions…

Lance andParas…
The issue is solved…
At one place sound was triggering multiple time as i have put it on touchesbegan…
So i have put one flag to keep track of playing…
But i am surprised that when one sound file playing multiple time in cctouchesbegan its level become much higher…

What I did was to create a SoundManager class that would call certain SimpleAudioEngine functions but with a bit more functionality.

In the SoundManager class, I had this function called *SoundManager::changeBGM( const char * pBGMFile )* which checks first if it is the same as the currently playing BGM.

void SoundManager::changeBGM( const char * pBGMFile ) {
   // Check if new BGM is the same as before. If so, do nothing.
   if ( strcmp( pBGMFile, mBGM ) == 0 ) return;

   // BGM is new. Save its name so that we can check again later.
   mBGM = pBGMFile;

   // play bgm using SimpleAudioEngine here.
}

Thanks @Lance for helpful suggestion…

@Lance

Your solution seems nice especially when we need to continue the same BGM. Just a thought, the method can be integrated within simple audio engine rather than creating soundManager class. Is it something extra doing apart from this?

Paras Mendiratta wrote:

@Lance
>
>
Your solution seems nice especially when we need to continue the same BGM. Just a thought, the method can be integrated within simple audio engine rather than creating soundManager class. Is it something extra doing apart from this?

I noticed on the SimpleAudioEngine class when you play a BGM, the music gets repeated on the very beginning. For example, you have the Main Menu and a Shop Menu. Both of them uses the same BGMs, however, simply using SimpleAudioEngine would reset the currently playing BGM back to the beginning. I don’t want that, so I made the SoundManager class to check if the same BGM is going to be played again so it does not reset back, creating a nice audio loop. It also checks first if the game is muted or not and will only play if it is not muted.

It also contains stuff like SoundManager::playKaching* and similar stuff so that I won’t have to type the file name over and over again when I want to play sounds. It also has a method likeSoundManager::changeVolume( Volume pVolume )* because my project requires 3 volume levels (LOW, MED, HIGH) and not float values. It also hold boolean values to determine if the game is muted or not.

It’s actually just something I made to make my life easier, I just wanted to share it, just in case it becomes helpful.