Package com.vivoka.vsdk.audio.producers
Class AudioRecorder
java.lang.Object
com.vivoka.vsdk.audio.ProducerModule
com.vivoka.vsdk.audio.producers.AudioRecorder
AudioRecorder is a producer module that captures audio from the device's microphone.
It supports various configurations such as sample rate, channel configuration, and buffer size.
The recorded audio can be processed in real-time or saved for later use.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vivoka.vsdk.audio.ProducerModule
ProducerModule.State -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an AudioRecorder with default parameters.AudioRecorder(int audioSource) Constructs an AudioRecorder with the specified audio source.AudioRecorder(int sampleRate, int channelConfig, int bufferSizePerChannel) Constructs an AudioRecorder with the specified sample rate, channel configuration, and buffer size.AudioRecorder(int sampleRate, int channelConfig, int bufferSizePerChannel, int audioSource) Constructs an AudioRecorder with the specified sample rate, channel configuration, buffer size, and audio source. -
Method Summary
Methods inherited from class com.vivoka.vsdk.audio.ProducerModule
closeImpl, dispatchAudio, dispatchBuffer, getLastError, getState, isBusy, isClosed, isIdle, isOpened, isPaused, isStarted, pauseImpl, resumeImpl, runImpl, setLastError, setState, setStateChanedCallback, subscribeFirst, subscribeLast, unsubscribe
-
Constructor Details
-
AudioRecorder
@RequiresPermission("android.permission.RECORD_AUDIO") public AudioRecorder()Constructs an AudioRecorder with default parameters. It uses a sample rate of 16000 Hz, mono channel configuration, and a buffer size of 1024 bytes. The audio source is set to VOICE_COMMUNICATION. -
AudioRecorder
@RequiresPermission("android.permission.RECORD_AUDIO") public AudioRecorder(int audioSource) Constructs an AudioRecorder with the specified audio source. It uses a sample rate of 16000 Hz, mono channel configuration, and a buffer size of 1024 bytes.- Parameters:
audioSource- The audio source to use for recording such as VOICE_COMMUNICATION, MIC, etc. For a list of available audio sources, refer to the Android documentation: https://developer.android.com/reference/android/media/MediaRecorder.AudioSource
-
AudioRecorder
@RequiresPermission("android.permission.RECORD_AUDIO") public AudioRecorder(int sampleRate, int channelConfig, int bufferSizePerChannel) Constructs an AudioRecorder with the specified sample rate, channel configuration, and buffer size. The audio source is set to VOICE_COMMUNICATION.- Parameters:
sampleRate- The sample rate of the audio (e.g., 16000 Hz).channelConfig- The channel configuration (e.g., AudioFormat.CHANNEL_IN_MONO).bufferSizePerChannel- The size of the buffer for each channel in bytes.
-
AudioRecorder
@RequiresPermission("android.permission.RECORD_AUDIO") public AudioRecorder(int sampleRate, int channelConfig, int bufferSizePerChannel, int audioSource) Constructs an AudioRecorder with the specified sample rate, channel configuration, buffer size, and audio source. This allows for more flexibility in configuring the audio recording parameters.- Parameters:
sampleRate- The sample rate of the audio (e.g., 16000 Hz).channelConfig- The channel configuration (e.g., AudioFormat.CHANNEL_IN_MONO).bufferSizePerChannel- The size of the buffer for each channel in bytes.audioSource- The audio source to use for recording such as VOICE_COMMUNICATION, MIC, etc. For a list of available audio sources, refer to the Android documentation: https://developer.android.com/reference/android/media/MediaRecorder.AudioSource
-
-
Method Details
-
isRunning
public boolean isRunning()Checks if the AudioRecorder is currently running. This method returns true if the recorder is actively capturing audio, false otherwise.- Overrides:
isRunningin classProducerModule- Returns:
- True if the producer module is running, false otherwise.
-
openImpl
protected void openImpl()Description copied from class:ProducerModuleOpens the producer module. This method prepares the module for processing audio data. This method is called by the pipeline before starting or running the producer.- Overrides:
openImplin classProducerModule
-
startImpl
Description copied from class:ProducerModuleStarts the producer module in a non-blocking manner. The producer state must beOPENED. When calling start pipeline, this method will be called after theopenmethod. startImpl() should initiate the producer and return immediately without waiting for processing to complete and update the state to STARTED when it is done.- Overrides:
startImplin classProducerModule- Throws:
Exception- If an error occurs during starting.
-
stopImpl
Description copied from class:ProducerModuleStops the producer module. The producer state must beSTARTED. When calling stop pipeline, this method will be called. It should initiate the stopping process and return immediately without waiting for it to complete. It should make sure that the state is updated to OPENED when it is done.- Overrides:
stopImplin classProducerModule- Throws:
Exception- If an error occurs during stopping.
-