Discussion:
audo-echo
(too old to reply)
alex dashevski
2018-10-06 18:08:48 UTC
Permalink
Hi,

I talk about google audio-echo example.
https://github.com/googlesamples/android-ndk/tree/master/audio-echo

What the changes do I need to do if I want to record audio buffer until
buffer size is 10*original buffer size, do processing on the new buffer
size and then play every original buffer size(That means: 10 times).

Why do I need it ? I need it because algorithm that I want to run , buffer
should have duration >=50 ms, My recommended sample rate is 48Khz and
buffer size is 240 samples,

Thanks,
Alex
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/8136ed46-71a5-4719-91e4-87b69fdcd727%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Phil Burk' via android-ndk
2018-10-08 14:07:48 UTC
Permalink
Hello Alex,

The data is processed by your callback in 5 msec bursts. But your algorithm
requires 50 msec buffers.

So allocate a 50 msec input buffer and a 50 msec output buffer.
When you get a callback write 5 msec of data into the input buffer and
advance your index.
When your 50 msec input buffer is full, apply your algorithm and write the
result to your 50 msec output buffer.
Before leaving the callback, take 5 msec of data from the output buffer and
return it through the callback's 5 msec audioData buffer.
When you first start running, the 50 msec output buffer will be empty and
should be filled with zeros when allocated.

Note that the burst size on Android devices can vary from 96 to over 3000.
So your code needs to be flexible.

Or, in AAudio you can set the callback size using
AAudioStreamBuilder_setFramesPerDataCallback(). There is a similar
function in Oboe.
You would also need to set the buffer capacity to at least 50 msec on both
input and output.

Phil Burk
Post by alex dashevski
Hi,
I talk about google audio-echo example.
https://github.com/googlesamples/android-ndk/tree/master/audio-echo
What the changes do I need to do if I want to record audio buffer until
buffer size is 10*original buffer size, do processing on the new buffer
size and then play every original buffer size(That means: 10 times).
Why do I need it ? I need it because algorithm that I want to run , buffer
should have duration >=50 ms, My recommended sample rate is 48Khz and
buffer size is 240 samples,
Thanks,
Alex
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-ndk/8136ed46-71a5-4719-91e4-87b69fdcd727%40googlegroups.com
<https://groups.google.com/d/msgid/android-ndk/8136ed46-71a5-4719-91e4-87b69fdcd727%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CACL%3DQ7w8hVg%3DDv1GbZPA0a3SyDU7L4AiqFoEWO7HJ-1GaGD_GA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Alex Dashevski
2018-10-08 14:26:54 UTC
Permalink
Could you point me in the code where I need to do the changes ?
Thanks,
Alex

‫בתאךיך יום ב׳, 8 באוק׳ 2018 ב-17:08 מאת ‪'Phil Burk' via android-ndk‬‏ <‪
Post by 'Phil Burk' via android-ndk
Hello Alex,
The data is processed by your callback in 5 msec bursts. But your
algorithm requires 50 msec buffers.
So allocate a 50 msec input buffer and a 50 msec output buffer.
When you get a callback write 5 msec of data into the input buffer and
advance your index.
When your 50 msec input buffer is full, apply your algorithm and write the
result to your 50 msec output buffer.
Before leaving the callback, take 5 msec of data from the output buffer
and return it through the callback's 5 msec audioData buffer.
When you first start running, the 50 msec output buffer will be empty and
should be filled with zeros when allocated.
Note that the burst size on Android devices can vary from 96 to over 3000.
So your code needs to be flexible.
Or, in AAudio you can set the callback size using
AAudioStreamBuilder_setFramesPerDataCallback(). There is a similar
function in Oboe.
You would also need to set the buffer capacity to at least 50 msec on both
input and output.
Phil Burk
Post by alex dashevski
Hi,
I talk about google audio-echo example.
https://github.com/googlesamples/android-ndk/tree/master/audio-echo
What the changes do I need to do if I want to record audio buffer until
buffer size is 10*original buffer size, do processing on the new buffer
size and then play every original buffer size(That means: 10 times).
Why do I need it ? I need it because algorithm that I want to run ,
buffer should have duration >=50 ms, My recommended sample rate is 48Khz
and buffer size is 240 samples,
Thanks,
Alex
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-ndk/8136ed46-71a5-4719-91e4-87b69fdcd727%40googlegroups.com
<https://groups.google.com/d/msgid/android-ndk/8136ed46-71a5-4719-91e4-87b69fdcd727%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-ndk/CACL%3DQ7w8hVg%3DDv1GbZPA0a3SyDU7L4AiqFoEWO7HJ-1GaGD_GA%40mail.gmail.com
<https://groups.google.com/d/msgid/android-ndk/CACL%3DQ7w8hVg%3DDv1GbZPA0a3SyDU7L4AiqFoEWO7HJ-1GaGD_GA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAFvRVMALuN3PRwzZXT6rSk9qV4nTvUHQKGttT-GmLOxd8s-rdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
'Gerry Fan' via android-ndk
2018-10-12 17:45:21 UTC
Permalink
your apps does not seem to care about the low-latency, so most things about
fast path are not needed.

