OFAndroidSoundStream latency

Hey there!

I work on an openframeworks app for android which generates audio.
I use the audioRequested callback and everything works fine.

But i have like 300ms latency from the touch event, that triggers a sound output, and the output from the loudspeaker which is much to long.

I tested with the ofSoundPlayer and there i don’t have that much latency (about 100ms, which is standard for my device), so i think it’s a Problem of the SoundStream.

I tracked through the signal path and measured that from the touch event to oTrack.write() in OFAndroidSoundStream it’s just takes about 40ms.

Anyone knows where the rest of the latency comes from?
Why doe it takes this much longer than the Soundplayer?

Thanks!

it’s usually because the underalying java class the soundstream uses requires a huge buffer size which introduces a lot of latency. there might be some api in newer versions that allows to set that buffer to a lower size but most probably we need to port our code to use opensl instead of the java classes we are using now

Thanks, i’ll have to use Opensl then.