Skip to content

Running an Audio Sketch on the Desktop

pschatzmann edited this page Feb 12, 2023 · 25 revisions

Sometimes it is just to tedious to deploy and test a sketch on a Microcontroller - specially when you don't have all the wires of your hardware connected or expect to run thru many validation cycles.

This project can also be used to output the sound on Linux, Windows and OS/X.

You just need to provide an Arduino Sketch together with this CMakeLists.txt file. Just replace the example generator.ino with your sketch file in the add_executable line.

In your sketch you can use the PortAudioStream class which uses PortAudio to input or output audio.

Alternatively you can also use the StdioStream class to input or output data (in Linux or OS/X) togheter with pipes: e.g. ./generator | aplay -f cd is playing the output of the generator with the help of the aplay command.

The CMakeLists.txt file automatically downloads all dependencies (including the arduino-audio-tools project).

You can build the executable with:

mkdir build
cd build
cmake ..
make

A full example can be found in the examples-desktop directory.

If you intend to debug, please use cmake -DCMAKE_BUILD_TYPE=Debug .. instead.

Clone this wiki locally