igorski / MWEngine

Audio engine and DSP library for Android, written in C++ providing low latency performance within a musical context, while providing a Java/Kotlin API. Supports both OpenSL and AAudio.
MIT License
264 stars 45 forks source link

Is there possible to adjust the volume of latency or turn off those live voice feedback? #160

Closed YogarajRamesh closed 2 years ago

YogarajRamesh commented 2 years ago

Hi @igorski ,

While recording, their is live voice feedback (latency). In some older device those voices feed back is delayed by more than 200 milliseconds. So we need option to adjust the volume of latency or mute the live voice feedback while recording for those particular device.

Is there possible to adjust the volume of latency or turn off those live voice feedback?

Thanks in advance @igorski

igorski commented 2 years ago

Hi @YogarajRamesh the input channel used for recording the microphone is an AudioChannel like any other. As such, prior to invoking MWEngine.startOutputRecording() you can set the muted state using MWEngine.getInputChannel().setMuted( true ).

YogarajRamesh commented 2 years ago

Hi @igorski ,

  1. When I set the input channel to mute by the following snippet. Then input Audio(voice) get muted. But the recorded output audio also Muted means I am getting output with out voice.

private class RecordOutputHandler implements View.OnClickListener { @Override public void onClick( View v ) { _isRecording = !_isRecording;
_engine.getInputChannel().setMuted( true );
if ( _isRecording ) _engine.startOutputRecording( Environment.getExternalStorageDirectory().getAbsolutePath() + "/Download/testsm.wav" ); else _engine.stopOutputRecording(); (( Button ) v ).setText( _isRecording ? R.string.rec_btn_off : R.string.rec_btn_on ); } }

when i do the save with setRecordFromDeviceInputState. i am able to get the output with audio(voice).

_engine.getInputChannel().setMuted( true );
engine.setRecordFromDeviceInputState( _isRecording, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Download/test/"+fname+".wav", 10000);

Thank you @igorski

igorski commented 2 years ago

Maybe I misunderstood.

Am I correct that your intention is to:

Record the microphone input with the input muted during playback And at the same time record the engine output including the input audible?.

YogarajRamesh commented 2 years ago

Thank you so much for your time @igorski

Yes you are correct

YogarajRamesh commented 2 years ago

Hi @igorski Sorry to disturb you again, Did you have the time to check on this?

Eagerly waiting for your reply.

Thanks in advance

igorski commented 2 years ago

Hi, this is added in commit 6fe135518fce8edd52e6e23d59d3025efd651237

When output recording is activated AND input recording is activated with a muted input channel, the input is written into the disk output (but remains inaudible on the device as before, to prevent feedback loops).

    // activate input recording with muted monitoring
    MWEngineInstance.getInputChannel().setMuted( true );
    MWEngineInstance.recordInput( true );

    // record output handler
    if ( shouldRecordOutput ) {
        MWEngineInstance.startOutputRecording( Environment.getExternalStorageDirectory().getAbsolutePath() + "/path/file_name.wav" );
    } else {
        MWEngineInstance.stopOutputRecording();
    }
YogarajRamesh commented 2 years ago

Hi @igorski This function is working great. Thank you for your time and effort.