Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple cross-platform free audio library for raw PCM?

I'm writing a cross-platform Qt-based program that from time to time needs to play back audio supplied externally (outside my control) as raw PCM. The exact format is 16 bit little-endian PCM at various common sample rates.

My first obvious idea was to use Qt's own Phonon for audio playback, but there are two problems with this approach:

  1. As far as I can see, Phonon does not support headerless PCM data. I would have to hack around this and fake a WAV header every time playback starts. Not a showstopper, though.
  2. More importantly: There doesn't seem to be any way to control how Phonon (and its backends such as xine, PulseAudio, DirectX, whatever) prebuffers. Its default behaviour seems to be something like 5 seconds of prebuffering, which is way too much for me. I'd prefer about 1 second, and I'd definitely like to be able to control this!

I'm currently looking at Gstreamer, FFMPEG and libvlc. Any thoughts? Since my audio is in a very simple format and I don't need to do fancy mixing stuff (just volume control), I'd like a simple, free (as in freedom), cross-platform and widely available library.

like image 863
gspr Avatar asked Dec 29 '22 02:12

gspr


1 Answers

Qt 4.6 has the new QtMultimedia module.

https://doc.qt.io/archives/4.6/qtmultimedia.html

The QAudioOutput class would seem to do what you want - it just plays raw PCM data.

like image 99
BlackAura Avatar answered Jan 09 '23 05:01

BlackAura