google / oboe

Oboe is a C++ library that makes it easy to build high-performance audio apps on Android.
Apache License 2.0
3.7k stars 566 forks source link

LiveEffect: mute original recorded stream #729

Closed bletru closed 1 year ago

bletru commented 4 years ago

In the example LiveEffect the original recorded stream is replicated to the output stream and there is a possbility to alter the recorded stream and play at the same time.

Is it possible and how to mute the recorded stream and playing only the altered stream?

The idea is to make an equalizer which has more bands and features than the internal equalizer.

dturner commented 4 years ago

I'm unsure exactly what your question is.

Are you trying to add an equalizer to data coming from the microphone and then play it? If so, this is definitely possible using the LiveEffect as a starting point and adding your equalizer processing code inside the output stream callback.

If your question is "how can I add an equalizer to all sounds produced by the user's phone" the answer is also yes, although this can't be done using Oboe.

You may want to check out the DynamicsProcessing effect https://developer.android.com/reference/android/media/audiofx/DynamicsProcessing

dturner commented 4 years ago

Please provide more information and I'll try to help further. If I don't hear back from you within 7 days the issue will be closed.

bletru commented 4 years ago

Hi Don,

Thanks for your answer and I am happy to provide you more information

about my project.

I am developing an audio therapy where people have to listen to modified music

(some special equalizer processing using FFT) in order to improve their auditive capacity.

The actual beta version loads chunks from a "local" MP3 or WAV music file on the Android

device, modifies it and then plays it through the actual speaker or for my application

to the headphone (either through the jack or Bluetooth). Anyway, it is the

actual standard output device whatever it is.

In order to do the therapy, the client has to listen at least 1 hour per day for

at least 14 days. It is possible to always listen to the same MP3 files downloaded

on the Android device but after some time you always turn around on the same music.

Thus I had the idea to "fetch" a live stream, to modify it and play it.

In this way the client has "infinite" audio files to his convenience to listen to.

I have already succeeded to gather some of the URLs streams of TuneIn

but it is a manual task. Further this scheme is not working for example

Spotify or Youtube.

By searching on the Internet I became aware of your OBOE library and

already succeeded to make playing the samples. One of them is LiveEffect

which seems very near to what I need. Already confirmed to be able

to catch TuneIn, Youtube and Spotify.

I am able to catch the incoming stream (e.g. I launch TuneIn or another Internet radio),

to modify it and stream it to the standard out device. But the LiveEffect application

plays the original input at the same as the modified output which is not desired in my case.

The client should only listen to the modified version and not the original.

So we are back to my question: is there any way to catch the incoming stream,

but mute it for output and play only the modified version gone through my onReady callbacks?

As an complementary information, the library tells me in the output that my application

is not able to open the output stream in Exclusive mode. Perhaps because there is

already another stream playing and perhaps thus the two streams would be mixed

together?

I would be really happy and grateful if I could extend my application with this

"live" streaming possibly.

Thanks in advance for your and my best regards

Christoph

--

INFISA Consulting

Christoph Malloth

Ch. sur le Blétru 12

1132 Lully

info@infisa.ch mailto:info@infisa.ch

021 802 23 44

