ZeroOneZeroR / android_audio_mixer

A simple android library for processing audio and mixing multiple audios parallelly or sequentially, made with android native media APIs (MediaExtractor, MediaCodec, MediaFormat, MediaMuxer) and JAVA.
68 stars 18 forks source link

Sequential concatentation to start before the previous sound has finished #3

Open ThomasVeitch opened 4 years ago

ThomasVeitch commented 4 years ago

Not really an issue but a requirement.

It would be useful if you were able to make a wav file from many wav files. But instead of sequentially waiting until one sound finished before concatenating it to the end, you can start a sound before the first finished. So really I'm looking for a mixture of parallel and sequential, but the sequential being able to be added at a specific time before the previous sound has finished. Is this possible? Could you do it?

Thanks.

ZeroOneZeroR commented 4 years ago

What you want can be done by this. You just need to use parallel mixing with blank audio input.

Aren't wav files supported?

ThomasVeitch commented 4 years ago

Thanks for getting back to me quickly,

You'll have to detail this as I've tried

audioMixer.addDataSource(input1); // 2 secs long audioMixer.addDataSource(blankInput); // 0.5 secs gap audioMixer.addDataSource(input2); // 2 secs long

audioMixer.setMixingType(AudioMixer.MixingType.PARALLEL);

The desired output would be to play at 0 secs input 1; then at 0.5 secs play input 2. (when input 1 is still playing)

The above is just putting everything in parallel so they all play at the same time.

If I change the setting to SEQUENTIAL then at 0 secs input 1 is played, then at 2 secs there is a gap at 2.5 secs input 2 is played.

Please explain how to achieve desired output.

Tom

On Thu, 6 Aug 2020 at 13:29, Rakibul Hasan Rajib notifications@github.com wrote:

What you want can be done by this. You just need to use parallel mixing with blank audio input.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rajib010/android_audio_mixer/issues/3#issuecomment-669897268, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7LABH3FMZELRM6HI7WIN3R7KOZBANCNFSM4PWQ43RQ .

ZeroOneZeroR commented 4 years ago

Sorry, I gave the wrong answer. Currently this not possible with this. Need to do some work.

ThomasVeitch commented 4 years ago

Thanks.

I look forward to it!

Tom.

On Thu, 6 Aug 2020 at 13:54, Rakibul Hasan Rajib notifications@github.com wrote:

Sorry, I gave the wrong answer. Currently this not possible with this. Need to do some work.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rajib010/android_audio_mixer/issues/3#issuecomment-669908673, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7LABBQBJGLSQ6AYWQFJFDR7KRXVANCNFSM4PWQ43RQ .

ThomasVeitch commented 4 years ago

Hi Rakibul,

When will this be ready? I'd really like this functionality.

Tom

On Thu, 6 Aug 2020 at 14:39, Tom Veitch tveitch75@gmail.com wrote:

Thanks.

I look forward to it!

Tom.

On Thu, 6 Aug 2020 at 13:54, Rakibul Hasan Rajib notifications@github.com wrote:

Sorry, I gave the wrong answer. Currently this not possible with this. Need to do some work.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rajib010/android_audio_mixer/issues/3#issuecomment-669908673, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7LABBQBJGLSQ6AYWQFJFDR7KRXVANCNFSM4PWQ43RQ .

ZeroOneZeroR commented 4 years ago

I will work on it soon.

ZeroOneZeroR commented 4 years ago

Your problem has been solved. You can now set startOffsetUs() to GeneralAudioInput. Use version v1.1

ZeroOneZeroR commented 4 years ago

Do you have the previous version's code? I need the README.md file. Could you provide me with that, please?

ThomasVeitch commented 4 years ago

Just did a quick rattle test and it's looking fantastic. So many thanks. It's looking like an excellent API.

On Mon, 24 Aug 2020 at 13:25, Rakibul Hasan Rajib notifications@github.com wrote:

Your problem has been solved. You can now set startOffsetUs() to GeneralAudioInput.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rajib010/android_audio_mixer/issues/3#issuecomment-679095367, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7LABENXY7U6XP4NSKD2X3SCJL37ANCNFSM4PWQ43RQ .

ZeroOneZeroR commented 4 years ago

Thank you so much.

ThomasVeitch commented 4 years ago

Hi Rakibul, We are using the API in a proper project and it's become apparent we need some functionality adding. We have created about a 10second wav file and we intend to loop it using MediaPlayer setLooping(true) The issue is we don't want to wait until the loop has finished to start again. We want to start the next loop at a designated time before the previous loop has finished. Would this be possible? Thanks.

On Tue, 25 Aug 2020 at 13:44, Rakibul Hasan Rajib notifications@github.com wrote:

Thank you so much.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rajib010/android_audio_mixer/issues/3#issuecomment-680001624, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7LABG6OZIXYY6OOIFY33LSCOWZLANCNFSM4PWQ43RQ .

ZeroOneZeroR commented 4 years ago

You want this while playing with Mediaplayer? I haven't got you properly.

ThomasVeitch commented 4 years ago

Yes. Thanks to your API we have created a 15 second .wav file with lots of individual sounds running in parallel and sequentially. With the offSet functionality we have been able to mix sounds properly without having to wait until a previous sound has finished.

However we intend to loop this newly created 15 second .wav file. We are using MediaPlayer to play this .wav file.

Unfortunately, when trying to loop this new .wav file, you have to wait until the whole wav file has finished playing. Are you able to extend your functionality so that we can loop the wav file, without having to wait until the very end of the file. We need to able to start the new loop at a designated offset before the previous loop has finished.

On Wed, 9 Sep 2020 at 16:12, rajib010 notifications@github.com wrote:

You want this while playing with Mediaplayer? I haven't got you properly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rajib010/android_audio_mixer/issues/3#issuecomment-689627775, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7LABDAKV7UPUUISSV5QP3SE6LNRANCNFSM4PWQ43RQ .

ZeroOneZeroR commented 4 years ago

You can add one audio multiple times. You can add the previous Audios again with new AudioInputs with your required settings. You have to calculate the startOffset for looping.

ThomasVeitch commented 4 years ago

The issue with creating a huge wav file with AudioMixer (and not looping in MediaPlayer) is that it''s slow to create and the volume is really low.

On Wed, 9 Sep 2020 at 16:31, rajib010 notifications@github.com wrote:

You can add one audio multiple times. You can add the previous Audios again with new AudioInputs with your required settings. You have to calculate the startOffset for looping.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rajib010/android_audio_mixer/issues/3#issuecomment-689639665, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK7LABESVNW2XLN4N7JPVZDSE6NTTANCNFSM4PWQ43RQ .

ZeroOneZeroR commented 4 years ago

Maybe i will have to do something to maintain the volume. I already have thought about it. Let me do something with volume. But i can't do anything with timing.