I want to write some code to download and decode multiple MP3 files in parallel, as fast as possible. It seems SuperpoweredAdvancedAudioPlayer is the only thread safe class in the library, but what's not clear to me is if you can call process() as fast as possible (assuming the data is available for decoding). Is this possible or must process() be called more or less in real time?
Asked
Active
Viewed 185 times
1 Answers
1
You can call process() faster. I guess you will call it in an "offline" thread, not in an audio I/O thread? Please note that using the SuperpoweredDecoder class would be even better, it doesn't have the additional processing of the player. The offline processing example in the Superpowered SDK shows how to decode a file in an "offline" thread.

Gabor Szanto
- 1,329
- 8
- 12
-
SuperpoweredDecoder works like charm, but if there are two different file with samples decoded coming different (eg 1024, 1152) it starts producing noise and SuperpoweredAudioMixer can input only one sample decoded value. also fwrite we need to give only one sample decoded value. how to handel this ? – Kathan Shah Nov 06 '18 at 09:08
-
1You need to introduce some buffering in this case. Futhermore, the sample rate of the files may be different too, so you may need to resample. – Gabor Szanto Nov 06 '18 at 10:04
-
buffering exactly where? using asked size buffers wherever required for i/o. also, can resampling be done via superpowered? – Kathan Shah Nov 06 '18 at 11:07
-
1Buffering in your custom code. SuperpoweredResampler exists, yes. – Gabor Szanto Nov 06 '18 at 12:33
-
Thanks for SuperpoweredResampler (will go through it) I understand buffering in my custom code, but buffering of what exactly? decoder decodes >= samplesPerFrame. and on return i get the samples decoded value. both different for different file, 1024, 1152. I am using SuperpoweredStereoMixer to mix the samples decoded by the decoder with any one of the samples per frame i.e. 1024 and 1152 and both produce distortion when both files have different samples per frame. What exactly should be buffered for this fix.? – Kathan Shah Nov 06 '18 at 12:40
-
Here is an example, if the sample rate is the same for both files (so no SuperpoweredResampler is needed): - read 1024 from the first decoder into a buffer - read 1152 from the second decoder into another buffer - if both buffers have 1024 frames, mix 1024 frames and remove 1024 frames from both buffers - repeat! If resampling is needed, then the situation is bit more complex, because the number of samples will be different every time. – Gabor Szanto Nov 06 '18 at 14:08
-
Thanks for your reply. you said read 1024 from one the first decoder and read 1152 from second decoder. how can both buffers have 1024 frames ? i am doing exactly same (reading samplesPerFrame) in seperate buffers and mixing using SuperpoweredAudioMixer. but where the samplesPerFrame is same for both files i.e.1024 it has no distortion but where samplesPerFrame is different 1024 and 1152 it produces distortion in mixed file. if i read 1024 from one and 1152 from another buffer how can both buffers have 1024 frames? – Kathan Shah Nov 06 '18 at 14:25
-
Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/183191/discussion-between-kathan-shah-and-gabor-szanto). – Kathan Shah Nov 06 '18 at 14:25
-
both buffers can not have 1024 frames obviously – Gabor Szanto Nov 06 '18 at 14:25
-
you need to read into some kind of circular buffer, or just memmove the remaining data – Gabor Szanto Nov 06 '18 at 14:26
-
Will SuperpoweredAdvancedAudioPlayer do buffering / resampling task ot of the box ?, than i can use it in while loop instead of audio i/o callback. – Kathan Shah Nov 06 '18 at 14:29