The buffer size is passed to native side in CreateSLEngine() call
createSLEngine(
Integer.parseInt(nativeSampleRate),
Integer.parseInt(nativeSampleBufSize),
<https://github.com/googlesamples/android-ndk/blob/master/audio-echo/app/src/main/java/com/google/sample/echo/MainActivity.java#L124>
echoDelayProgress,
echoDecayProgress);
so you could just fool the function with your 50 ms buffer size:
either do it in the live above, or in native code ( at that place, you just
ignore the passed in buffer size and use your own:

engine.fastPathFramesPerBuf_ = static_cast<uint32_t>(framesPerBuf);
<https://github.com/googlesamples/android-ndk/blob/master/audio-echo/app/src/main/cpp/audio_main.cpp#L59>

you might also need to change the BUF_COUNT
<https://github.com/googlesamples/android-ndk/blob/master/audio-echo/app/src/main/cpp/audio_common.h#L38>
to a small number ( your buffer is big, not in fast path anymore, so no
need ) like 8 or 4.

This sample assumes the small callback buffers, once you use the big
buffers, you could relax some logic.

Hope it helps

thanks
Post by Alex Dashevski
Could you point me in the code where I need to do the changes ?
Thanks,
Alex
‫בתאךיך יום ב׳, 8 באוק׳ 2018 ב-17:08 מאת ‪'Phil Burk' via android-ndk‬‏ <‪
Post by 'Phil Burk' via android-ndk
Hello Alex,
The data is processed by your callback in 5 msec bursts. But your
algorithm requires 50 msec buffers.
So allocate a 50 msec input buffer and a 50 msec output buffer.
When you get a callback write 5 msec of data into the input buffer and
advance your index.
When your 50 msec input buffer is full, apply your algorithm and write
the result to your 50 msec output buffer.
Before leaving the callback, take 5 msec of data from the output buffer
and return it through the callback's 5 msec audioData buffer.
When you first start running, the 50 msec output buffer will be empty and
should be filled with zeros when allocated.
Note that the burst size on Android devices can vary from 96 to over
3000. So your code needs to be flexible.
Or, in AAudio you can set the callback size using
AAudioStreamBuilder_setFramesPerDataCallback(). There is a similar
function in Oboe.
You would also need to set the buffer capacity to at least 50 msec on
both input and output.
Phil Burk
Post by alex dashevski
Hi,
I talk about google audio-echo example.
https://github.com/googlesamples/android-ndk/tree/master/audio-echo
What the changes do I need to do if I want to record audio buffer until
buffer size is 10*original buffer size, do processing on the new buffer
size and then play every original buffer size(That means: 10 times).
Why do I need it ? I need it because algorithm that I want to run ,
buffer should have duration >=50 ms, My recommended sample rate is 48Khz
and buffer size is 240 samples,
Thanks,
Alex
--
You received this message because you are subscribed to the Google
Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send
<javascript:>.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-ndk/8136ed46-71a5-4719-91e4-87b69fdcd727%40googlegroups.com
<https://groups.google.com/d/msgid/android-ndk/8136ed46-71a5-4719-91e4-87b69fdcd727%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an
<javascript:>.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-ndk/CACL%3DQ7w8hVg%3DDv1GbZPA0a3SyDU7L4AiqFoEWO7HJ-1GaGD_GA%40mail.gmail.com
<https://groups.google.com/d/msgid/android-ndk/CACL%3DQ7w8hVg%3DDv1GbZPA0a3SyDU7L4AiqFoEWO7HJ-1GaGD_GA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/39244086-6ed7-44f2-a828-286c2b435ca8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alex Dashevski
2018-10-12 17:53:05 UTC
Permalink
Hi,
I don't understand. I want to ajust the latency but still want to use
recommended parameters.
Thanks,
Alex

‫בתאךיך יום ו׳, 12 באוק׳ 2018 ב-20:45 מאת ‪'Gerry Fan' via android-ndk‬‏ <‪
Post by 'Gerry Fan' via android-ndk
your apps does not seem to care about the low-latency, so most things
about fast path are not needed.
The buffer size is passed to native side in CreateSLEngine() call
createSLEngine(
Integer.parseInt(nativeSampleRate),
Integer.parseInt(nativeSampleBufSize),
<https://github.com/googlesamples/android-ndk/blob/master/audio-echo/app/src/main/java/com/google/sample/echo/MainActivity.java#L124>
echoDelayProgress,
echoDecayProgress);
either do it in the live above, or in native code ( at that place, you just
engine.fastPathFramesPerBuf_ = static_cast<uint32_t>(framesPerBuf);
<https://github.com/googlesamples/android-ndk/blob/master/audio-echo/app/src/main/cpp/audio_main.cpp#L59>
you might also need to change the BUF_COUNT
<https://github.com/googlesamples/android-ndk/blob/master/audio-echo/app/src/main/cpp/audio_common.h#L38>
to a small number ( your buffer is big, not in fast path anymore, so no
need ) like 8 or 4.
This sample assumes the small callback buffers, once you use the big
buffers, you could relax some logic.
Hope it helps
thanks
Post by Alex Dashevski
Could you point me in the code where I need to do the changes ?
Thanks,
Alex
‫בתאךיך יום ב׳, 8 באוק׳ 2018 ב-17:08 מאת ‪'Phil Burk' via android-ndk‬‏ <‪
Post by 'Phil Burk' via android-ndk
Hello Alex,
The data is processed by your callback in 5 msec bursts. But your
algorithm requires 50 msec buffers.
So allocate a 50 msec input buffer and a 50 msec output buffer.
When you get a callback write 5 msec of data into the input buffer and
advance your index.
When your 50 msec input buffer is full, apply your algorithm and write
the result to your 50 msec output buffer.
Before leaving the callback, take 5 msec of data from the output buffer
and return it through the callback's 5 msec audioData buffer.
When you first start running, the 50 msec output buffer will be empty
and should be filled with zeros when allocated.
Note that the burst size on Android devices can vary from 96 to over
3000. So your code needs to be flexible.
Or, in AAudio you can set the callback size using
AAudioStreamBuilder_setFramesPerDataCallback(). There is a similar
function in Oboe.
You would also need to set the buffer capacity to at least 50 msec on
both input and output.
Phil Burk
Post by alex dashevski
Hi,
I talk about google audio-echo example.
https://github.com/googlesamples/android-ndk/tree/master/audio-echo
What the changes do I need to do if I want to record audio buffer until
buffer size is 10*original buffer size, do processing on the new buffer
size and then play every original buffer size(That means: 10 times).
Why do I need it ? I need it because algorithm that I want to run ,
buffer should have duration >=50 ms, My recommended sample rate is 48Khz
and buffer size is 240 samples,
Thanks,
Alex
--
You received this message because you are subscribed to the Google
Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-ndk/8136ed46-71a5-4719-91e4-87b69fdcd727%40googlegroups.com
<https://groups.google.com/d/msgid/android-ndk/8136ed46-71a5-4719-91e4-87b69fdcd727%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-ndk/CACL%3DQ7w8hVg%3DDv1GbZPA0a3SyDU7L4AiqFoEWO7HJ-1GaGD_GA%40mail.gmail.com
<https://groups.google.com/d/msgid/android-ndk/CACL%3DQ7w8hVg%3DDv1GbZPA0a3SyDU7L4AiqFoEWO7HJ-1GaGD_GA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-ndk/39244086-6ed7-44f2-a828-286c2b435ca8%40googlegroups.com
<https://groups.google.com/d/msgid/android-ndk/39244086-6ed7-44f2-a828-286c2b435ca8%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAFvRVMBHwfngWPsJKj_UJ7YXkyRRLPhCFEbOdRBA4syx6UiyKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...