Recording and playing back sounds with LibGDX

| | August 18, 2015

How do I record a sound to PCM format and replay it from there?

One Response to “Recording and playing back sounds with LibGDX”

  1. to record:

    AudioRecorder recorder = Gdx.audio.newAudioRecorder(sampleRate, isMono);
    short[] pCM = new float[1024]; // 1024 samples
    recorder.readSamples(pCM, 0, pCM.length);
    recorder.dispose();
    

    to play back:

    AudioDevice device = Gdx.audio.newAudioDevice(sampleRate, isMono);
    device.writeSamples(pCM, 0, pCM.length);
    device.dispose();
    

Leave a Reply