De : Don Turner notifications@github.com Envoyé : mercredi, 18 décembre 2019 14:15 À : google/oboe oboe@noreply.github.com Cc : bletru info@infisa.ch; Author author@noreply.github.com Objet : Re: [google/oboe] LiveEffect: mute original recorded stream (#729)

I'm unsure exactly what your question is.

Are you trying to add an equalizer to data coming from the microphone and then play it? If so, this is definitely possible using the LiveEffect as a starting point and adding your equalizer processing code inside the output stream callback.

If your question is "how can I add an equalizer to all sounds produced by the user's phone" the answer is also yes, although this can't be done using Oboe.

You may want to check out the DynamicsProcessing effect https://developer.android.com/reference/android/media/audiofx/DynamicsProcessing

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google/oboe/issues/729?email_source=notifications&email_token=ADISJJZX6DB7WOLTBBCIGUTQZIO4BA5CNFSM4J3N2HP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHGCEIA#issuecomment-567026208 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADISJJ66ORCV3XYXX5KJCKLQZIO4BANCNFSM4J3N2HPQ . https://github.com/notifications/beacon/ADISJJ4WO75RW3U5TWMJGSLQZIO4BA5CNFSM4J3N2HP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHGCEIA.gif

philburk commented 4 years ago

To summarize: it sounds like you want to insert a custom effect into the output path of music streaming apps like Spotify.

bletru commented 4 years ago

Exact. Custom effect and only this custom effect output

is passed through the output path.

Would be happy if there is an easy solution for this.

Looking for hearing from you, best regards

Christoph

--

INFISA Consulting

Christoph Malloth

Ch. sur le Blétru 12

1132 Lully

info@infisa.ch mailto:info@infisa.ch

021 802 23 44

De : Phil Burk notifications@github.com Envoyé : mercredi, 18 décembre 2019 16:55 À : google/oboe oboe@noreply.github.com Cc : bletru info@infisa.ch; Author author@noreply.github.com Objet : Re: [google/oboe] LiveEffect: mute original recorded stream (#729)

To summarize: it sounds like you want to insert a custom effect into the output path of music streaming apps like Spotify.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google/oboe/issues/729?email_source=notifications&email_token=ADISJJ7NGGR4YDIGMOCNKA3QZJBWDA5CNFSM4J3N2HP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHGSKIQ#issuecomment-567092514 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADISJJ5QSOVUCWIZFLRHC6DQZJBWDANCNFSM4J3N2HPQ . https://github.com/notifications/beacon/ADISJJ42B255XTXJCEODXBLQZJBWDA5CNFSM4J3N2HP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHGSKIQ.gif

dturner commented 4 years ago

What you are describing cannot be done by Oboe.

It can be done by using an Equalizer (https://developer.android.com/reference/android/media/audiofx/Equalizer.html) and attaching to session id = 0.

bletru commented 4 years ago

Hi Don,

Are you sure that I can't be done?

The built-in Equalizer of Android can do this but it has not enough

bands (I need at least 22) and I have special modification which changes

almost 1 to 2 seconds.

So could you give a pointer where I can find the low-level implementation

of the equalizer in the Android source?

Best regards

Christoph

--

INFISA Consulting

Christoph Malloth

Ch. sur le Blétru 12

1132 Lully

info@infisa.ch mailto:info@infisa.ch

021 802 23 44

De : Don Turner notifications@github.com Envoyé : vendredi, 20 décembre 2019 14:45 À : google/oboe oboe@noreply.github.com Cc : bletru info@infisa.ch; Author author@noreply.github.com Objet : Re: [google/oboe] LiveEffect: mute original recorded stream (#729)

What you are describing cannot be done by Oboe.

It can be done by using an Equalizer (https://developer.android.com/reference/android/media/audiofx/Equalizer.html) and attaching to session id = 0.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google/oboe/issues/729?email_source=notifications&email_token=ADISJJ3NIM7PUFNGB6ZR2OLQZTD5BA5CNFSM4J3N2HP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHM6RZA#issuecomment-567929060 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADISJJ4XDNRXWB5JK7QHQY3QZTD5BANCNFSM4J3N2HPQ . https://github.com/notifications/beacon/ADISJJ2VED7FRRP4WVOIEBLQZTD5BA5CNFSM4J3N2HP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHM6RZA.gif

philburk commented 4 years ago

There is a new EQ in Q that has more bands and additional features. It is used for the smart hearing assistance feature. So it is very flexible.

https://developer.android.com/reference/android/media/audiofx/DynamicsProcessing

Phil Burk

On Fri, Dec 20, 2019 at 7:44 AM bletru notifications@github.com wrote:

Hi Don,

Are you sure that I can't be done?

The built-in Equalizer of Android can do this but it has not enough

bands (I need at least 22) and I have special modification which changes

almost 1 to 2 seconds.

So could you give a pointer where I can find the low-level implementation

of the equalizer in the Android source?

Best regards

Christoph

--

INFISA Consulting

Christoph Malloth

Ch. sur le Blétru 12

1132 Lully

info@infisa.ch mailto:info@infisa.ch

021 802 23 44

De : Don Turner notifications@github.com Envoyé : vendredi, 20 décembre 2019 14:45 À : google/oboe oboe@noreply.github.com Cc : bletru info@infisa.ch; Author author@noreply.github.com Objet : Re: [google/oboe] LiveEffect: mute original recorded stream (#729)

What you are describing cannot be done by Oboe.

It can be done by using an Equalizer ( https://developer.android.com/reference/android/media/audiofx/Equalizer.html) and attaching to session id = 0.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/google/oboe/issues/729?email_source=notifications&email_token=ADISJJ3NIM7PUFNGB6ZR2OLQZTD5BA5CNFSM4J3N2HP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHM6RZA#issuecomment-567929060> , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ADISJJ4XDNRXWB5JK7QHQY3QZTD5BANCNFSM4J3N2HPQ> . < https://github.com/notifications/beacon/ADISJJ2VED7FRRP4WVOIEBLQZTD5BA5CNFSM4J3N2HP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHM6RZA.gif>

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/google/oboe/issues/729?email_source=notifications&email_token=ABHPU2OBMPFX77RFMDNM7VTQZTR6TA5CNFSM4J3N2HP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHNILSQ#issuecomment-567969226, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHPU2N6SQU2VFMJP7SOQJLQZTR6TANCNFSM4J3N2HPQ .

dturner commented 4 years ago

Are you sure that I can't be done?

Yes :) Oboe cannot modify an audio stream owned by another application. It can only create its own audio streams. In the case of LiveEffect it does something similar to your requirements because the Oboe owns both the input and output stream.

Take a look at the DynamicsProcessing API Phil posted (and I posted in my first response). It should do what you need.

philburk commented 1 year ago

Closing as infeasible.