Reputation: 4452
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.
Upvotes: 10
Views: 18441
Reputation: 11
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();
Upvotes: 0
Reputation: 79
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.
Upvotes: 1
Reputation: 5240
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..
Upvotes: 2
Reputation: 128
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.
Upvotes: 4
Reputation: 11251
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!
Upvotes: 3
Reputation: 2347
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.
Upvotes: 1