10

I want to process audio online/live where I constantly read audio samples from an audio file, process these (e.g. apply some effect), and forward the processed samples to an audio output device like a soundcard. The input files have common formats such as wav, mp3, perhaps even ogg.

Is there a library available similar to libav/ffmpeg for audio files which simplifies reading various audio formats and provides me a constant stream of raw audio samples? Or is the best solution to use individual libraries for each format? The libraries should be c/c++ and cross-plattform compatible (Mac, Win, Linux, ARM).

EDIT Thanks for all answers. I have evaluated all libraries and came to the conclusion that it is best to just stick with libav/ffmpeg because most of the libraries require ffmpeg as a backend.

Hyndrix
  • 4,282
  • 7
  • 41
  • 82
  • 1
    I don't know about ARM, but on other platforms you mentioned you can use BASS audio library (Un4seen developments) for decoding. It supports these formats natively. – DuXeN0N Oct 16 '12 at 13:38
  • Thanks. I checked their website and they state that ARM is supported as well. But parts of the library seem to be closed source. Are there any LGPL or similar licensed libraries out there? – Hyndrix Oct 16 '12 at 13:44
  • 1
    Maybe libsndfile (http://www.mega-nerd.com/libsndfile/)? Or SOX (http://sox.sourceforge.net/Main/HomePage)? Haven't used them myself but they look promising. – Jong Bor Lee Oct 16 '12 at 13:54
  • Old question, but for AAC: FAAC and FAAD – Léon Pelletier Oct 10 '13 at 03:12

6 Answers6

4

I can recommend RtAudio or PortAudio for cross-platform audio I/O. For audio decoding you might want to have a look at libsndfile or libaudiodecoder.

cel
  • 153
  • 5
3

Check out Juce. It is a big library that has been used to develop VST audio plug-ins for music software. There is a lot of stuff you don't need in there, but I think you can pick and choose only the audio parts to include in your build. The AudioFormatReader and its associated classes can do the file reading, and there are also classes for outputting to the sound card. There's a lot of other audio processing tools as well. It's GPL licensed, cross platform, and they claim experimental Android support. I haven't used it for a project yet, but I am waiting for the inspiration!

japreiss
  • 11,111
  • 2
  • 40
  • 77
2

I'd check out libSDL, it has an audio subsystem that is built for doing things like that and handles ogg,mp3,flac,wav, etc..

hexist
  • 5,151
  • 26
  • 33
1

LibVLC can do this. libvlc supports the most various audio (and video) formats. It's a C/C++ crossplatform library. It should also support Arm code generation.

Sdra
  • 2,297
  • 17
  • 30
  • The backend to LibVLC are libav* libraries which come from FFmpeg. So you better use libav* perhaps LibVLC is required to build a full-fledged media player like VLC, for audio decoding you need libavformat and libavcodec and this is an [example decoder code](https://ffmpeg.org/doxygen/trunk/decode_audio_8c-example.html). – tripulse Mar 18 '21 at 15:13
1

You can use irrKlang library. I have used it for my games. It is very simple library to use, for example to play some file "somefile.mp3" you just need to write

engine->play2D("somefile.mp3", true);

And this library is cross-platform, too. And works with C++, C# and all .NET languages.

More features of this library (from its own site)

It has all the features known from low level audio libraries as well as lots of useful features like a sophisticated streaming engine, extendable audio reading, single and multithreading modes, 3d audio emulation for low end hardware, a plugin system, multiple rolloff models and more. All this can be accessed via an extremely simple API.

Jekin
  • 79
  • 1
  • 8
0

GAudio Library maybe is one you persuit. It is simple, powerfull, cross-platform and extendable

The hello world of GAudio like this:

gaudio_init("addons");

const char* filename = "..\\media\\trek12.wav";

gsource* source = gaudio_source_create_from_file(filename,FALSE);
if(source == NULL)
{   
    printf("load file:%s error!\n",filename);
    printf("bad source.\nerror code:%d.\n",gaudio_error_get());
    gaudio_deinit();
    return -1;
}

printf("play filename:%s\n",filename);

gaudio_source_play(source,FALSE);

printf("\nplaying, press any key to quit.\n");
getch();

gaudio_source_stop(source);
gaudio_source_destroy(source);

gaudio_deinit();
Jazk.D
  • 11
  • 1