I’ve had great success with PortAudio
They have a couple different modes of operation. One where you just block IO and send audio direct to the device as needed. And another mode where you write a callback that runs in its own thread and constantly returns audio samples.
It’s a great library and fully cross platform.
FMOD is probably hands down the most used professional audio library and sometime back they made a free version. Of course, there is a catch, 100K or less in revenue. Then again, if you have a 0$ budget, 100K shouldn't be too much of a hangup.
There are also open source options like PortAudio. Or of course you can work low level in OpenAL.
None of these are technically C++, they are all C libraries.
Yeah, if it's an audio interface, the standard audio APIs for the various operating systems should be able to handle it. Take a look at PortAudio if you want a cross-platform solution.
Typically, an application uses a library to access devices. A library can then handle the differences between operating system interfaces to device drivers which interface in various ways to the hardware.
One way to increase your knowledge is to pick something open source, such as PortAudio and write a simple app to use it. Then if the library is open, you can see how they implement the various functions.
Would you like to know anything specific?
I think getting started is pretty easy, but there's not so much information about this. One of the first thing I read when starting was someone saying that developing digital pedal "is a lonely task" xD, because there's not so much people doing that; I actually quoting this sub, saying that most people are into analog here. And I think it was actually pretty accurate. And I'm actually "cheating" a bit by using a Pi, because trying to do it with ESPs for instance would add some more problems.
But when I had the idea, I search a way to get the audio first, and quickly found this lib: http://www.portaudio.com
I'm only using it to deal with the audio input and output. And the cool thing is, in the code example, there's actual a fuzz; so in a few hours, I was able to get sound from my guitar to my RPi, fuzz it, and returned it. Why was a good motivation!
I suggest trying to look at this lib, and compile it on your PC, and see how it goes. And ask if you need anything!
Have a look at PortAudio, a library. I’m using it on an RPi4. http://www.portaudio.com/. There’s a one-file C++ example included that plays a sine tone. If you’d prefer Python, pyaudio wraps the library for Python.
lol, not sure if libusb-dev is neccesary, installed it, but seems linrad didn't recognize it...
checking for libusb-dev... no
works anyway... ;P
and yeah, the help is really good, they not only tell you package x is missing, they give you detailed instructions on how to get them on common operating systems. and yeah, jack seems to be available for mac os, so installing portaudio might be a good idea if you want sound.
Portaudio may have to be installed from source code. The purpose of installing Portaudio is to be able to use Jack. The versions included in the distributions do not always support Jack Make sure to remove any old non-working version first. Install Portaudio from source like this: (Note that you may have to change the date 20140130 to something else.) cd /usr/src wget http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz tar xvfz pa_stable_v190600_20161030.tgz cd portaudio ./configure make make install Go back to the linrad directory and run ./configure again.
To install the distribution version use one of these commands Old Fedora: yum install portaudio-devel Fedora 22 and later: dnf install portaudio-devel Debian, Ubuntu: apt-get install libportaudio-dev Debian 8: apt-get install libportaudio2 Debian 8: ln -s /usr/lib/x86_64-linux-gnu/libportaudio.so.2.0.0 /usr/lib/x86_64-linux-gnu/libportaudio.so SuSE: zypper install portaudio-devel Gentoo: emerge portaudio Sabayon: equo install media-libs/portaudio Mageia: urpmi libportaudio-devel PCLinuxOS: apt-get install lib64portaudio2-devel Then run ./configure again.
I would recommend libsoundio for cross-platform audio. It's new, clean and very nice library. If you want something more established, there is portaudio. You can also use SDL2 to playback audio. Or libao, if you want something simpler.
All these only handle the playback. For decoding you will need something like sndfile.
Don't need Coreaudio
Linux can already support Portaudio, open source, cross-platform audio library
Been using it in JACK for a few years with icecast/shoutcast streaming application BUTT
Know a few Windows users that confirm this application works no problem for them
but if i could get the use of any Mac hardware I would be installing JACK on there to try a netjack connection to Linux
Typically, there's some mixer code. Behind the scenes what happens is something like this, roughly.
The soundcard has a circular buffer from which it's always playing. Periodically, it interrupts the OS, asking for more data to keep the buffer from becoming empty. Applications can register with the OS to help provide this data. It might provide data say, in 1Kbyte or 4Kbyte chunks at a time. An application that wants to provide this data may have many internal buffers to represent concurrently playing sounds. Each of these buffers will have a kind of "cursor" indicating where in the buffer it currently is. When the interrupt (callback) occurs asking for more data to be played, it will rip through all of its internal buffers starting at each buffers cursor, and add up all the values in each currently playing buffer to construct a new summed buffer which it then provides for the sound card.
If you use something like portaudio, this mixing code is the kind of code you'll have to write. Most people use some higher level sound library that does this mixing for them. I don't know what's typically done in javascript.
pyaudio is one library used to "handle" audio files. It's a wrapper around portaudio. There is a general overview of handling audio in python.
While it's possible to do things with audio data using just basic python, I think you'll find its a ton of work. You will learn a lot!
Ok, seems like this is a issue with ubuntu as a whole, not only me. You will need to build pyaudio yourself, it's not hard.
Download this: http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz
Unpack it to any folder
cd yourself into the folder you unpacked it
./configure&&make
sudo make install
sudo pip install pyaudio --upgrade
Now get back to the cloned repository and do the python3 /install.py , you might want to do it with sudo
For the C language there are a few open source audio platforms - Jack (http://www.jackaudio.org) and PortAudio (http://www.portaudio.com) for example. Java has audio support, and there's also the Web Audio API which allows you to process audio pretty efficiently using javascript and is pretty well supported on modern browsers. Processing is a nice platform that works on everything and provides a really straightforward method to get straight into audio processing - I'd probably recommend this over anything else if you're just getting your feet wet. The added benefit is that the Arduino hardware platform is based on it, so you'd have some crossover there.
I think the litmus test for these things is that you can get from zero to being able to process audio with reasonable latency with minimal effort. Find the most basic demo that can pass input to output with minimal effects, find where it modifies the audio, and start adding your own stuff.
The simplest solution is to have some other program do the work, like <code>afplay(1)</code>. You could spawn an instance of such a program from your program using system()
.
If you really must do the playing yourself, you'll need to use OS-specific APIs. In the case of OS X, that's the Core Audio framework. Like all the other OS X frameworks, is an Objective C API, so you'd need to learn that before being able to do much with it. You could easily waste months trying to do this.
You could also use a cross-platform portability library, like PortAudio, or possibly SDL or SFML.
You'd need to implement a sequencer, sort of like Cubase or Ableton Live (without the interface, obviously). One track, the "base" track, plays the background music, while 4 or 5 extra tracks are ready to play sounds when the player hits on a button. All the 4 or 5 extra "player" tracks have a blueprint of when the note/sound should play and which note/sound should play. You can calculate the time-distance between the player notes and the blueprint notes to reward the player with adequate points.
edit: perhaps something like PortAudio might be useful for such purposes.