In Cocos2d-x (3.6) I am trying to add increased functionality to SimpleAudioEngine. Specifically, with regard to Android's SoundPool (which SimpleAudioEngine is based upon, at least for Android), I am trying to add some of the methods that have not yet been implemented but are documented in the Android Developer web site.
For example, SoundPool's play method includes a loop variable that is of type int, whereas in SimpleAudioEngine it is of type bool (boolean on the Java side). If I can implement a new method with the loop variable as type int, I will be able to control the number of repetitions directly when I call the playEffect method.
I have figured out most of the changes required, including various C++ header and .cpp files (cocos/audio/include/SimpleAudioEngine.h, cocos/audio/android/cddSimpleAudioEngine.cpp, cocos/audio/android/jni/cddandroidAndroidJavaEngine.h, and cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp) and also the Cocos2dxSound.java file, but I am still getting error messages saying that my new method (which I am calling playEffectN) cannot be found.
The only other place I can see where something might need to be added is in the cocos/audio/openal/SimpleAudioEngineOpenAL.cpp file, but I'm not quite sure how to modify that in order to add my new method.
Can anyone point me in the right direction as to what else I need to do in order to add this additional functionality to SimpleAudioEngine? If I am successful, I will gladly share the results. (If successful, I will also be able to add some of the other unimplemented methods in SoundPool, such as setLoop, setPriority, setRate, and setVolume, for sounds that have already been assigned a soundID.)
first, add c++ apis, in :
though there is no implement in cddSimpleAudioEngine.cpp, you still need to declare functions in AudioEngine.h
then, the bridge btween c++ and java:
here, declare in cddandroidAndroidJavaEngine.h and implement in cddandroidAndroidJavaEngine.cpp, like
then in java
add function like:
finally is your java implement, in