Created
March 10, 2022 05:21
-
-
Save cp-radhika-s/16194343d0dda1977574daf6dae55020 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private const val RECORDER_SAMPLERATE = 44100 | |
private val RECORDER_CHANNELS: Int = AudioFormat.CHANNEL_IN_STEREO | |
private val RECORDER_AUDIO_ENCODING: Int = AudioFormat.ENCODING_PCM_16BIT | |
class AudioStreamManager { | |
private var audioRecord: AudioRecord? = null | |
val BUFFER_SIZE_RECORDING = AudioRecord.getMinBufferSize( | |
RECORDER_SAMPLERATE, | |
RECORDER_CHANNELS, | |
RECORDER_AUDIO_ENCODING | |
) * 4 | |
fun initAudioRecorder() { | |
audioRecord = AudioRecord( | |
MediaRecorder.AudioSource.MIC, | |
RECORDER_SAMPLERATE, RECORDER_CHANNELS, | |
RECORDER_AUDIO_ENCODING, BUFFER_SIZE_RECORDING | |
) | |
audioRecord?.startRecording() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment