Library for reading audio files
Asked Answered
T

6

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.

Tatary answered 16/10, 2012 at 13:34 Comment(4)
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.Falgout
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?Tatary
Maybe libsndfile (mega-nerd.com/libsndfile)? Or SOX (sox.sourceforge.net/Main/HomePage)? Haven't used them myself but they look promising.Confirmation
Old question, but for AAC: FAAC and FAADStereogram
A
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.

Adjudge answered 16/10, 2012 at 13:56 Comment(0)
I
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!

Indecent answered 16/10, 2012 at 13:54 Comment(0)
R
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..

Rajewski answered 16/10, 2012 at 14:2 Comment(0)
F
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.

Frontward answered 16/10, 2012 at 13:46 Comment(1)
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.Blynn
C
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.

Calabro answered 19/10, 2012 at 9:2 Comment(0)
A
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();
Alexis answered 7/11, 2013 at 13:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.