AudioRecorder recorder = Gdx.audio.newAudioRecorder(22050, true);
This will create an
AudioRecorder with a sampling rate of 22.05khz, in mono mode. If the recorder couldn’t be created, a
GdxRuntimeException will be thrown.
Samples can be read as 16-bit signed PCM:
short shortPCM = new short; // 1024 samples recorder.readSamples(shortPCM, 0, shortPCM.length);
Stereo samples are interleaved as usual (first sample -> left channel, second sample -> right channel).
AudioRecorder is a native resource and needs to be disposed of if no longer in use: