Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Learning to work with audio in C++ [closed]

Tags:

c++

audio

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.

like image 885
Skilldrick Avatar asked Apr 02 '09 19:04

Skilldrick


People also ask

Why C++ for audio programming?

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.

How to add sound in C?

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.

What is modern CPP?

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.


2 Answers

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.

like image 90
MissT Avatar answered Sep 18 '22 14:09

MissT


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

like image 29
Emile Vrijdags Avatar answered Sep 19 '22 14:09

Emile Vrijdags