How to reuse audio files in Superpowered?

巧了我就是萌 提交于 2019-12-08 12:30:13

问题


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);

回答1:


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.



来源:https://stackoverflow.com/questions/42563445/how-to-reuse-audio-files-in-superpowered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!