Hi…
What do audioID and AudioProfile parameters are for in cocos2d::experimental::AudioEngine and how to use them?
Thanks…
Hi…
What do audioID and AudioProfile parameters are for in cocos2d::experimental::AudioEngine and how to use them?
Thanks…
You can check it on the documentation:
but in most cases there is only needed the SimpleAudioEngine:
thanks, but it would not explain in deep what they do and how to use…
but i have found how to point to specific bgm track for instance…
int intro_bgm = cocos2d::experimental::AudioEngine::play2d("intro.mp3", true, 1.0f);
cocos2d::experimental::AudioEngine::setVolume(intro_bgm, 0.5f);
that way has sense for me at least
thanks.
thanks… now that i have an idea, i´m wondering what is the better way to organize my music… if i identify them by an int (audioID), should store all them in a static std::vector of int maybe … how do you do?
I define my Audio IDs in the header. This is adequate for my uses
There are many ways to store the audio ID, in this case I would use a std::map with a key/val pair, you can for this example set the key to the audio filename, and the value to the audio id:
ie: std::map<std::string,int>
(Can also use better data types or enums for the key than just the filename)
Where a std::pair could be of the form <"audio1.mp3", [the audio id int value returned]>
Then you can search your map by the key.
A std::vector of audio IDs might not mean much to you if you need to know which ID relates to which audio source.
As @anon22094508 said, you can also store it as an instance variable to a singleton helper class (where I would recommend you keep the std::map if you go that route), or inside specific objects. This is good for sound effects that should be encapsulated with their objects. ie:
In the case of a spaceship that has a sound effect for the engine… you could have an instance variable on the spaceship class:
declare in header:
unsigned int audioIDEngine;
Source:
audioIDEngine = <returned value of sound effect>
now you can stop/modify the effect from the object itself.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.