My degree was in audio engineering, but I'm fairly new to programming. I'd like to learn how to work with audio in a programming environment, partly so I can learn C++ better through interesting projects.
First off, is C++ the right language for this? Is there any reason I shouldn't be using it? I've heard of Soundfile and some other libraries - what would you recommend?
Finally, does anyone know of any good tutorials in this subject? I've learnt the basics of DSP - I just want to program it!
EDIT: I use Windows. I'd like to play about with real-time stuff, a bit like Max/MSP but with more control.
The good thing with C++ code is that it can be linked with existing C code for the best reuse of an application's legacy code and existing C libraries. Besides, C++ also has many enhancements and features that make it a better option for audio-video app development and independent of object-oriented programming.
Beep() function in C with Examples The Beep function in C is used to make a Beep sound. It generates a tone on the speaker. The function is synchronous, i.e. it waits and doesn't return to its caller function until the sound is finished. It can be very useful during the Debugging process for finding errors.
Modern C++ emphasizes the principle of resource acquisition is initialization (RAII). The idea is simple. Resources (heap memory, file handles, sockets, and so on) should be owned by an object. That object creates, or receives, the newly allocated resource in its constructor, and deletes it in its destructor.
It really depends on what kind of audio work you want to do, If you want to implement audio for a game, C++ is sure the right language. There are many libraries around, OpenAL is great, free and multiplatform. I also used DirectSound and Fmod with great sucess. Check them out, it all depends on your needs.
If you do decide to use C++, then The Synthesis Toolkit is worth noting. I use it for a schoolproject and it is very usable, developed at stanford university, crossplatform (win, mac and linux), free and opensource. An extract from the wikipedia page on it:
Versions of the STK instrument classes have been integrated into ChucK, Csound, Real-Time Cmix, Max/MSP (as part of PeRColate) and SuperCollider
They have a lot of testcode included + on the site are some tutorials to get started with their library. (But you do have to know some C++ of course)
STK has some classed to read/write audio files (and matlab files), realtime audio/midi io, some basic algorithms (usage based on similar functions out of matlab), ...
Another obvious option and probably THE most used environment to learn/test dsp stuff is Matlab (or free octave, but i havent used it before). I sometimes test stuff out in Matlab before implementing it in C++.
EDIT: In the past year I've been using JUCE which is a pretty cool C++ library centered around C++ audio programming, though its more leaning towards something like QT. One of their developers (Timur Doumler) has a nice talk about real time audio with C++ and JUCE on CppCon 2015, definitely worth checking out, even if you don't end up using JUCE: https://youtu.be/boPEO2auJj4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With