Code Monkey home page Code Monkey logo

Comments (4)

igorski avatar igorski commented on July 26, 2024

Hi @YogarajRamesh

you mean dB ? So ideally when the sound goes below a certain threshold (e.g. audio level) you want to completely silence the signal.

If so, sounds like a gate effect, which is actually under development at the moment, it might work for your use case.

from mwengine.

YogarajRamesh avatar YogarajRamesh commented on July 26, 2024

Hi @igorski
Yes, that's what I meant.
Thanks for your reply,

from mwengine.

igorski avatar igorski commented on July 26, 2024

Alright, the latest version of the repository now includes Compressor and Gate processors.

For your use case, I would recommend to use the gate. It has the following methods:

gate.setThreshold( float valueInDb );
gate.setAttack( float value );
gate.setRelease( float value );

The threshold defines the level in dB at which the gate should operate. Experiment with values in the 0 - 100 range. When the signal drops below the provided threshold, the gate becomes active (e.g. sound will be muted).

With the attack and release setters you can set a value (in milliseconds) that determines how fast the gate opens and closes (so you make the effect more smoother instead of a hard open- and close).

I suggest you place the Gate as the first processor in the processing chain of the audio channel (e.g. the one that records the mic input). That means all effects coming afterwards (for instance reverb) will operate as normal (and in the case of reverb add a more natural tail when the input closes).

Also, beware that the createOutput signature of MWEngine has been updated with a new version (as input channel amount is now configurable at runtime). The new way of creating output is:

MWEngineInstance.createOutput( int sampleRate, int bufferSize, int outputChannels, int inputChannels, Drivers.types driver );

So you likely need to provide an argument for inputChannels (setting this to 1 ensures you can access the device microphone).

from mwengine.

YogarajRamesh avatar YogarajRamesh commented on July 26, 2024

Hi @igorski,
Thanks for reply, I try to add gate processor to input channel processing chain. With dB value from 0.0f-100.0f no matter what ever the value set the sound stay muted always. Seems gate is always stay active.

Below is my code snippet
```

_gate=  new Gate(); 

_gate.setThreshold(100.0f);

_gate.setAttack(100 );

_gate.setRelease(100);
_engine.getInputChannel().getProcessingChain().reset();

_engine.getInputChannel().getProcessingChain().addProcessor(_gate);

_engine.startInputRecording(
 Environment.getExternalStorageDirectory().getAbsolutePath() + "/Download/test/outputt2.wav",false);
  ```

This is the log:

V/MWENGINE: AAudio_IO::AAudioStream_read() returns 0 read frames instead of 96
V/MWENGINE: AAudio_IO::Setting buffer size to 192
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 48 read frames instead of 96
V/MWENGINE: AAudio_IO::Setting buffer size to 288
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 0 read frames instead of 96
V/MWENGINE: AAudio_IO::Setting buffer size to 384
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 0 read frames instead of 96
V/MWENGINE: AAudio_IO::Setting buffer size to 480
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 0 read frames instead of 96
V/MWENGINE: AAudio_IO::Setting buffer size to 576
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 48 read frames instead of 96
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 0 read frames instead of 96
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 48 read frames instead of 96
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 48 read frames instead of 96
I/chatty: uid=10479(nl.igorski.mwengine.example) Thread-2 identical 1 line
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 48 read frames instead of 96
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 48 read frames instead of 96
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 48 read frames instead of 96
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 48 read frames instead of 96
I/chatty: uid=10479(nl.igorski.mwengine.example) Thread-2 identical 1 line
V/MWENGINE: AAudio_IO::AAudioStream_read() returns 48 read frames instead of 96
D/MWENGINE: Recorded snippet 0 saved to storage
V/MWENGINE: WaveReader::About to parse data for WAV file '/storage/emulated/0/Download/test/rec_snippet_0.WAV'
V/MWENGINE: File size    : 1440036
V/MWENGINE: Audio format   : 1
V/MWENGINE: Channel amount  : 1
V/MWENGINE: Sample rate   : 48000
V/MWENGINE: Bytes per second : 96000
V/MWENGINE: Block align   : 2
V/MWENGINE: Bits per sample : 16
V/MWENGINE: WaveReader::About to parse data for WAV file '/storage/emulated/0/Download/test/rec_snippet_1.WAV'
V/MWENGINE: File size    : 291300
V/MWENGINE: Audio format   : 1
V/MWENGINE: Channel amount  : 1
V/MWENGINE: Sample rate   : 48000
V/MWENGINE: Bytes per second : 96000
V/MWENGINE: Block align   : 2
V/MWENGINE: Bits per sample : 16
D/MWENGINE: Recording has completed

Thank you,

from mwengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.