In Proceedings of the 2005 International Computer Music Conference, Barcelona, Spain 1 RTMIDI, RTAUDIO, AND A SYNTHESIS TOOLKIT (STK) UPDATE Gary P. Scavone gary@music.mcgill.ca Perry R. Cook prc@cs.princeton.edu Music Technology, Faculty of Music McGill University Departments of Computer Science & Music Princeton University ABSTRACT This paper presents new and ongoing development efforts directed toward open-source, cross-platform C++ “tools” for music and audio programming. RtMidi provides a common application programming interface (API) for re- altime MIDI input and output on Linux, Windows, Mac- intosh, and SGI computer systems. RtAudio provides complementary functionality for realtime audio input and output streaming. The Synthesis ToolKit in C++ (STK) is a set of audio signal processing and algorithmic synthesis classes designed to facilitate rapid development of music synthesis and audio processing software. 1. INTRODUCTION The development of cross-platform computer applications for music and audio has long been limited by the lack of universal programming interfaces to communicate with audio and MIDI hardware. The multitude of APIs in ex- istence offer vastly different levels of control and often present fundamentally different programming paradigms. In several instances, multiple APIs exist for a single op- erating system (OS). RtAudio is a set of C++ classes that provides a uniform, flexible, and easy to use interface for realtime audio input/output across the most common audio APIs [8]. RtMidi, a set of companion classes for realtime MIDI input/output, was more recently released in September 2004. The Synthesis ToolKit in C++ (STK) has been avail- able and in use for nearly ten years [7]. STK provides a flexible set of objects that can be used for rapid prototyp- ing of music and audio algorithms, embedded in a com- puter program to provide audio signal processing func- tionality, or used to teach practical aspects of computer music programming, for example. In this paper, we dis- cuss recent updates that have been made in a continuing effort to serve the STK user community of over 200 de- velopers and thousands of users worldwide. 2. RTAUDIO The RtAudio C++ class was originally developed to pro- vide realtime audio input/output support for the Synthe- sis ToolKit. A completely redesigned, standalone version of the class was released by the first author in 2002 [8]. This version included support for Linux (OSS and ALSA), Windows (DirectSound), and Irix platforms. Since then, support has expanded to also include the CoreAudio (Mac- intosh OS X), ASIO (Windows), and Jack (Linux) APIs. 2.1. The RtAudio API Given space limitations, it is not possible to provide a complete programming example of RtAudio here. How- ever, an extensive tutorial and class documentation are available from the RtAudio website 1 . The following pseudo-code outlines a typical RtAudio “session”. // Write a callback function to process // audio data to/from buffer. int callback(char * buffer, int frames, void * userData) {} // Open an RtAudio stream RtAudio audio(oDevice, oChannels, iDevice, iChannels, dataFormat, sampleRate, &bufferFrames, nBuffers); // Set callback and start the stream audio.setStreamCallback(&callback, NULL); audio.startStream(); // Running ... until done // Stop and close the stream audio.stopStream(); audio.closeStream(); 2.2. Simultaneous Multi-API Support Since release 3.0, RtAudio has provided support for com- pilation of multiple simultaneous APIs within a given op- erating system. For example, it is now possible to com- pile simultaneous support for the OSS, ALSA, and Jack APIs in Linux or both the DirectSound and ASIO APIs in Windows. This was accomplished by subclassing each API and redesigning RtAudio to choose an appropriate subclass for instantiation. The user can specify a particu- lar API during object construction or the RtAudio con- troller will automatically search for an available API sup- port in a prioritized order (for example, Jack, ALSA, and 1 http://music.mcgill.ca/˜gary/rtaudio/