Reputation: 1
I'm building an Android digital piano with Superpowered SDK.
I use a SuperpoweredAdvancedAudioPlayer instance for every tone (e.g. c tone, d tone, e tone...).
To avoid memory, I would like to reuse audio samples (mp3 files) across SuperpoweredAdvancedAudioPlayer instances and - if necessary - pitch them down/up by a halftone (100 cent). e.g. The "E tone" uses the mp3 sample for the "D tone" and is just pitched up by 100 cent.
How can I make it happen, that the SuperpoweredAdvancedAudioPlayer instance for the e tone uses the same audio object as the d tone? (I want that the d-tone.mp3 file is only once allocated in memory)
Thanks!
Current instantiation:
player1 = new SuperpoweredAdvancedAudioPlayer(&player1 , playerEventCallback1, samplerate, 0);
player1->open(path, fileAoffset, fileAlength);
Upvotes: 0
Views: 445
Reputation: 1329
Just use the open method for every instance of the SuperpoweredAdvancedAudioPlayer. A player instance doesn't use a lot of memory. If that solution is not good enough, then use the SuperpoweredDecoder to uncompressed the original sound, and use multiple instances of the SuperpoweredTimeStretching to do the pitch changes. Of course this version takes a lot more code.
Upvotes: 1