In addition to the Music
and Sound
interfaces Libgdx also provides two more low-level audio interfaces that enable direct access to the audio device. They can be used for recording and playback of raw samples of audio data. Those samples are stored as a PCM-encoded audio signal.
The AudioDevice
interface allows you to send PCM-encoded audio samples directly to the audio device. For this to work, a new audio device can be requested using Libgdx's Gdx.audio
module and called by its newAudioDevice()
method as follows:
AudioDevice audioDevice = Gdx.audio.newAudioDevice(44100, false);
The preceding line of code allocates a new instance of an audio device with a sample rate of 44.1 kHz in stereo mode. Requested instances of AudioDevice
need to be disposed using the dispose()
method when they are no longer needed in order to avoid memory...