I am writing a small program in C++ that receives mic input and does some simple live audio processing. I have been looking around and the only things I have been able to find that work on Linux are PortAudio, QAudioInput, and fmod.
I am trying to stay away from any super low level programming and use a minimal amount of lines.
Which one of these would fit my needs best?
Check out JUCE. Juce will build on many platforms. JUCE does a lot more than just audio, but it was made with audio programmers in mind. Look at he JUCE demo application and then just chop up the source code from the audio demo to suit your needs. The API documentation is really good also. The abstraction from the low level stuff is good.
Related
I am a reasonably experienced programmer who is pretty inexperienced with C++ and brand new to creating plugins.
Thus far I have looked into http://martinfinke.de/blog/tags/making_audio_plugins.html but it seems incredibly dated, I'm hitting a whole load of compilation issues and don't know where to get the legacy SDKs which would mean I had the exact same set up that the author is using.
I have also looked into JUCE but there isn't a vast amount of resources out there that I can find.
What I am trying to do is create a plugin, VST only for now (will look at compatibility with other vendors later) which simply maps a MIDI input to an audio file which my partner, who is a sound engineer, has already created. We have enough samples for randomising and also various velocities
I highly recommend just working your way through the JUCE Tutorials or watching through the JUCE videos by The Audio Programmer on Youtube to get you started on JUCE. Whilst the first tutorials do not produce audio plugins, the components used within them are crucial 'building blocks' to creating a full plugin.
When you're happy with creating basic GUI elements and how audio can be played/ synthesised within both the Audio App and Audio Plug-In projects, I recommend you try building the smallest part of your plugin you can and, getting that working and slowly building upon it. I suggest starting with how to load an audio file into the buffer (take a look at the looping audio tutorial) as once that is complete it is just a case of using the tutorials again to create and handle the MIDI data.
For my school project I would like to know if anyone can help me in finding a way of outputting sound in real time through the speakers of my PC.
This has to be donevia my sound Card while at the same time playing with parameters of the signal being played such as phase, amplitude, waveform etc?
I would prefere a library under the C++ language if possible and on the Windows plateform for practical reasons. Ofcourse Linux is also possible.
Most importantly I would also like to send a different waveforms through each speaker as to create stationary waves as can be seen through this experiment:
www.youtube.com/watch?v=T56waxJ7bB8
One interesting possibility is to use JACK. It works under Linux, Windows and OSX and provides low-latency access to audio output. It also allows for the output to be arbitrarily routed to some other program.
JACK's programming model is very simple - the only kind of data supported is a single channel of 32-bit floats, so rather than fiddling with manually interleaving data channels, you can instead provide separate instances of left and right audio sine wave generators and route each to the appropriate output channel.
Also, as a minor point of interest, JACK2 is written in C++ (although the external API is still C). I'd recommend starting with the JACK wiki and perhaps modifying one of the simple example clients to do what you're attempting.
There are a few APIs to do this.
For Windows XP and up use DirectSound
For Windows Vista/7/8 and up use WASAPI
There are some cross-platform APIs like OpenAL and SDL.
Search the web for some examples. Play around with those APIs and examples for a while and see how you do.
I need some advice on this idea that I've had for an UNI project.
I was wondering if it's possible to split an audio file into different "streams" from different audio sources.
For example, split the audio file into: engine noise, train noise, voices, different sounds that are not there all the time, etc.
I wouldn't necessarily need to do this from a programming language(although it would be ideal) but manually as well, by using some sound processing software like Sound Forge. I need to know if this is possible first, though. I know nothing about sound processing.
After the first stage is complete(separating the sounds) I want to determine if one of the processed sounds exists in another audio recording. The purpose would be sound detection. For (an ideal) example, take the car engine sound and match it against another file and determine that the audio is a recording of a car's engine or not. It doesn't need to be THAT precise, I guess detecting a sound that is not constant, like a honk! would be alright as well.
I will do the programming part, I just need some pointers on what to look for(software, math, etc). As I am no sound expert, this would really be an interesting project, if it's possible.
Thanks.
This problem of splitting sounds based on source is known in research as (Audio) Source Separation or Audio Signal Separation. If there is no more information about the sound sources or how they have been mixed, it is a Blind Source Separation problem. There are hundreds of papers on these topics.
However for the purpose of sound detection, it is not typically necessary to separate sounds at the audio level. Very often one can (and will) do detection on features computed on the mixed signal. Search literature for Acoustic Event Detection and Acoustic Event Classification.
For a introduction to the subject, check out a book like Computational Analysis of Sound Scenes and Events
It's extremely difficult to do automated source separation from a single audio stream. Your brain is uncannily good at this task, and it also benefits from a stereo signal.
For instance. voice is full of signals that aren't there all the time. Car noise has components that are quite stationary, but gear changes are outliers.
Unfortunately, there are no simple answers.
Correlate reference signals against the audio stream. Correlation can be done efficiently using FFTs. The output of the correlation calculation can be thresholded and 'debounced' in time for signal identification.
My commercial embedded C++ Linux project requires playing wav files and tones at individual volume levels concurrently. A few examples of the sounds:
• “Click” sounds each time user presses screen played at a user-specified volume
• Warning sounds played at max-volume
• Warning tones requested by other applications at app-specified volume level (0-100%)
• Future support for MP3 player and/or video playback (with sound) at user-specified volume. All other sounds should continue while song/video is playing.
We're using Qt as our UI framework which has QtMultimedia and Phonon support. However, I heard the former has spotty sound support on Linux and the latter is an older version and may be deprecated in an upcoming Qt release.
I've done some research and here are a few APIs I've come across:
KDE Phonon
SFML
PortAudio
SDL_Mixer
OpenAL Soft
FMOD (though I'd prefer to avoid license fees)
ALSA (perhaps a bit too low-level...)
Other considerations:
Cross-platform isn't required but preferred. We'd like to limit dependencies as much as possible. There is no need for advanced features like 3D audio or special effects in the foreseeable future. My team doesn't have much audio experience so ease-of-use is important.
Are any of these overkill for my application? Which seems like the best fit?
Update:
It turns out we were already dependent on SDL for other reasons so we decided on SDL_Mixer. For other Embedded applications, however, I'd take a long at the PortAudio/libsndfile combo as well due to their minimal dependencies.
libao is simple, cross-platform, Xiphy goodness.
There's documentation too!
Usage is outlined here - simple usage goes like this:
Initialize (ao_initialize())
Call ao_open_live() or ao_open_file()
Play sound using ao_play()
Close device/file using ao_close() and then ao_shutdown() to clean up.
Go for PortAudio. For just plain audio without unneeded overhead such as complex streaming pipelines, or 3D, it is the best lib out there. In addition you have really nice cross-platform support. It is used by several professional audio programs and has really high quality.
i have used SDL_Mixer time and time again, lovely library, it should serve well for your needs, the license is flexible and its heavily documented. i have also experimented with SFML, while more modern and fairly documented, i find it a bit bulky and cumbersome to work with even tho both libraries are very similar. imo SDL_Mixer is the best.
however you might also want to check out this one i found a few weeks ago http://www.mpg123.de/, i haven't delved too much into it, but it is very lightweight and again the license is flexible.
There is a sound library called STK that would meet most of your requirements:
https://ccrma.stanford.edu/software/stk/faq.html
Don't forget about:
FFmpeg: is a complete, cross-platform solution to record, convert and stream audio and video.
GStreamer: is a library for constructing graphs of media-handling components. The applications it supports range from simple Ogg/Vorbis playback, audio/video streaming to complex audio (mixing) and video (non-linear editing) processing.
I've been trying to wrap my head around embedded. Since I will be self-taught in this specific niche, I realize it will be harder to get a job in the field, so I'm hoping to add a completed project to my resume to prove to potential employers that I've done it and can do it again for them.
Can someone suggest a project that I can undertake as a single person and actually be able to finish, but at the same time not too simple that it doesn't prove anything? Something reasonable that I can aim for.
If you can substantiate your example with a project you worked on yourself, and mention how many people were involved, and how long it took to finish it, that would also help me gauge the difficulty of projects I see in general and rule out the ones that are probably too big for my capacity. It's very difficult to gauge the amount of work a project needs from my position.
You should take a look at the arduino. To quote their site:
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.
There is a really handy playground listing a bunch of personal projects on the arduino, any one of which might fulfil your need to do some embedded development. You can also trawl around the internet (e.g. instructables) to find many other interesting arduino applications -- I particularly like the one building a fancy control system for an espresso machine, and, of course, there is the mandatory fart detecting chair that tweets its findings.
Being an arduino experimenter myself, I can attest to the simplicity and power of this device -- and the great fun you will have playing with it. If you want to get started quickly, I can recommend buying the starter kit from the very helpful people at oomlout.
Are you looking specifically at embedded software development, or are you interested in circuit board design as well?
If it's just software, then I would suggest getting hold of an ARM development board (Possibly the Philips LPC range - sparkfun have some nice ones) that you can program via a bootloader over usb and start hacking. Get one with a display and an ethernet port and you can build up to making some sort of network attached sensor (temperature, water level, object counter, etc). Start out little (turn on a LED from a button) and work your way up.
If you're also into the electronics side of things, I'd suggest something like an MP3 (or WAV) player and maybe stick to the AVR or PIC 8bit microcontrollers (AVR is used on the Arduino) as these are a little easier to deal with than ARM. Here you could start with a usb powered device that streams wav files from a PC serial port out to a pair of headphones, and build up to a battery powered board, feeding data to an MP3 decoder IC from an SD card.
Some things you may want to learn & demonstrate:
Understands the bounds of working with limited resources, including memory management (dynamic and/or static); resource management (locks, semaphores, mutex); multiple tasks (interrupts); and appropriate data structures
Ability to interface with other devices/ICs over various interconnects (analog & digital IO, serial bus (RS232, I2C, SPI))
Ability to sanely structure a program and segment the various modules without producing 'spaghetti' code
Ability to use source and integrate 3rd party libraries where appropriate (think FAT filesystem, or TCP/IP stack)
Misc Tips:
read and understand the datasheets (yes all of them)
code and test on the desktop where possible, but understand that there are differences and bugs will still creep through (this is where it helps to be using a tool-chain that is common with the desktop - GCC is good, but the tools are generally CLI)
use assert a lot - you can flash the line number of a failed assert using a single LED - this is invaluable
Most of all have fun - it still makes me smile when you first get a new component working (display, motor, sensor). Embedded makes the world go round :)