diff --git a/INSTALL b/INSTALL
index 00d0ea1..c290a1a 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,6 @@
The Synthesis ToolKit in C++ (STK)
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
The Synthesis ToolKit in C++ can be used in a variety of ways, depending on your particular needs. Some people just choose the classes they need for a particular project and copy those to their project directory. Others like to compile and link to a library of object files. STK was not designed with one particular style of use in mind.
@@ -19,10 +19,11 @@ Several options can be passed to configure, including:
--disable-realtime = only compile generic non-realtime classes
--enable-debug = enable various debug output
--with-alsa = choose native ALSA API support (default, linux only)
- --with-jack = choose native JACK server API support (linux only)
--with-oss = choose native OSS API support (linux only)
+ --with-jack = choose native JACK server API support (linux and macintosh OS-X)
+ --with-core = choose OS-X Core Audio API (macintosh OS-X only)
-It is now possible to specify more than one Linux audio API. Note however that the ALSA library is required in order to compile the RtMidi class, even if the "--with-oss" option is provided (only the OSS audio API will be used, not the OSS MIDI API). Typing "./configure --help" will display all the available options. In addition, it is possible to specify the RAWWAVES and INCLUDE paths to configure as (ex. to set to /home/gary/rawwaves and /home/gary/include):
+It is now possible to specify more than one audio API where supported. Note however that the ALSA library is required in order to compile the RtMidi class, even if the "--with-oss" option is provided (only the OSS audio API will be used, not the OSS MIDI API). Typing "./configure --help" will display all the available options. In addition, it is possible to specify the RAWWAVES and INCLUDE paths to configure as (ex. to set to /home/gary/rawwaves and /home/gary/include):
./configure RAWWAVE_PATH='$(HOME)/rawwaves/'
./configure INCLUDE_PATH='$(HOME)/include/'
diff --git a/README b/README
index 8a9fe9c..8e23fb8 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
The Synthesis ToolKit in C++ (STK)
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
This distribution of the Synthesis ToolKit in C++ (STK) contains the following:
@@ -17,61 +17,180 @@ For compiling and installing STK, see the INSTALL file in this directory.
OVERVIEW:
-The Synthesis ToolKit in C++ (STK) is a set of open source audio signal processing and algorithmic synthesis classes written in the C++ programming language. STK was designed to facilitate rapid development of music synthesis and audio processing software, with an emphasis on cross-platform functionality, realtime control, ease of use, and educational example code. The Synthesis ToolKit is extremely portable (it's mostly platform-independent C and C++ code), and it's completely user-extensible (all source included, no unusual libraries, and no hidden drivers). We like to think that this increases the chances that our programs will still work in another 5-10 years. In fact, the ToolKit has been working continuously for nearly 10 years now. STK currently runs with "realtime" support (audio and MIDI) on SGI (Irix), Linux, Macintosh OS X, and Windows computer platforms. Generic, non-realtime support has been tested under NeXTStep, Sun, and other platforms and should work with any standard C++ compiler.
+The Synthesis ToolKit in C++ (STK) is a set of open source audio
+signal processing and algorithmic synthesis classes written in the C++
+programming language. STK was designed to facilitate rapid
+development of music synthesis and audio processing software, with an
+emphasis on cross-platform functionality, realtime control, ease of
+use, and educational example code. The Synthesis ToolKit is extremely
+portable (it's mostly platform-independent C and C++ code), and it's
+completely user-extensible (all source included, no unusual libraries,
+and no hidden drivers). We like to think that this increases the
+chances that our programs will still work in another 5-10 years. In
+fact, the ToolKit has been working continuously for nearly 10 years
+now. STK currently runs with "realtime" support (audio and MIDI) on
+Linux, Macintosh OS X, and Windows computer platforms. Generic,
+non-realtime support has been tested under NeXTStep, Sun, and other
+platforms and should work with any standard C++ compiler.
-The Synthesis ToolKit is free for non-commercial use. The only parts of the Synthesis ToolKit that are platform-dependent concern real-time audio and MIDI input and output, and that is taken care of with a few special classes. The interface for MIDI input and the simple Tcl/Tk graphical user interfaces (GUIs) provided is the same, so it's easy to experiment in real time using either the GUIs or MIDI. The Synthesis ToolKit can generate simultaneous SND (AU), WAV, AIFF, and MAT-file output soundfile formats (as well as realtime sound output), so you can view your results using one of a large variety of sound/signal analysis tools already available (e.g. Snd, Cool Edit, Matlab).
+The Synthesis ToolKit is free for non-commercial use. The only parts
+of the Synthesis ToolKit that are platform-dependent concern real-time
+audio and MIDI input and output, and that is taken care of with a few
+special classes. The interface for MIDI input and the simple Tcl/Tk
+graphical user interfaces (GUIs) provided is the same, so it's easy to
+experiment in real time using either the GUIs or MIDI. The Synthesis
+ToolKit can generate simultaneous SND (AU), WAV, AIFF, and MAT-file
+output soundfile formats (as well as realtime sound output), so you
+can view your results using one of a large variety of sound/signal
+analysis tools already available (e.g. Snd, Cool Edit, Matlab).
-The Synthesis Toolkit is not one particular program. Rather, it is a set of C++ classes that you can use to create your own programs. A few example applications are provided to demonstrate some of the ways to use the classes. If you have specific needs, you will probably have to either modify the example programs or write a new program altogether. Further, the example programs don't have a fancy GUI wrapper. If you feel the need to have a "drag and drop" graphical patching GUI, you probably don't want to use the ToolKit. Spending hundreds of hours making platform-dependent graphics code would go against one of the fundamental design goals of the ToolKit - platform independence.
+The Synthesis Toolkit is not one particular program. Rather, it is a
+set of C++ classes that you can use to create your own programs. A
+few example applications are provided to demonstrate some of the ways
+to use the classes. If you have specific needs, you will probably
+have to either modify the example programs or write a new program
+altogether. Further, the example programs don't have a fancy GUI
+wrapper. If you feel the need to have a "drag and drop" graphical
+patching GUI, you probably don't want to use the ToolKit. Spending
+hundreds of hours making platform-dependent graphics code would go
+against one of the fundamental design goals of the ToolKit - platform
+independence.
-For those instances where a simple GUI with sliders and buttons is helpful, we use Tcl/Tk (http://dev.scriptics.com) which is freely distributed for all the supported ToolKit platforms. A number of Tcl/Tk GUI scripts are distributed with the ToolKit release. For control, the Synthesis Toolkit uses raw MIDI (on supported platforms), and SKINI (Synthesis ToolKit Instrument Network Interface, a MIDI-like text message synthesis control format).
+For those instances where a simple GUI with sliders and buttons is
+helpful, we use Tcl/Tk (http://dev.scriptics.com) which is freely
+distributed for all the supported ToolKit platforms. A number of
+Tcl/Tk GUI scripts are distributed with the ToolKit release. For
+control, the Synthesis Toolkit uses raw MIDI (on supported platforms),
+and SKINI (Synthesis ToolKit Instrument Network Interface, a MIDI-like
+text message synthesis control format).
SYSTEM REQUIREMENTS:
-See the individual README's (eg. README-linux) in the /doc directory for platform specific information and system requirements. In general, you will use the configure script to create Makefiles on unix platforms or the VC++ workspace files to compile the example programs. To use the Tcl/Tk GUIs, you will need Tcl/Tk version 8.0 or higher.
+See the individual README's (eg. README-linux) in the /doc directory
+for platform specific information and system requirements. In
+general, you will use the configure script to create Makefiles on unix
+platforms or the VC++ workspace files to compile the example programs.
+To use the Tcl/Tk GUIs, you will need Tcl/Tk version 8.0 or higher.
WHAT'S NEW (AND NOT SO NEW):
-Despite being available in one form or another since 1996, we still consider STK to be alpha software. We attempt to maintain backward compatability but changes are sometimes made in an effort to improve the overall design or performance of the software. Please read the Release Notes to see what has changed since the last release.
+Despite being available in one form or another since 1996, we still
+consider STK to be alpha software. We attempt to maintain backward
+compatability but changes are sometimes made in an effort to improve
+the overall design or performance of the software. Please read the
+Release Notes to see what has changed since the last release.
-A new StkFrames class has been created to facilitate the handling and passing of multichannel, vectorized audio data. All STK classes have been updated to include tick() functions that accept StkFrames arguments.
+A new StkFrames class has been created to facilitate the handling and
+passing of multichannel, vectorized audio data. All STK classes have
+been updated to include tick() functions that accept StkFrames
+arguments.
-The control message handling scheme has been simplified greatly through the use of the Messager class. It is now possible to have access to simultaneous piped, socketed, and/or MIDI input control messages. In most cases, this should eliminate the use of the Md2Skini program.
+The control message handling scheme has been simplified greatly
+through the use of the Messager class. It is now possible to have
+access to simultaneous piped, socketed, and/or MIDI input control
+messages. In most cases, this should eliminate the use of the
+Md2Skini program.
-Realtime audio input capabilities were added to STK with release 3.0, though the behavior of such is very hardware dependent. Under Linux, Macintosh OS-X, and Irix, audio input and output are possible with very low latency. Using the Windoze DirectSound API, minimum dependable output sound latency seems to be around 20 milliseconds or so, while input sound latency is on the order of a hundred milliseconds or more!
+Realtime audio input capabilities were added to STK with release 3.0,
+though the behavior of such is very hardware dependent. Under Linux,
+Macintosh OS-X, and Irix, audio input and output are possible with
+very low latency. Using the Windoze DirectSound API, minimum
+dependable output sound latency seems to be around 20 milliseconds or
+so, while input sound latency is on the order of a hundred
+milliseconds or more!
-As mentioned above, it is possible to record the audio ouput of an STK program to .snd, .wav, .raw, .aif, and .mat (Matlab MAT-file) output file types. Though somewhat obsolete, the program Md2Skini can be used to write SKINI scorefiles from realtime MIDI input. Finally, STK should compile with non-realtime functionality on any platform with a generic C++ compiler.
+As mentioned above, it is possible to record the audio ouput of an STK
+program to .snd, .wav, .raw, .aif, and .mat (Matlab MAT-file) output
+file types. Though somewhat obsolete, the program Md2Skini can be
+used to write SKINI scorefiles from realtime MIDI input. Finally, STK
+should compile with non-realtime functionality on any platform with a
+generic C++ compiler.
-For those who wish to make a library from the core STK classes, the configure script generates a Makefile in the src directory that will accomplish that (Linux, SGI, and Macintosh OS X only).
+For those who wish to make a library from the core STK classes, the
+configure script generates a Makefile in the src directory that will
+accomplish that (Linux, SGI, and Macintosh OS X only).
DISCLAIMER:
-You probably already guessed this, but just to be sure, we don't guarantee anything works. :-) It's free ... what do you expect? If you find a bug, please let us know and we'll try to correct it. You can also make suggestions, but again, no guarantees. Send email to the mail list.
+You probably already guessed this, but just to be sure, we don't
+guarantee anything works. :-) It's free ... what do you expect? If
+you find a bug, please let us know and we'll try to correct it. You
+can also make suggestions, but again, no guarantees. Send email to
+the mail list.
LEGAL AND ETHICAL:
-This software was designed and created to be made publicly available for free, primarily for academic purposes, so if you use it, pass it on with this documentation, and for free.
+This software was designed and created to be made publicly available
+for free, primarily for academic purposes, so if you use it, pass it
+on with this documentation, and for free.
-If you make a million dollars with it, give us some. If you make compositions with it, put us in the program notes.
+If you make a million dollars with it, it would be nice if you would
+share. If you make compositions with it, put us in the program notes.
-Some of the concepts are covered by various patents, some known to us and likely others which are unknown. Many of the ones known to us are administered by the Stanford Office of Technology and Licensing.
+Some of the concepts are covered by various patents, some known to us
+and likely others which are unknown. Many of the ones known to us are
+administered by the Stanford Office of Technology and Licensing.
-The good news is that large hunks of the techniques used here are public domain. To avoid subtle legal issues, we'll not state what's freely useable here, but we'll try to note within the various classes where certain things are likely to be protected by patents.
+The good news is that large hunks of the techniques used here are
+public domain. To avoid subtle legal issues, we'll not state what's
+freely useable here, but we'll try to note within the various classes
+where certain things are likely to be protected by patents.
+
+LICENSE:
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+Any person wishing to distribute modifications to the Software is
+asked to send the modifications to the original developer so that they
+can be incorporated into the canonical version. This is, however, not
+a binding provision of this license.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FURTHER READING:
-For complete documentation on this ToolKit, the classes, etc., see the doc directory of the distribution or surf to http://ccrma.stanford.edu/software/stk/. Also check the platform specific README's for specific system requirements.
+For complete documentation on this ToolKit, the classes, etc., see the
+doc directory of the distribution or surf to
+http://ccrma.stanford.edu/software/stk/. Also check the platform
+specific README's for specific system requirements.
PERRY'S NOTES FROM THE ORIGINAL DISTRIBUTION:
-This whole world was created with no particular hardware in mind. These examples are intended to be tutorial in nature, as a platform for the continuation of my research, and as a possible starting point for a software synthesis system. The basic motivation was to create the necessary unit generators to do the synthesis, processing, and control that I want to do and teach about. Little thought for optimization was given and therefore improvements, especially speed enhancements, should be possible with these classes. It was written with some basic concepts in mind about how to let compilers optimize.
+This whole world was created with no particular hardware in mind.
+These examples are intended to be tutorial in nature, as a platform
+for the continuation of my research, and as a possible starting point
+for a software synthesis system. The basic motivation was to create
+the necessary unit generators to do the synthesis, processing, and
+control that I want to do and teach about. Little thought for
+optimization was given and therefore improvements, especially speed
+enhancements, should be possible with these classes. It was written
+with some basic concepts in mind about how to let compilers optimize.
-Your question at this point might be, "But Perry, with CMix, CMusic, CSound, CShells, CMonkeys, etc. already cluttering the landscape, why a new set of stupid C functions for music synthesis and processing?" The answers lie below.
+Your question at this point might be, "But Perry, with CMix, CMusic,
+CSound, CShells, CMonkeys, etc. already cluttering the landscape, why
+a new set of stupid C functions for music synthesis and processing?"
+The answers lie below.
1) I needed to port many of the things I've done into something which is generic enough to port further to different machines.
diff --git a/STK_TODO.txt b/STK_TODO.txt
new file mode 100644
index 0000000..9bcc5e0
--- /dev/null
+++ b/STK_TODO.txt
@@ -0,0 +1,25 @@
+Ongoing STK "to do" list:
+
+- OSC server/client classes
+
+- move various error checks, especially in tick() functions, into __DEBUG__ blocks
+
+- more information reported in __DEBUG__ blocks
+
+- add funcionality for sample rate in MAT-file support
+
+- develop a good solution for multi-channel support in Instrumnt class (and others)
+
+- add WAVEFORMATEXTENSIBLE support to WvIn/WvOut?
+
+- port Blotar and Ublotar classes from PeRColate
+
+- consider further sample rate change updates in classes?
+
+- more documentation
+
+
+To see differences:
+-------------------
+
+diff -B -C2 -P -u original_src_dir new_src_dir > difffile.txt
diff --git a/configure.ac b/configure.ac
index f3c9e4e..5c35b0f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
# Process this file with autoconf to produce a configure script.
-AC_INIT(STK, 4.2.1, gary@music.mcgill.ca, stk)
+AC_INIT(STK, 4.3, gary@music.mcgill.ca, stk)
AC_CONFIG_SRCDIR(src/Stk.cpp)
AC_CONFIG_FILES(src/Makefile projects/demo/Makefile projects/effects/Makefile projects/ragamatic/Makefile projects/examples/Makefile projects/examples/libMakefile)
@@ -69,12 +69,12 @@ if test $realtime = yes; then
audio_apis="-D__LINUX_ALSASEQ__"
# Look for Jack flag
- AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_JACK__] ) AC_MSG_RESULT(using JACK)] , )
- if [test $sound_api = -D__LINUX_JACK__;] then
+ AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (linux only)], [AC_SUBST( sound_api, [-D__UNIX_JACK__] ) AC_MSG_RESULT(using JACK)] , )
+ if [test $sound_api = -D__UNIX_JACK__;] then
TEMP_LIBS=$LIBS
AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
LIBS="`pkg-config --cflags --libs jack` $TEMP_LIBS -lasound"
- audio_apis="-D__LINUX_JACK__ $audio_apis"
+ audio_apis="-D__UNIX_JACK__ $audio_apis"
fi
# Look for Alsa flag
@@ -96,19 +96,33 @@ if test $realtime = yes; then
fi
;;
- *-sgi*)
- AC_SUBST( audio_apis, ["-D__IRIX_AL__ -D__IRIX_MD__ -LANG:std -w"] )
- AC_MSG_RESULT(using IRIX AL)
- AC_CHECK_LIB(audio, alOpenPort, , AC_MSG_ERROR(IRIX audio support requires the audio library!) )
- AC_CHECK_LIB(md, mdOpenInPort, , AC_MSG_ERROR(IRIX MIDI support requires the md library!) )
- ;;
-
*-apple*)
- # Check for CoreAudio and CoreMIDI framework
- AC_CHECK_HEADERS(CoreAudio/CoreAudio.h CoreMIDI/CoreMIDI.h CoreServices/CoreServices.h,
- [AC_SUBST( audio_apis, [-D__MACOSX_CORE__] )],
- [AC_MSG_ERROR(CoreAudio and/or CoreMIDI header files not found!)] )
- AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreMIDI -framework CoreFoundation"] )
+ AC_SUBST( sound_api, [_NO_API_] )
+
+ # Look for JACK flag
+ AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (unix only)], [AC_SUBST( sound_api, [-D__UNIX_JACK__] ) AC_MSG_RESULT(using JACK)], )
+ if [test $sound_api = -D__UNIX_JACK__;] then
+ AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
+ audio_apis="-D__UNIX_JACK__"
+ fi
+
+ # Look for Core flag
+ AC_ARG_WITH(core, [ --with-core = choose CoreAudio API support (mac only)], [AC_SUBST( sound_api, [-D__MACOSX_CORE__] ) AC_MSG_RESULT(using CoreAudio)], )
+ if test $sound_api = -D__MACOSX_CORE__; then
+ AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
+ AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation -framework CoreMidi"] )
+ audio_apis="-D__MACOSX_CORE__ $audio_apis"
+ fi
+
+ # If no audio api flags specified, use CoreAudio
+ if [test $sound_api = _NO_API_;] then
+ AC_SUBST( sound_api, [-D__MACOSX_CORE__] )
+ AC_MSG_RESULT(using CoreAudio)
+ AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
+ [AC_SUBST( audio_apis, [-D__MACOSX_CORE__] )],
+ [AC_MSG_ERROR(CoreAudio header files not found!)] )
+ AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation -framework CoreMidi"] )
+ fi
;;
*)
diff --git a/doc/README-Linux.txt b/doc/README-Linux.txt
index 99fddaf..89da290 100644
--- a/doc/README-Linux.txt
+++ b/doc/README-Linux.txt
@@ -1,12 +1,10 @@
The Synthesis ToolKit in C++ (STK)
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
Please read the file README and INSTALL for more general STK information.
-Realtime audio support for Linux currently includes the Advanced Linux Sound Architecture (ALSA), the JACK low-latency audio server, and/or Open Sound System (OSS) APIs. One or more APIs are selected during compilation using the __LINUX_ALSA__, __LINUX_JACK__, and/or __LINUX_OSS__ definitions. Because the ALSA library is now integrated into the standard Linux kernel, it is the default audio/MIDI API with STK versions 4.2 and higher. The __LINUX_ALSASEQ__ definition is required to compile RtMidi with ALSA sequencer support. Native OSS MIDI support no longer exists in RtMidi. If the __LINUX_OSS__ preprocessor definition is specified, only OSS audio support will be compiled and RtMidi will still be compiled using the ALSA API. For this reason, STK now requires the asound library for realtime support. Realtime programs must also link with the pthread library. The OSS audio API can be selected by passing the "--with-oss" option to configure.
-
-The free version of OSS generally works as well (and in some cases better than the commercial OSS version ... such as with my Maestro 2e chipset). In general, the ALSA drivers also seem to perform well. You can read more about ALSA at http://www.alsa-project.org/. ALSA is open source and holds great promise for audio under Linux.
+Realtime audio support for Linux currently includes the Advanced Linux Sound Architecture (ALSA), the JACK low-latency audio server, and/or Open Sound System (OSS version 4.0 and higher only) APIs. One or more APIs are selected during compilation using the __LINUX_ALSA__, __UNIX_JACK__, and/or __LINUX_OSS__ definitions. Because the ALSA library is now integrated into the standard Linux kernel, it is the default audio/MIDI API with STK versions 4.2 and higher. The __LINUX_ALSASEQ__ definition is required to compile RtMidi with ALSA sequencer support. Native OSS MIDI support no longer exists in RtMidi. If the __LINUX_OSS__ preprocessor definition is specified, only OSS audio support will be compiled and RtMidi will still be compiled using the ALSA API. For this reason, STK now requires the asound library for realtime support. Realtime programs must also link with the pthread library. The OSS audio API can be selected by passing the "--with-oss" option to configure.
STK should compile without much trouble under Linux. Since all Linux distributions typically include the GNU makefile utilities, you should be able to use the default Makefile. Typing "make" will initiate the compilation process.
diff --git a/doc/README-MacOSX.txt b/doc/README-MacOSX.txt
index 1830b6d..e07de5e 100644
--- a/doc/README-MacOSX.txt
+++ b/doc/README-MacOSX.txt
@@ -1,10 +1,10 @@
The Synthesis ToolKit in C++ (STK)
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
Please read the file README and INSTALL for more general STK information.
-Realtime support for Macintosh OS X uses the CoreAudio HAL API and is specified during compilation using the __MACOSX_CORE__ preprocessor definition.
+The default realtime support for Macintosh OS X uses the CoreAudio HAL API and is specified during compilation using the __MACOSX_CORE__ preprocessor definition. There is also support for the JACK low-latency audio server using the __UNIX_JACK__ preprocessor definition.
It is necessary to install the OS X developer kit in order to compile STK. STK was successfully tested on OS X versions 10.4.
diff --git a/doc/README-NeXT.txt b/doc/README-NeXT.txt
index e9d59b1..16c651e 100644
--- a/doc/README-NeXT.txt
+++ b/doc/README-NeXT.txt
@@ -1,6 +1,6 @@
The Synthesis ToolKit in C++ (STK)
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
Please read the file README and INSTALL for more general STK information.
diff --git a/doc/README-SGI.txt b/doc/README-SGI.txt
index febe80f..7ec2ad7 100644
--- a/doc/README-SGI.txt
+++ b/doc/README-SGI.txt
@@ -1,12 +1,12 @@
The Synthesis ToolKit in C++ (STK)
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
Please read the file README and INSTALL for more general STK information.
The project Makefiles are created by configure. If you have trouble running "make", try invoking "gmake" (for GNU make). If that doesn't work, try to download the GNU Makefile utilities from the Internet.
-Another issue that has crept up with this release is proper compiler support for C++ error handling. If you experience problems, you probably don't have a recent version of the C++ compiler. Otherwise, STK should compile and run on SGI platforms without any problems. Release 4.0 of STK is confirmed to compile (with various warnings) using CC version 7.30.
+With STK version 4.3, realtime support for IRIX has been discontinued due to the inability to test it. If you need realtime support on an SGI, go back to version 4.2.1. Release 4.0 of STK is confirmed to compile (with various warnings) using CC version 7.30.
The __IRIX_AL__ and __IRIX_MD__ preprocessor definitions are required for realtime audio and MIDI support.
diff --git a/doc/README-Win.txt b/doc/README-Win.txt
index 5d78d14..4f1e03e 100644
--- a/doc/README-Win.txt
+++ b/doc/README-Win.txt
@@ -1,13 +1,13 @@
The Synthesis ToolKit in C++ (STK)
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
Please read the file README for more general STK information.
DirectX and WindowsNT Issues:
-----------------------------
-STK is currently distributed with Visual C++ 6.0 project and workspace files. It has been tested using both Visual C++ 6.0 and Visual C++ .NET.
+STK is currently distributed with Visual C++ .NET project and workspace files. It no longer compiles with Visual C++ 6.0. I gave up attempting to fix all the problems created by such a bad compiler. This version of STK has been tested using Visual C++ .NET.
IMPORTANT VC++ NOTE: When compiling "release" versions of STK programs, link to the release multithreaded library. When compiling "debug" versions, link to the debug multithreaded library. Compiler errors will result otherwise. Also, the Microsoft folk are up to their old habits of trying to change standards. The .NET compiler will complain about cerr for some reason.
@@ -17,7 +17,7 @@ When using the DirectSound API for audio input, latency is typically pretty horr
Realtime MIDI input/output is supported by RtMidi using the winmm.lib API and requires the __WINDOWS_MM__ preprocessor definition.
-Visual C++ 6.0 workspaces have been created for the various STK projects. Everything has already been configured for you. The intermediate .obj files will be written to either the "Release" or "Debug" directories, but the executable files will be written to the main project directories (where they need to be for proper execution). If you should somehow lose or hose the VC++ workspace file for a project, then you will have to do a LOT of configuring to recreate it ... it's probably easier just to download the distribution again from our WWW sites. Anyway, for your benefit and mine, here is a list of things that need to be added to the various "Project Settings":
+Visual C++ workspaces have been created for the various STK projects. Everything has already been configured for you. The intermediate .obj files will be written to either the "Release" or "Debug" directories, but the executable files will be written to the main project directories (where they need to be for proper execution). If you should somehow lose or hose the VC++ workspace file for a project, then you will have to do a LOT of configuring to recreate it ... it's probably easier just to download the distribution again from our WWW sites. Anyway, for your benefit and mine, here is a list of things that need to be added to the various "Project Settings" (this was for VC 6.0 ... things have changed with the newer versions of the VC compiler):
1. Under General: Set "Output files:" to (this will put the executable in the main project directory.
diff --git a/doc/ReleaseNotes.txt b/doc/ReleaseNotes.txt
index ed4439d..c946a58 100644
--- a/doc/ReleaseNotes.txt
+++ b/doc/ReleaseNotes.txt
@@ -1,13 +1,22 @@
The Synthesis ToolKit in C++ (STK)
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
+
+v4.3.0: (13 August 2007)
+- an official MIT-like license
+- new functionality to automatically update class data when the STK sample rate changes (partly implemented)
+- updates for new RtAudio version 4.0
+- bug fix in interpolate() function in Stk.h for non-interleaved data
+- fixes / improvements to the Granulate class
+- fix in Whistle when doing animation
+- fixes in BlitSquare for frequency, harmonics, and dc offset
+- updates to Makefiles for non-realtime compile
+- fix in demo.cpp for voice channel assignment
+- updated versions of RtMidi and RtAudio
+- updated ASIO files for MinGW compiler
+- new FAQ in documentation
+- MAT-file bug fix in FileRead class
-Future To Do:
-- OSC server/client classes
-- move various error checks, especially in tick() functions, into __DEBUG__ blocks?
-- add WAVEFORMATEXTENSIBLE support to RtAudio
-- add WAVEFORMATEXTENSIBLE support to WvIn/WvOut?
-- better documentation
v4.2.1: (14 October 2005)
- greatly expanded StkFrames functionality (including interpolation and indexing by channel/frame)
diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile
index 795a16e..9d51253 100644
--- a/doc/doxygen/Doxyfile
+++ b/doc/doxygen/Doxyfile
@@ -4,7 +4,7 @@
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = STK
-PROJECT_NUMBER = 4.2.1
+PROJECT_NUMBER = 4.3
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
diff --git a/doc/doxygen/compile.txt b/doc/doxygen/compile.txt
index ff153aa..ce5c05b 100644
--- a/doc/doxygen/compile.txt
+++ b/doc/doxygen/compile.txt
@@ -1,6 +1,6 @@
/*! \page compile Compiling
-The Synthesis ToolKit can be used in a variety of ways, depending on your particular needs. Some people choose the classes they need for a particular project and copy those to their working directory. Others create Makefiles which compile project-specific class objects from common src and include directories. And still others like to compile and link to a common library of object files. STK was not designed with one particular style of use in mind.
+The Synthesis ToolKit can be used in a variety of ways, depending on your particular needs. Some people choose the classes they need for a particular project and copy those to their working directory. Others create Makefiles that compile project-specific class objects from common src and include directories. And still others like to compile and link to a common library of object files. STK was not designed with one particular style of use in mind.
\section rtvsnonrt "Realtime" vs. "Non-Realtime"
@@ -9,11 +9,11 @@ Most of the Synthesis ToolKit classes are platform independent. That
means that they should compile on any reasonably current C++ compiler.
The functionality needed for realtime audio and MIDI input/output, as
well as realtime control message acquistion, is inherently platform
-and operating-system (OS) dependent. STK classes which require
+and operating-system (OS) dependent. STK classes that require
specific platform/OS support include RtAudio, RtWvOut, RtWvIn,
RtDuplex, RtMidi, InetWvIn, InetWvOut, Socket, UdpSocket, TcpServer,
TcpClient, Thread, and Mutex. These classes currently can only be
-compiled on Linux, Irix, Macintosh OS X, and Windows systems.
+compiled on Linux, Macintosh OS X, and Windows systems.
Without the "realtime" classes, it is still possible to read SKINI
scorefiles for control input and to read and write to/from a variety
@@ -42,15 +42,15 @@ STK compiles with realtime support on the following flavors of the Unix operatin
| Linux |
- Jack (audio only, use ALSA for MIDI support) |
- __LINUX_JACK__, __LINUX_ALSASEQ__, __LITTLE_ENDIAN__ |
+ OSS (version 4.0 only, use ALSA for MIDI support) |
+ __LINUX_OSS__, __LINUX_ALSASEQ__, __LITTLE_ENDIAN__ |
asound, pthread |
- | Linux |
- OSS (audio only, use ALSA for MIDI support) |
- __LINUX_OSS__, __LINUX_ALSASEQ__, __LITTLE_ENDIAN__ |
- asound, pthread |
+ Linux and Macintosh OS-X |
+ Jack (audio only, use ALSA for MIDI support) |
+ __UNIX_JACK__, __LINUX_ALSASEQ__, __LITTLE_ENDIAN__ |
+ asound, pthread, jack |
| Macintosh OS X |
@@ -58,12 +58,6 @@ STK compiles with realtime support on the following flavors of the Unix operatin
__MACOSX_CORE__ |
pthread, CoreAudio, CoreMIDI, CoreFoundation |
-
- | Irix |
- AL |
- __IRIX_AL__, __IRIX_MD__ |
- audio, pthread |
-
@@ -85,7 +79,7 @@ g++ -Wall -D__LITTLE_ENDIAN__ -o sineosc Stk.cpp FileRead.cpp FileWrite.cpp WvIn
Note that the sineosc.cpp example does not make use of realtime audio or MIDI input/output classes. For programs using any of the STK realtime classes mentioned above, it is necessary to specify an audio/MIDI API preprocessor definition and link with the appropriate libraries or frameworks.
-When working with a number of different projects that make use of ToolKit classes, the above approach can become cumbersome (especially when trying to synchronize with new STK releases). Most of the STK projects (e.g., demo, effects, ...) contain Makefiles (built by the configure script) which compile project-specific class objects from the distribution src and include directories. This approach makes it relatively easy when upgrading to a new STK release (by making path substitutions in the Makefile or by moving the projects to a similar relative path within the new STK source tree). A Makefile is provided in the projects/examples directory for compiling all the tutorial programs, as well as other example programs. To compile the sineosc.cpp program, for example, one need only type make sineosc from within the projects/examples directory.
+When working with a number of different projects that make use of ToolKit classes, the above approach can become cumbersome (especially when trying to synchronize with new STK releases). Most of the STK projects (e.g., demo, effects, ...) contain Makefiles (built by the configure script) that compile project-specific class objects from the distribution src and include directories. This approach makes it relatively easy when upgrading to a new STK release (by making path substitutions in the Makefile or by moving the projects to a similar relative path within the new STK source tree). A Makefile is provided in the projects/examples directory for compiling all the tutorial programs, as well as other example programs. To compile the sineosc.cpp program, for example, one need only type make sineosc from within the projects/examples directory.
\subsection library Library Use:
@@ -114,11 +108,11 @@ g++ -Wall -D__LITTLE_ENDIAN__ -o sineosc sineosc.cpp -lstk
\section compileWin Windows:
-STK has been tested on Windows platforms using the Visual C++ compiler
+STK has been tested on Windows platforms using the Visual .NET compiler
only. It is assumed here that you're familiar with Visual C++ and its
-particular idiosyncrasies.
+particular idiosyncrasies. STK won't compile in Visual C++ 6.0 any more.
-The approach when using Visual C++ is to build a project which
+The approach when using Visual C++ is to build a project that
includes the necessary ToolKit files from the distribution
src and include directories. For the example
program from the previous tutorial chapter, create a VC++ console
diff --git a/doc/doxygen/crealtime.txt b/doc/doxygen/crealtime.txt
index 02d4ec4..e0aa5aa 100644
--- a/doc/doxygen/crealtime.txt
+++ b/doc/doxygen/crealtime.txt
@@ -1,26 +1,74 @@
/*! \page crealtime Realtime Audio (callback)
-The previous section described the use of the RtWvOut class for realtime audio output. The RtWvOut::tick() function periodically pauses program execution in order to send a buffer of audio data to the computer's audio hardware (referred to as blocking functionality). These pauses will effectively limit a program's computations to the correct number of samples per second, which is defined by the sample rate of the hardware.
+An alternative scheme for audio input/output is to define a specific
+function in which audio computations are performed and to let the
+audio system call this function when more input/output data can be
+accepted by the hardware (referred to as a callback scheme). In this
+section, we show how the previous rtsine.cpp program can be
+modified to work in a callback scenario. There is no "single-sample"
+interface for this functionality. The callback function will be
+invoked automatically by the audio system controller (RtAudio) when
+new data is needed and it is necessary to compute a full audio buffer
+of samples at that time (see \ref callback for further information).
-An alternative scheme for audio input/output is to define a specific function in which audio computations are performed and to let the audio system call this function when more input/output data can be accepted by the hardware (referred to as a callback scheme). In this section, we show how the previous rtsine.cpp program can be modified to work in a callback scenario. There is no "single-sample" interface for this functionality. The callback function will be invoked automatically by the audio system controller (RtAudio) when new data is needed and it is necessary to compute a full audio buffer of samples at that time (see \ref callback for further information).
+The previous section described the use of the RtWvOut class for
+realtime audio output. The RtWvOut::tick() function writes data to a
+large ring-buffer, from which data is periodically written to the
+computer's audio hardware via an underlying callback routine.
\include crtsine.cpp
-The sinusoidal oscillator is created as before. The instantiation of RtAudio requires quite a few more parameters, including output/input device and channel specifiers, the data format, and the desired buffer length (in frames). In this example, we request a single output channel using the default output device, zero channels of input, the RtAudio data format which corresponds to an StkFloat, and the RT_BUFFER_SIZE defined in Stk.h. The last argument is an API-dependent buffering parameter (see RtAudio for further information).
+The sinusoidal oscillator is created as before. The instantiation of
+RtAudio requires quite a few more parameters, including output/input
+device and channel specifiers, the data format, and the desired buffer
+length (in frames). In this example, we request a single output
+channel using the default output device, zero channels of input, the
+RtAudio data format which corresponds to an StkFloat, and the
+RT_BUFFER_SIZE defined in Stk.h. The \c bufferFrames argument is an
+API-dependent buffering parameter (see RtAudio for further
+information).
-After the digital-to-analog converter (dac) and oscillator are successfully created, it is necessary to provide the audio system controller with a pointer to our callback function. The RtAudio::setStreamCallback() function takes a pointer to the callback function and an optional pointer to data that will be made available in the callback. In this example, we need to pass only the pointer to the oscillator. In more complex programs, it is typically necessary to put all shared data in a struct (see the next tutorial program for an example) or make use of global variables.
+We also provide the audio system controller with a pointer to our
+callback function and an optional pointer to data that will be made
+available in the callback. In this example, we need to pass only the
+pointer to the oscillator. In more complex programs, it is typically
+necessary to put all shared data in a struct (see the next
+tutorial program for an example) or make use of global variables.
-Our callback routine is the \c tick() function. %Function arguments include a pointer to the audio data buffer, the buffer size (in frames), and the data pointer passed to the RtAudio::setStreamCallback() function (if it exists). It is necessary to cast these pointers to their corresponding data types before use. Our tick() routine simply "ticks" the oscillator for \c bufferSize counts and writes the result into the audio data buffer before returning.
+Our callback routine is the \c tick() function. Function arguments
+include pointers to the audio input and output data buffers, the
+buffer size (in frames), a stream time argument, a status argument to
+test for over/underruns, and the data pointer passed in the
+openStream() function (if it exists). It is necessary to cast these
+pointers to their corresponding data types before use. Our tick()
+routine simply "ticks" the oscillator for \c nBufferFrames counts and
+writes the result into the audio data buffer before returning.
-The \c main() function blocks at the std::cin.get() call until the user hits the "enter" key, after which the audio controller is shut down and program execution ends.
+The \c main() function blocks at the std::cin.get() call until the
+user hits the "enter" key, after which the audio controller is shut
+down and program execution ends.
\section callback Blocking vs. Callbacks
-Prior to version 4.2.0, all STK example projects and programs used blocking audio input/output functionality (typically with the RtWvIn, RtWvOut, or RtDuplex classes). In many instances, a blocking scheme results in a clearer and more straight-forward program structure. Within a graphical user interface (GUI) programming context, however, callback routines are often more natural.
+Prior to version 4.2.0, all STK example projects and programs used
+blocking audio input/output functionality (typically with the RtWvIn,
+RtWvOut, or RtDuplex classes). In many instances, a blocking scheme
+results in a clearer and more straight-forward program structure.
+Within a graphical user interface (GUI) programming context, however,
+callback routines are often more natural.
-The RtAudio class provides both blocking and callback routines for all supported audio APIs. It should be noted that it is easy to embed blocking calls within a thread to create "callback-like" functionality. In fact, this is what RtAudio does for those audio APIs which are naturally based on blocking routines (Linux ALSA and OSS, SGI Irix, and Windows DirectSound). It is much more difficult to make an inherently callback-based system work like a blocking scheme. RtAudio attempts to do this with the Linux JACK, Macintosh OS-X CoreAudio, and Windows ASIO APIs, but the result is not fully robust (audio over/underruns are more likely to occur).
-
-In order to allow all STK programs to function with equal proficiency on all supported computer platforms, a decision was made to modify the example projects to use audio callback routines. The result is a more complicated code structure, which is unfortunate given that we generally strive to make STK code as clear as possible for educational purposes. This was especially an issue with the demo program because it is designed to function in both realtime and non-realtime contexts. The use of global variables has been avoided by defining data structures to hold all variables which must be accessible to the callback routine and other functions. Alternative schemes for making control updates could be designed depending on particular program needs and constraints.
+In order to allow all STK programs to function with equal proficiency
+on all supported computer platforms, a decision was made to modify the
+example projects to use audio callback routines. The result is a more
+complicated code structure, which is unfortunate given that we
+generally strive to make STK code as clear as possible for educational
+purposes. This was especially an issue with the demo program because
+it is designed to function in both realtime and non-realtime contexts.
+The use of global variables has been avoided by defining data
+structures to hold all variables that must be accessible to the
+callback routine and other functions. Alternative schemes for making
+control updates could be designed depending on particular program
+needs and constraints.
[Main tutorial page] [Next tutorial]
*/
diff --git a/doc/doxygen/download.txt b/doc/doxygen/download.txt
index 9ba6a6d..0986d23 100644
--- a/doc/doxygen/download.txt
+++ b/doc/doxygen/download.txt
@@ -1,16 +1,34 @@
/*! \page download Download, Release Notes, and Bug Fixes
-\section down Download Version 4.2.1 (14 October 2005):
+\section down Download Version 4.3.0 (13 August 2007):
\section notes Release Notes:
+\subsection v4dot3dot0 Version 4.3.0
+
+
+- An official MIT-like license.
+- New functionality to automatically update class data when the STK sample rate changes (partly implemented).
+- Updates for new RtAudio version 4.0.
+- Bug fix in interpolate() function in Stk.h for non-interleaved data.
+- Fixes / improvements to the Granulate class.
+- Fix in Whistle when doing animation.
+- Fixes in BlitSquare for frequency, harmonics, and dc offset.
+- Updates to Makefiles for non-realtime compile.
+- Fix in demo.cpp for voice channel assignment.
+- Updated versions of RtMidi and RtAudio.
+- Updated ASIO files for MinGW compiler.
+- New FAQ in documentation.
+- MAT-file bug fix in FileRead class.
+
+
\subsection v4dot2dot1 Version 4.2.1
diff --git a/doc/doxygen/faq.txt b/doc/doxygen/faq.txt
new file mode 100644
index 0000000..fbd3f93
--- /dev/null
+++ b/doc/doxygen/faq.txt
@@ -0,0 +1,72 @@
+/*! \page faq Frequently Asked Questions
+
+- \ref license
+- \ref filerate
+- \ref computesample
+- \ref tickframe
+- \ref endianness
+- \ref xwindows
+
+\section license Does STK have a license?
+
+Yes, we finally made something official for release 4.3.0. It is listed in the Stk class and a few other places in the distribution, but I'll repeat it here for clarity:
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+Any person wishing to distribute modifications to the Software is
+asked to send the modifications to the original developer so that they
+can be incorporated into the canonical version. This is, however, not
+a binding provision of this license.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+\section filerate Why is my file sample rate wrong?
+
+When the FileWvIn class loads a soundfile, it automatically sets its internal read increment based on the soundfile rate and the current STK sample rate. For example, if the current STK sample rate is 44100 Hz and the soundfile rate is 22050 Hz, the read increment, or rate, will be set to 0.5 and the file will be interpolated so that is sounds correct at 44100 Hz. For most cases, this works fine. However, consider the following example:
+
+\code
+FileWvIn input( "infile" ); // read an input soundfile
+StkFloat sampleRate = input.getFileRate();
+Stk::setSampleRate( sampleRate ); // set a new STK sample rate based on the file rate
+\endcode
+
+With version 4.3 and higher of STK, the FileWvIn class will be notified of a sample rate change and it will automatically adjust its read rate accordingly. Previous versions of STK did not perform this change and thus, the read rate could end up being incorrect. If you do not want FileWvIn to perform this automatic adjustment, you can call the \c ignoreSampleRateChange() function for a given class instance.
+
+\section tickframe What is the difference between the tick() and tickFrame() functions?
+
+\e tickFrame() functions are provided in classes that can handle multi-channel data. A sample frame of audio data represents a single "slice" in time across many audio channels. The WvIn and WvOut subclasses are the primary classes in STK that currently implement the \e tickFrame() functions. \e tick() functions are used for monophonic classes. Note, however, that the WvIn and WvOut classes also implement \e tick() functions though their behavior is dependent on the number of channels you are working with. For example, if using the FileWvIn class with a monophonic soundfile, then there is no difference between the \e tick() and \e tickFrame() functions (aside from the format of their arguments). But if you have a multi-channel file open, then the single value returned from the tick() function is an average of all the samples in the multi-channel sample frame.
+
+\section computesample Hey, why was the tick() function replaced by computeSample() in various STK classes?
+
+C++ doesn't like overloaded virtual functions. All STK classes that implement a single-sample \e tick() function also provide an overloaded version that takes an StkFrames argument (for vectorized computations). Further, many STK classes inherit from abstract base classes (Instrmnt, Generator, ...) and it is most convenient to define functionality common to all subclasses (like the \e tick() function that takes an StkFrames argument) in only the base class. So, to get around the overloaded virtual function problem, STK now uses the \e computeSample() function as a non-overloaded virtual function that is implemented in all subclasses (it essentially replaces the \e tick() function). Note, however, that the overloaded \e tick() functions are still available to the user ... they are implemented in the base classes.
+
+\section endianness Why does the sound I generated with STK sound like *@!?
+
+If the resultant sound generated by an STK program sounds like noise (and you're not doing an MLS experiment), the problem is likely related to the byte "endianness" of your computer. By default, STK assumes "big endian" byte order. If you are working with STK classes on a PC (Windows or Linux), you \e must define the __LITTLE_ENDIAN__ preprocessor definition \e before compiling. If after reading this you realize you need to make this change, do not forget to recompile all STK classes from scratch.
+
+\section xwindows Why do I get a Tk display error message?
+
+The following error will be printed to your terminal window if you attempt to start an STK tcl/tk interface without the X Server first running:
+
+\code
+Application initialization failed: this isn't a Tk applicationcouldn't connect to display ":0.0"
+\endcode
+
+Simply start your X server and then try the command again.
+
+*/
diff --git a/doc/doxygen/footer.html b/doc/doxygen/footer.html
index 3eb686f..c536480 100644
--- a/doc/doxygen/footer.html
+++ b/doc/doxygen/footer.html
@@ -2,7 +2,7 @@
| The Synthesis ToolKit in C++ (STK) |
- | ©1995-2005 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |
+ | ©1995-2007 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |
+This software was designed and created to be made publicly available
+for free, primarily for academic purposes, so if you use it, pass it
+on with this documentation, and for free. If you make a million
+dollars with it, it would be nice if you would share. If you make
+compositions with it, put us in the program notes.
-Some of the concepts are covered by various patents, some known to us and likely others which are unknown. Many of the ones known to us are administered by the Stanford Office of Technology and Licensing. The good news is that large hunks of the techniques used here are public domain. To avoid subtle legal issues, we will not state what's freely useable here, but we will try to note within the various classes where certain things are likely to be protected by patents.
+Some of the concepts are covered by various patents, some known to us
+and likely others that are unknown. Many of the ones known to us are
+administered by the Stanford Office of Technology and Licensing. The
+good news is that large hunks of the techniques used here are public
+domain. To avoid subtle legal issues, we will not state what's freely
+useable here, but we will try to note within the various classes where
+certain things are likely to be protected by patents.
+
- Clarinet: Pretty good physical model of the clarinet
- BlowHole: A clarinet physical model with one tonehole and one register vent
-- Saxofony: A psuedo-conical bore reed instrument which sometimes sounds like a saxophone
+- Saxofony: A psuedo-conical bore reed instrument that sometimes sounds like a saxophone
- Flute: Pretty good physical model of the flute
- Brass: Not so bad physical model of a brass instrument
- BlowBotl: A basic helmholtz resonator and air jet model
@@ -141,7 +140,7 @@ from the demo directory will play the scorefile bookert.ski
\section rt Demo: Realtime Use
-STK realtime audio and MIDI input/output and realtime SKINI control input via socketing support is provided for Linux, SGI, Mac OS X, and Windows95/98/2000/XP operating systems. STK realtime SKINI control input via piping is possible under Linux, SGI, Mac OS X, and Windows2000/XP only.
+STK realtime audio and MIDI input/output and realtime SKINI control input via socketing support is provided for Linux, Mac OS-X, and Windows95/98/2000/XP operating systems. STK realtime SKINI control input via piping is possible under Linux, Mac OS X, and Windows2000/XP only.
Control input and audio output options are typically specified as command-line arguments to STK programs. For example, the demo program is invoked as:
@@ -199,7 +198,7 @@ On all supported realtime platforms, you can direct realtime MIDI input to the S
demo Clarinet -or -im
\endcode
-This will attempt to use the default MIDI port for input. An optional MIDI port number can be specified after the -im flag. Valid MIDI ports are numbered from 0 (default) and higher. On Linux and Macintosh OS-X systems, it is possible to open a virtual MIDI input port (which other software applications can connect to) by specifying a port identifier of -1.
+This will attempt to use the default MIDI port for input. An optional MIDI port number can be specified after the -im flag. Valid MIDI ports are numbered from 0 (default) and higher. On Linux and Macintosh OS-X systems, it is possible to open a virtual MIDI input port (that other software applications can connect to) by specifying a port identifier of -1.
\section polyphony Polyphony:
diff --git a/doc/hierarchy.txt b/doc/hierarchy.txt
index 8520e0b..a4f2f47 100644
--- a/doc/hierarchy.txt
+++ b/doc/hierarchy.txt
@@ -1,6 +1,6 @@
STK: A ToolKit of Audio Synthesis Classes and Instruments in C++
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
STK Classes - See the HTML documentation in the html directory for complete information.
diff --git a/include/ADSR.h b/include/ADSR.h
index 04df416..c1971e8 100644
--- a/include/ADSR.h
+++ b/include/ADSR.h
@@ -11,7 +11,7 @@
envelope value reaches 0.0 in the
ADSR::RELEASE state.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -75,6 +75,7 @@ class ADSR : public Envelope
protected:
StkFloat computeSample( void );
+ void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
StkFloat attackRate_;
StkFloat decayRate_;
diff --git a/include/Asymp.h b/include/Asymp.h
index e1a5c1d..ad74265 100644
--- a/include/Asymp.h
+++ b/include/Asymp.h
@@ -19,7 +19,7 @@
to \e keyOn and \e keyOff messages by ramping to
1.0 on keyOn and to 0.0 on keyOff.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -64,6 +64,7 @@ class Asymp : public Envelope
protected:
StkFloat computeSample( void );
+ void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
StkFloat factor_;
StkFloat constant_;
diff --git a/include/BeeThree.h b/include/BeeThree.h
index 0880c24..39f76f0 100644
--- a/include/BeeThree.h
+++ b/include/BeeThree.h
@@ -28,7 +28,7 @@
type who should worry about this (making
money) worry away.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/BiQuad.h b/include/BiQuad.h
index 7a58548..d1951f6 100644
--- a/include/BiQuad.h
+++ b/include/BiQuad.h
@@ -8,7 +8,7 @@
frequency response while maintaining a constant
filter gain.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -27,6 +27,9 @@ public:
//! Class destructor.
virtual ~BiQuad();
+ //! A function to enable/disable the automatic updating of class data when the STK sample rate changes.
+ void ignoreSampleRateChange( bool ignore = true ) { ignoreSampleRateChange_ = ignore; };
+
//! Clears all internal states of the filter.
void clear(void);
@@ -107,6 +110,30 @@ public:
// This function must be implemented in all subclasses. It is used
// to get around a C++ problem with overloaded virtual functions.
virtual StkFloat computeSample( StkFloat input );
+ virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
};
+inline StkFloat BiQuad :: computeSample( StkFloat input )
+{
+ inputs_[0] = gain_ * input;
+ outputs_[0] = b_[0] * inputs_[0] + b_[1] * inputs_[1] + b_[2] * inputs_[2];
+ outputs_[0] -= a_[2] * outputs_[2] + a_[1] * outputs_[1];
+ inputs_[2] = inputs_[1];
+ inputs_[1] = inputs_[0];
+ outputs_[2] = outputs_[1];
+ outputs_[1] = outputs_[0];
+
+ return outputs_[0];
+}
+
+inline StkFloat BiQuad :: tick( StkFloat input )
+{
+ return this->computeSample( input );
+}
+
+inline StkFrames& BiQuad :: tick( StkFrames& frames, unsigned int channel )
+{
+ return Filter::tick( frames, channel );
+}
+
#endif
diff --git a/include/BlitSquare.h b/include/BlitSquare.h
index 8c758ff..a41f02a 100644
--- a/include/BlitSquare.h
+++ b/include/BlitSquare.h
@@ -8,8 +8,8 @@
The algorithm implemented in this class uses a SincM function with
an even M value to achieve a bipolar bandlimited impulse train.
This signal is then integrated to achieve a square waveform. The
- integration process has an associated DC offset but that is
- subtracted off the output signal.
+ integration process has an associated DC offset so a DC blocking
+ filter is applied at the output.
The user can specify both the fundamental frequency of the
waveform and the number of harmonics contained in the resulting
@@ -19,10 +19,14 @@
to half the sample rate. Note, however, that this setting may
produce aliasing in the signal when the frequency is changing (no
automatic modification of the number of harmonics is performed by
- the setFrequency() function).
+ the setFrequency() function). Also note that the harmonics of a
+ square wave fall at odd integer multiples of the fundamental, so
+ aliasing will happen with a lower fundamental than with the other
+ Blit waveforms. This class is not guaranteed to be well behaved
+ in the presence of significant aliasing.
Based on initial code of Robin Davies, 2005.
- Modified algorithm code by Gary Scavone, 2005.
+ Modified algorithm code by Gary Scavone, 2005 - 2006.
*/
/***************************************************/
@@ -83,7 +87,9 @@ class BlitSquare: public Generator
StkFloat rate_;
StkFloat phase_;
StkFloat p_;
- StkFloat offset_;
+ StkFloat a_;
+ StkFloat lastBlitOutput_;
+ StkFloat dcbState_;
};
#endif
diff --git a/include/BlowBotl.h b/include/BlowBotl.h
index 7bf7f1b..42a4cc9 100644
--- a/include/BlowBotl.h
+++ b/include/BlowBotl.h
@@ -12,7 +12,7 @@
- Vibrato Gain = 1
- Volume = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/BlowHole.h b/include/BlowHole.h
index 9dd06b4..125e70e 100644
--- a/include/BlowHole.h
+++ b/include/BlowHole.h
@@ -29,7 +29,7 @@
- Register State = 1
- Breath Pressure = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/BowTable.h b/include/BowTable.h
index 093b9aa..dfc4862 100644
--- a/include/BowTable.h
+++ b/include/BowTable.h
@@ -5,7 +5,7 @@
This class implements a simple bowed string
non-linear function, as described by Smith (1986).
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Bowed.h b/include/Bowed.h
index 56be381..e077ba9 100644
--- a/include/Bowed.h
+++ b/include/Bowed.h
@@ -17,7 +17,7 @@
- Vibrato Gain = 1
- Volume = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Brass.h b/include/Brass.h
index 2242bb3..da13dde 100644
--- a/include/Brass.h
+++ b/include/Brass.h
@@ -16,7 +16,7 @@
- Vibrato Gain = 1
- Volume = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Chorus.h b/include/Chorus.h
index 241e1e9..046f6c8 100644
--- a/include/Chorus.h
+++ b/include/Chorus.h
@@ -4,7 +4,7 @@
This class implements a chorus effect.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Clarinet.h b/include/Clarinet.h
index d5b09ac..5bef84a 100644
--- a/include/Clarinet.h
+++ b/include/Clarinet.h
@@ -18,7 +18,7 @@
- Vibrato Gain = 1
- Breath Pressure = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Delay.h b/include/Delay.h
index 83dc8f1..addefbd 100644
--- a/include/Delay.h
+++ b/include/Delay.h
@@ -14,7 +14,7 @@
used in fixed delay-length applications, such
as for reverberation.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/DelayA.h b/include/DelayA.h
index 540f950..f8d87e3 100644
--- a/include/DelayA.h
+++ b/include/DelayA.h
@@ -15,7 +15,7 @@
minimum delay possible in this implementation is limited to a
value of 0.5.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/DelayL.h b/include/DelayL.h
index f0e0b87..ed5d820 100644
--- a/include/DelayL.h
+++ b/include/DelayL.h
@@ -18,7 +18,7 @@
order Lagrange interpolators can typically
improve (minimize) this attenuation characteristic.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Drummer.h b/include/Drummer.h
index e362ef7..d9411bd 100644
--- a/include/Drummer.h
+++ b/include/Drummer.h
@@ -11,7 +11,7 @@
of simultaneous voices) via a #define in the
Drummer.h.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Echo.h b/include/Echo.h
index f8f3d76..f9a6fff 100644
--- a/include/Echo.h
+++ b/include/Echo.h
@@ -4,7 +4,7 @@
This class implements an echo effect.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Effect.h b/include/Effect.h
index 8903d8e..530f62f 100644
--- a/include/Effect.h
+++ b/include/Effect.h
@@ -5,7 +5,7 @@
This class provides common functionality for
STK effects subclasses.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Envelope.h b/include/Envelope.h
index 7b8a688..23c97d6 100644
--- a/include/Envelope.h
+++ b/include/Envelope.h
@@ -9,7 +9,7 @@
\e keyOff messages, ramping to 1.0 on
keyOn and to 0.0 on keyOff.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -58,6 +58,7 @@ class Envelope : public Generator
protected:
virtual StkFloat computeSample( void );
+ virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
StkFloat value_;
StkFloat target_;
diff --git a/include/FM.h b/include/FM.h
index f0c17a2..18c2895 100644
--- a/include/FM.h
+++ b/include/FM.h
@@ -19,7 +19,7 @@
type who should worry about this (making
money) worry away.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/FMVoices.h b/include/FMVoices.h
index 02d782d..ec8dff1 100644
--- a/include/FMVoices.h
+++ b/include/FMVoices.h
@@ -26,7 +26,7 @@
type who should worry about this (making
money) worry away.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/FileRead.h b/include/FileRead.h
index 04fa5a2..3d29195 100644
--- a/include/FileRead.h
+++ b/include/FileRead.h
@@ -25,7 +25,7 @@
filling a matrix row. The sample rate for
MAT-files is assumed to be 44100 Hz.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/FileWrite.h b/include/FileWrite.h
index 2401ea1..c43db1b 100644
--- a/include/FileWrite.h
+++ b/include/FileWrite.h
@@ -17,7 +17,7 @@
type, the data type will automatically be modified. Compressed
data types are not supported.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/FileWvIn.h b/include/FileWvIn.h
index ab5a661..ec54032 100644
--- a/include/FileWvIn.h
+++ b/include/FileWvIn.h
@@ -27,7 +27,7 @@
See the FileRead class for a description of the supported audio
file formats.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -126,6 +126,7 @@ public:
protected:
virtual void computeFrame( void );
+ virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
FileRead file_;
bool finished_;
diff --git a/include/FileWvOut.h b/include/FileWvOut.h
index 1f82fb0..3af786f 100644
--- a/include/FileWvOut.h
+++ b/include/FileWvOut.h
@@ -17,7 +17,7 @@
Currently, FileWvOut is non-interpolating and the output rate is
always Stk::sampleRate().
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Filter.h b/include/Filter.h
index f10dc1e..2ed9106 100644
--- a/include/Filter.h
+++ b/include/Filter.h
@@ -23,7 +23,7 @@
results in one extra multiply per computed sample,
but allows easy control of the overall filter gain.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Flute.h b/include/Flute.h
index 97df13b..9b95f9f 100644
--- a/include/Flute.h
+++ b/include/Flute.h
@@ -18,7 +18,7 @@
- Vibrato Gain = 1
- Breath Pressure = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/FormSwep.h b/include/FormSwep.h
index 2e74428..f7daf56 100644
--- a/include/FormSwep.h
+++ b/include/FormSwep.h
@@ -8,7 +8,7 @@
It provides methods for controlling the sweep
rate and target frequency.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Function.h b/include/Function.h
index 13e6bc7..99d2d68 100644
--- a/include/Function.h
+++ b/include/Function.h
@@ -6,7 +6,7 @@
implement tables or other types of input to output function
mappings.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Generator.h b/include/Generator.h
index 6f82b86..71242a2 100644
--- a/include/Generator.h
+++ b/include/Generator.h
@@ -5,7 +5,7 @@
This class provides common functionality for
STK unit generator sample-source subclasses.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Granulate.h b/include/Granulate.h
index 8629df0..ea0a4b3 100644
--- a/include/Granulate.h
+++ b/include/Granulate.h
@@ -76,9 +76,11 @@ class Granulate: public Generator
trapezoidal window. In addition, each grain can have a time delay
of length \e delay and a grain pointer increment of length \e
offset, which can be negative, before the next ramp onset (in
- milliseconds). The actual values calculated for each grain will
- be randomized by a factor set using the setRandomFactor()
- function.
+ milliseconds). The \e offset parameter controls grain pointer
+ jumps between enveloped grain segments, while the \e delay
+ parameter causes grain calculations to pause between grains. The
+ actual values calculated for each grain will be randomized by a
+ factor set using the setRandomFactor() function.
*/
void setGrainParameters( unsigned int duration = 30, unsigned int rampPercent = 50,
int offset = 0, unsigned int delay = 0 );
diff --git a/include/HevyMetl.h b/include/HevyMetl.h
index 80030a7..f070fc1 100644
--- a/include/HevyMetl.h
+++ b/include/HevyMetl.h
@@ -24,7 +24,7 @@
type who should worry about this (making
money) worry away.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/InetWvIn.h b/include/InetWvIn.h
index 5ff944b..c2aee83 100644
--- a/include/InetWvIn.h
+++ b/include/InetWvIn.h
@@ -20,7 +20,7 @@
data type for the incoming stream is signed 16-bit integers,
though any of the defined StkFormats are permissible.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/InetWvOut.h b/include/InetWvOut.h
index 964c8cb..96c273e 100644
--- a/include/InetWvOut.h
+++ b/include/InetWvOut.h
@@ -16,7 +16,7 @@
data type is signed 16-bit integers but any of the defined
StkFormats are permissible.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Instrmnt.h b/include/Instrmnt.h
index e3a66e9..85b2c7e 100644
--- a/include/Instrmnt.h
+++ b/include/Instrmnt.h
@@ -5,7 +5,7 @@
This class provides a common interface for
all STK instruments.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/JCRev.h b/include/JCRev.h
index 397d21e..6c55019 100644
--- a/include/JCRev.h
+++ b/include/JCRev.h
@@ -10,7 +10,7 @@
filters, and two decorrelation delay lines in
parallel at the output.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/JetTable.h b/include/JetTable.h
index c527c98..2a3f298 100644
--- a/include/JetTable.h
+++ b/include/JetTable.h
@@ -9,7 +9,7 @@
Consult Fletcher and Rossing, Karjalainen,
Cook, and others for more information.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Mandolin.h b/include/Mandolin.h
index ce62301..dee9637 100644
--- a/include/Mandolin.h
+++ b/include/Mandolin.h
@@ -23,7 +23,7 @@
- String Detuning = 1
- Microphone Position = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Messager.h b/include/Messager.h
index cf3b087..4607c8a 100644
--- a/include/Messager.h
+++ b/include/Messager.h
@@ -28,7 +28,7 @@
This class is primarily for use in STK example programs but it is
generic enough to work in many other contexts.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Modal.h b/include/Modal.h
index fdc7b2a..576d931 100644
--- a/include/Modal.h
+++ b/include/Modal.h
@@ -7,7 +7,7 @@
(non-sweeping BiQuad filters), where N is set
during instantiation.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/ModalBar.h b/include/ModalBar.h
index bea5ed8..aca13b8 100644
--- a/include/ModalBar.h
+++ b/include/ModalBar.h
@@ -24,7 +24,7 @@
- Two Fixed = 7
- Clump = 8
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Modulate.h b/include/Modulate.h
index d47d301..6573964 100644
--- a/include/Modulate.h
+++ b/include/Modulate.h
@@ -6,7 +6,7 @@
modulations to give a nice, natural human
modulation function.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Moog.h b/include/Moog.h
index e72ce3d..ec6497b 100644
--- a/include/Moog.h
+++ b/include/Moog.h
@@ -14,7 +14,7 @@
- Vibrato Gain = 1
- Gain = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Mutex.h b/include/Mutex.h
index 6757f44..ac04384 100644
--- a/include/Mutex.h
+++ b/include/Mutex.h
@@ -7,7 +7,7 @@
systems, the pthread library is used. Under
Windows, critical sections are used.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/NRev.h b/include/NRev.h
index b594b71..dce31cd 100644
--- a/include/NRev.h
+++ b/include/NRev.h
@@ -12,7 +12,7 @@
filters in parallel with corresponding right
and left outputs.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Noise.h b/include/Noise.h
index f87eb93..6d154e8 100644
--- a/include/Noise.h
+++ b/include/Noise.h
@@ -6,7 +6,7 @@
C rand() function. The quality of the rand()
function varies from one OS to another.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/OnePole.h b/include/OnePole.h
index 7ed5dca..652753b 100644
--- a/include/OnePole.h
+++ b/include/OnePole.h
@@ -8,7 +8,7 @@
the real axis of the z-plane while maintaining
a constant peak filter gain.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/OneZero.h b/include/OneZero.h
index d34eb30..45e2435 100644
--- a/include/OneZero.h
+++ b/include/OneZero.h
@@ -8,7 +8,7 @@
along the real axis of the z-plane while
maintaining a constant filter gain.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/PRCRev.h b/include/PRCRev.h
index 8760496..2fd6ef4 100644
--- a/include/PRCRev.h
+++ b/include/PRCRev.h
@@ -10,7 +10,7 @@
two series allpass units and two parallel comb
filters.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/PercFlut.h b/include/PercFlut.h
index c573757..5745466 100644
--- a/include/PercFlut.h
+++ b/include/PercFlut.h
@@ -22,7 +22,7 @@
type who should worry about this (making
money) worry away.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Phonemes.h b/include/Phonemes.h
index f5dc2de..21773ad 100644
--- a/include/Phonemes.h
+++ b/include/Phonemes.h
@@ -6,7 +6,7 @@
set of 32 static phoneme formant parameters
and provide access to those values.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/PitShift.h b/include/PitShift.h
index 45dd830..521bb57 100644
--- a/include/PitShift.h
+++ b/include/PitShift.h
@@ -5,7 +5,7 @@
This class implements a simple pitch shifter
using delay lines.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/PluckTwo.h b/include/PluckTwo.h
index dfa3efe..3e479ec 100644
--- a/include/PluckTwo.h
+++ b/include/PluckTwo.h
@@ -14,7 +14,7 @@
use possibly subject to patents held by
Stanford University, Yamaha, and others.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Plucked.h b/include/Plucked.h
index 251a30e..ceba36c 100644
--- a/include/Plucked.h
+++ b/include/Plucked.h
@@ -13,7 +13,7 @@
Stanford, bearing the names of Karplus and/or
Strong.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/PoleZero.h b/include/PoleZero.h
index 989076c..5f1b520 100644
--- a/include/PoleZero.h
+++ b/include/PoleZero.h
@@ -8,7 +8,7 @@
filter with a given coefficient. Another
method is provided to create a DC blocking filter.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/ReedTable.h b/include/ReedTable.h
index a01ea2b..3b599e6 100644
--- a/include/ReedTable.h
+++ b/include/ReedTable.h
@@ -13,7 +13,7 @@
Smith (1986), Hirschman, Cook, Scavone, and
others for more information.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Resonate.h b/include/Resonate.h
index 2e51e33..b5b3f05 100644
--- a/include/Resonate.h
+++ b/include/Resonate.h
@@ -13,7 +13,7 @@
- Zero Radii = 1
- Envelope Gain = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Rhodey.h b/include/Rhodey.h
index 3960554..d7ab2b3 100644
--- a/include/Rhodey.h
+++ b/include/Rhodey.h
@@ -26,7 +26,7 @@
type who should worry about this (making
money) worry away.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/RtAudio.h b/include/RtAudio.h
index e26f81d..1c54e97 100644
--- a/include/RtAudio.h
+++ b/include/RtAudio.h
@@ -4,13 +4,13 @@
RtAudio provides a common API (Application Programming Interface)
for realtime audio input/output across Linux (native ALSA, Jack,
- and OSS), SGI, Macintosh OS X (CoreAudio), and Windows
+ and OSS), SGI, Macintosh OS X (CoreAudio and Jack), and Windows
(DirectSound and ASIO) operating systems.
- RtAudio WWW site: http://music.mcgill.ca/~gary/rtaudio/
+ RtAudio WWW site: http://www.music.mcgill.ca/~gary/rtaudio/
RtAudio: realtime audio i/o C++ classes
- Copyright (c) 2001-2005 Gary P. Scavone
+ Copyright (c) 2001-2007 Gary P. Scavone
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
@@ -24,8 +24,9 @@
included in all copies or substantial portions of the Software.
Any person wishing to distribute modifications to the Software is
- requested to send the modifications to the original developer so that
- they can be incorporated into the canonical version.
+ asked to send the modifications to the original developer so that
+ they can be incorporated into the canonical version. This is,
+ however, not a binding provision of this license.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
@@ -37,14 +38,438 @@
*/
/************************************************************************/
-// RtAudio: Version 3.0.2 (14 October 2005)
+/*!
+ \file RtAudio.h
+ */
+
+// RtAudio: Version 4.0
#ifndef __RTAUDIO_H
#define __RTAUDIO_H
-#include "RtError.h"
#include
#include
+#include "RtError.h"
+
+/*! \typedef typedef unsigned long RtAudioFormat;
+ \brief RtAudio data format type.
+
+ Support for signed integers and floats. Audio data fed to/from an
+ RtAudio stream is assumed to ALWAYS be in host byte order. The
+ internal routines will automatically take care of any necessary
+ byte-swapping between the host format and the soundcard. Thus,
+ endian-ness is not a concern in the following format definitions.
+
+ - \e RTAUDIO_SINT8: 8-bit signed integer.
+ - \e RTAUDIO_SINT16: 16-bit signed integer.
+ - \e RTAUDIO_SINT24: Upper 3 bytes of 32-bit signed integer.
+ - \e RTAUDIO_SINT32: 32-bit signed integer.
+ - \e RTAUDIO_FLOAT32: Normalized between plus/minus 1.0.
+ - \e RTAUDIO_FLOAT64: Normalized between plus/minus 1.0.
+*/
+typedef unsigned long RtAudioFormat;
+static const RtAudioFormat RTAUDIO_SINT8 = 0x1; // 8-bit signed integer.
+static const RtAudioFormat RTAUDIO_SINT16 = 0x2; // 16-bit signed integer.
+static const RtAudioFormat RTAUDIO_SINT24 = 0x4; // Lower 3 bytes of 32-bit signed integer.
+static const RtAudioFormat RTAUDIO_SINT32 = 0x8; // 32-bit signed integer.
+static const RtAudioFormat RTAUDIO_FLOAT32 = 0x10; // Normalized between plus/minus 1.0.
+static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; // Normalized between plus/minus 1.0.
+
+/*! \typedef typedef unsigned long RtAudioStreamFlags;
+ \brief RtAudio stream option flags.
+
+ The following flags can be OR'ed together to allow a client to
+ make changes to the default stream behavior:
+
+ - \e RTAUDIO_NONINTERLEAVED: Use non-interleaved buffers (default = interleaved).
+ - \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency.
+ - \e RTAUDIO_HOG_DEVICE: Attempt grab device for exclusive use.
+
+ By default, RtAudio streams pass and receive audio data from the
+ client in an interleaved format. By passing the
+ RTAUDIO_NONINTERLEAVED flag to the openStream() function, audio
+ data will instead be presented in non-interleaved buffers. In
+ this case, each buffer argument in the RtAudioCallback function
+ will point to a single array of data, with \c nFrames samples for
+ each channel concatenated back-to-back. For example, the first
+ sample of data for the second channel would be located at index \c
+ nFrames (assuming the \c buffer pointer was recast to the correct
+ data type for the stream).
+
+ Certain audio APIs offer a number of parameters that influence the
+ I/O latency of a stream. By default, RtAudio will attempt to set
+ these parameters internally for robust (glitch-free) performance
+ (though some APIs, like Windows Direct Sound, make this difficult).
+ By passing the RTAUDIO_MINIMIZE_LATENCY flag to the openStream()
+ function, internal stream settings will be influenced in an attempt
+ to minimize stream latency, though possibly at the expense of stream
+ performance.
+
+ If the RTAUDIO_HOG_DEVICE flag is set, RtAudio will attempt to
+ open the input and/or output stream device(s) for exclusive use.
+ Note that this is not possible with all supported audio APIs.
+*/
+typedef unsigned int RtAudioStreamFlags;
+static const RtAudioStreamFlags RTAUDIO_NONINTERLEAVED = 0x1; // Use non-interleaved buffers (default = interleaved).
+static const RtAudioStreamFlags RTAUDIO_MINIMIZE_LATENCY = 0x2; // Attempt to set stream parameters for lowest possible latency.
+static const RtAudioStreamFlags RTAUDIO_HOG_DEVICE = 0x4; // Attempt grab device and prevent use by others.
+
+/*! \typedef typedef unsigned long RtAudioStreamStatus;
+ \brief RtAudio stream status (over- or underflow) flags.
+
+ Notification of a stream over- or underflow is indicated by a
+ non-zero stream \c status argument in the RtAudioCallback function.
+ The stream status can be one of the following two options,
+ depending on whether the stream is open for output and/or input:
+
+ - \e RTAUDIO_INPUT_OVERFLOW: Input data was discarded because of an overflow condition at the driver.
+ - \e RTAUDIO_OUTPUT_UNDERFLOW: The output buffer ran low, likely producing a break in the output sound.
+*/
+typedef unsigned int RtAudioStreamStatus;
+static const RtAudioStreamStatus RTAUDIO_INPUT_OVERFLOW = 0x1; // Input data was discarded because of an overflow condition at the driver.
+static const RtAudioStreamStatus RTAUDIO_OUTPUT_UNDERFLOW = 0x2; // The output buffer ran low, likely causing a gap in the output sound.
+
+//! RtAudio callback function prototype.
+/*!
+ All RtAudio clients must create a function of type RtAudioCallback
+ to read and/or write data from/to the audio stream. When the
+ underlying audio system is ready for new input or output data, this
+ function will be invoked.
+
+ \param outputBuffer For output (or duplex) streams, the client
+ should write \c nFrames of audio sample frames into this
+ buffer. This argument should be recast to the datatype
+ specified when the stream was opened. For input-only
+ streams, this argument will be NULL.
+
+ \param inputBuffer For input (or duplex) streams, this buffer will
+ hold \c nFrames of input audio sample frames. This
+ argument should be recast to the datatype specified when the
+ stream was opened. For output-only streams, this argument
+ will be NULL.
+
+ \param nFrames The number of sample frames of input or output
+ data in the buffers. The actual buffer size in bytes is
+ dependent on the data type and number of channels in use.
+
+ \param streamTime The number of seconds that have elapsed since the
+ stream was started.
+
+ \param status If non-zero, this argument indicates a data overflow
+ or underflow condition for the stream. The particular
+ condition can be determined by comparison with the
+ RtAudioStreamStatus flags.
+
+ \param userData A pointer to optional data provided by the client
+ when opening the stream (default = NULL).
+
+ To continue normal stream operation, the RtAudioCallback function
+ should return a value of zero. To stop the stream and drain the
+ output buffer, the function should return a value of one. To abort
+ the stream immediately, the client should return a value of two.
+ */
+typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,
+ unsigned int nFrames,
+ double streamTime,
+ RtAudioStreamStatus status,
+ void *userData );
+
+
+// **************************************************************** //
+//
+// RtAudio class declaration.
+//
+// RtAudio is a "controller" used to select an available audio i/o
+// interface. It presents a common API for the user to call but all
+// functionality is implemented by the class RtApi and its
+// subclasses. RtAudio creates an instance of an RtApi subclass
+// based on the user's API choice. If no choice is made, RtAudio
+// attempts to make a "logical" API selection.
+//
+// **************************************************************** //
+
+class RtApi;
+
+class RtAudio
+{
+ public:
+
+ //! Audio API specifier arguments.
+ enum Api {
+ UNSPECIFIED, /*!< Search for a working compiled API. */
+ LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */
+ LINUX_OSS, /*!< The Linux Open Sound System API. */
+ UNIX_JACK, /*!< The Jack Low-Latency Audio Server API. */
+ MACOSX_CORE, /*!< Macintosh OS-X Core Audio API. */
+ WINDOWS_ASIO, /*!< The Steinberg Audio Stream I/O API. */
+ WINDOWS_DS, /*!< The Microsoft Direct Sound API. */
+ RTAUDIO_DUMMY /*!< A compilable but non-functional API. */
+ };
+
+ //! The public device information structure for returning queried values.
+ struct DeviceInfo {
+ bool probed; /*!< true if the device capabilities were successfully probed. */
+ std::string name; /*!< Character string device identifier. */
+ unsigned int outputChannels; /*!< Maximum output channels supported by device. */
+ unsigned int inputChannels; /*!< Maximum input channels supported by device. */
+ unsigned int duplexChannels; /*!< Maximum simultaneous input/output channels supported by device. */
+ bool isDefaultOutput; /*!< true if this is the default output device. */
+ bool isDefaultInput; /*!< true if this is the default input device. */
+ std::vector sampleRates; /*!< Supported sample rates (queried from list of standard rates). */
+ RtAudioFormat nativeFormats; /*!< Bit mask of supported data formats. */
+
+ // Default constructor.
+ DeviceInfo()
+ :probed(false), outputChannels(0), inputChannels(0), duplexChannels(0),
+ isDefaultOutput(false), isDefaultInput(false), nativeFormats(0) {}
+ };
+
+ //! The structure for specifying input or ouput stream parameters.
+ struct StreamParameters {
+ unsigned int deviceId; /*!< Device index (0 to getDeviceCount() - 1). */
+ unsigned int nChannels; /*!< Number of channels. */
+ unsigned int firstChannel; /*!< First channel index on device (default = 0). */
+
+ // Default constructor.
+ StreamParameters()
+ : deviceId(0), nChannels(0), firstChannel(0) {}
+ };
+
+ //! The structure for specifying stream options.
+ /*!
+ The following flags can be OR'ed together to allow a client to
+ make changes to the default stream behavior:
+
+ - \e RTAUDIO_NONINTERLEAVED: Use non-interleaved buffers (default = interleaved).
+ - \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency.
+ - \e RTAUDIO_HOG_DEVICE: Attempt grab device for exclusive use.
+
+ By default, RtAudio streams pass and receive audio data from the
+ client in an interleaved format. By passing the
+ RTAUDIO_NONINTERLEAVED flag to the openStream() function, audio
+ data will instead be presented in non-interleaved buffers. In
+ this case, each buffer argument in the RtAudioCallback function
+ will point to a single array of data, with \c nFrames samples for
+ each channel concatenated back-to-back. For example, the first
+ sample of data for the second channel would be located at index \c
+ nFrames (assuming the \c buffer pointer was recast to the correct
+ data type for the stream).
+
+ Certain audio APIs offer a number of parameters that influence the
+ I/O latency of a stream. By default, RtAudio will attempt to set
+ these parameters internally for robust (glitch-free) performance
+ (though some APIs, like Windows Direct Sound, make this difficult).
+ By passing the RTAUDIO_MINIMIZE_LATENCY flag to the openStream()
+ function, internal stream settings will be influenced in an attempt
+ to minimize stream latency, though possibly at the expense of stream
+ performance.
+
+ If the RTAUDIO_HOG_DEVICE flag is set, RtAudio will attempt to
+ open the input and/or output stream device(s) for exclusive use.
+ Note that this is not possible with all supported audio APIs.
+
+ The \c numberOfBuffers parameter can be used to control stream
+ latency in the Windows DirectSound, Linux OSS, and Linux Alsa APIs
+ only. A value of two is usually the smallest allowed. Larger
+ numbers can potentially result in more robust stream performance,
+ though likely at the cost of stream latency. The value set by the
+ user is replaced during execution of the RtAudio::openStream()
+ function by the value actually used by the system.
+
+ The \c streamName parameter can be used to set the client name
+ when using the Jack API. By default, the client name is set to
+ RtApiJack. However, if you wish to create multiple instances of
+ RtAudio with Jack, each instance must have a unique client name.
+ */
+ struct StreamOptions {
+ RtAudioStreamFlags flags; /*!< A bit-mask of stream flags (RTAUDIO_NONINTERLEAVED, RTAUDIO_MINIMIZE_LATENCY, RTAUDIO_HOG_DEVICE). */
+ unsigned int numberOfBuffers; /*!< Number of stream buffers. */
+ std::string streamName; /*!< A stream name (currently used only in Jack). */
+
+ // Default constructor.
+ StreamOptions()
+ : flags(0), numberOfBuffers(0) {}
+ };
+
+ //! A static function to determine the available compiled audio APIs.
+ /*!
+ The values returned in the std::vector can be compared against
+ the enumerated list values. Note that there can be more than one
+ API compiled for certain operating systems.
+ */
+ static void getCompiledApi( std::vector &apis ) throw();
+
+ //! The class constructor.
+ /*!
+ The constructor performs minor initialization tasks. No exceptions
+ can be thrown.
+
+ If no API argument is specified and multiple API support has been
+ compiled, the default order of use is JACK, ALSA, OSS (Linux
+ systems) and ASIO, DS (Windows systems).
+ */
+ RtAudio( RtAudio::Api api=UNSPECIFIED ) throw();
+
+ //! The destructor.
+ /*!
+ If a stream is running or open, it will be stopped and closed
+ automatically.
+ */
+ ~RtAudio() throw();
+
+ //! Returns the audio API specifier for the current instance of RtAudio.
+ RtAudio::Api getCurrentApi( void ) throw();
+
+ //! A public function that queries for the number of audio devices available.
+ /*!
+ This function performs a system query of available devices each time it
+ is called, thus supporting devices connected \e after instantiation. If
+ a system error occurs during processing, a warning will be issued.
+ */
+ unsigned int getDeviceCount( void ) throw();
+
+ //! Return an RtAudio::DeviceInfo structure for a specified device number.
+ /*!
+
+ Any device integer between 0 and getDeviceCount() - 1 is valid.
+ If an invalid argument is provided, an RtError (type = INVALID_USE)
+ will be thrown. If a device is busy or otherwise unavailable, the
+ structure member "probed" will have a value of "false" and all
+ other members are undefined. If the specified device is the
+ current default input or output device, the corresponding
+ "isDefault" member will have a value of "true".
+ */
+ RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
+
+ //! A function that returns the index of the default output device.
+ /*!
+ If the underlying audio API does not provide a "default
+ device", or if no devices are available, the return value will be
+ 0. Note that this is a valid device identifier and it is the
+ client's responsibility to verify that a device is available
+ before attempting to open a stream.
+ */
+ unsigned int getDefaultOutputDevice( void ) throw();
+
+ //! A function that returns the index of the default input device.
+ /*!
+ If the underlying audio API does not provide a "default
+ device", or if no devices are available, the return value will be
+ 0. Note that this is a valid device identifier and it is the
+ client's responsibility to verify that a device is available
+ before attempting to open a stream.
+ */
+ unsigned int getDefaultInputDevice( void ) throw();
+
+ //! A public function for opening a stream with the specified parameters.
+ /*!
+ An RtError (type = SYSTEM_ERROR) is thrown if a stream cannot be
+ opened with the specified parameters or an error occurs during
+ processing. An RtError (type = INVALID_USE) is thrown if any
+ invalid device ID or channel number parameters are specified.
+
+ \param outputParameters Specifies output stream parameters to use
+ when opening a stream, including a device ID, number of channels,
+ and starting channel number. For input-only streams, this
+ argument should be NULL. The device ID is an index value between
+ 0 and getDeviceCount() - 1.
+ \param inputParameters Specifies input stream parameters to use
+ when opening a stream, including a device ID, number of channels,
+ and starting channel number. For output-only streams, this
+ argument should be NULL. The device ID is an index value between
+ 0 and getDeviceCount() - 1.
+ \param format An RtAudioFormat specifying the desired sample data format.
+ \param sampleRate The desired sample rate (sample frames per second).
+ \param *bufferFrames A pointer to a value indicating the desired
+ internal buffer size in sample frames. The actual value
+ used by the device is returned via the same pointer. A
+ value of zero can be specified, in which case the lowest
+ allowable value is determined.
+ \param callback A client-defined function that will be invoked
+ when input data is available and/or output data is needed.
+ \param userData An optional pointer to data that can be accessed
+ from within the callback function.
+ \param options An optional pointer to a structure containing various
+ global stream options, including a list of OR'ed RtAudioStreamFlags
+ and a suggested number of stream buffers that can be used to
+ control stream latency. More buffers typically result in more
+ robust performance, though at a cost of greater latency. If a
+ value of zero is specified, a system-specific median value is
+ chosen. If the RTAUDIO_MINIMIZE_LATENCY flag bit is set, the
+ lowest allowable value is used. The actual value used is
+ returned via the structure argument. The parameter is API dependent.
+ */
+ void openStream( RtAudio::StreamParameters *outputParameters,
+ RtAudio::StreamParameters *inputParameters,
+ RtAudioFormat format, unsigned int sampleRate,
+ unsigned int *bufferFrames, RtAudioCallback callback,
+ void *userData = NULL, RtAudio::StreamOptions *options = NULL );
+
+ //! A function that closes a stream and frees any associated stream memory.
+ /*!
+ If a stream is not open, this function issues a warning and
+ returns (no exception is thrown).
+ */
+ void closeStream( void ) throw();
+
+ //! A function that starts a stream.
+ /*!
+ An RtError (type = SYSTEM_ERROR) is thrown if an error occurs
+ during processing. An RtError (type = INVALID_USE) is thrown if a
+ stream is not open. A warning is issued if the stream is already
+ running.
+ */
+ void startStream( void );
+
+ //! Stop a stream, allowing any samples remaining in the output queue to be played.
+ /*!
+ An RtError (type = SYSTEM_ERROR) is thrown if an error occurs
+ during processing. An RtError (type = INVALID_USE) is thrown if a
+ stream is not open. A warning is issued if the stream is already
+ stopped.
+ */
+ void stopStream( void );
+
+ //! Stop a stream, discarding any samples remaining in the input/output queue.
+ /*!
+ An RtError (type = SYSTEM_ERROR) is thrown if an error occurs
+ during processing. An RtError (type = INVALID_USE) is thrown if a
+ stream is not open. A warning is issued if the stream is already
+ stopped.
+ */
+ void abortStream( void );
+
+ //! Returns true if a stream is open and false if not.
+ bool isStreamOpen( void ) throw();
+
+ //! Returns true if the stream is running and false if it is stopped or not open.
+ bool isStreamRunning( void ) throw();
+
+ //! Returns the number of elapsed seconds since the stream was started.
+ /*!
+ If a stream is not open, an RtError (type = INVALID_USE) will be thrown.
+ */
+ double getStreamTime( void );
+
+ //! Returns the internal stream latency in sample frames.
+ /*!
+ The stream latency refers to delay in audio input and/or output
+ caused by internal buffering by the audio system and/or hardware.
+ For duplex streams, the returned value will represent the sum of
+ the input and output latencies. If a stream is not open, an
+ RtError (type = INVALID_USE) will be thrown. If the API does not
+ report latency, the return value will be zero.
+ */
+ long getStreamLatency( void );
+
+ //! Specify whether warning messages should be printed to stderr.
+ void showWarnings( bool value = true ) throw();
+
+ protected:
+
+ void openRtApi( RtAudio::Api api );
+ RtApi *rtapi_;
+};
// Operating system dependent thread functionality.
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
@@ -54,12 +479,19 @@
typedef unsigned long ThreadHandle;
typedef CRITICAL_SECTION StreamMutex;
-#else // Various unix flavors with pthread support.
+#elif defined(__LINUX_ALSA__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__)
+ // Using pthread library for various flavors of unix.
#include
typedef pthread_t ThreadHandle;
typedef pthread_mutex_t StreamMutex;
+#else // Setup for "dummy" behavior
+
+ #define __RTAUDIO_DUMMY__
+ typedef int ThreadHandle;
+ typedef int StreamMutex;
+
#endif
// This global structure type is used to pass callback information
@@ -68,54 +500,23 @@
struct CallbackInfo {
void *object; // Used as a "this" pointer.
ThreadHandle thread;
- bool usingCallback;
void *callback;
void *userData;
void *apiInfo; // void pointer for API specific callback information
+ bool isRunning;
// Default constructor.
CallbackInfo()
- :object(0), usingCallback(false), callback(0),
- userData(0), apiInfo(0) {}
-};
-
-// Support for signed integers and floats. Audio data fed to/from
-// the tickStream() routine is assumed to ALWAYS be in host
-// byte order. The internal routines will automatically take care of
-// any necessary byte-swapping between the host format and the
-// soundcard. Thus, endian-ness is not a concern in the following
-// format definitions.
-typedef unsigned long RtAudioFormat;
-static const RtAudioFormat RTAUDIO_SINT8 = 0x1; /*!< 8-bit signed integer. */
-static const RtAudioFormat RTAUDIO_SINT16 = 0x2; /*!< 16-bit signed integer. */
-static const RtAudioFormat RTAUDIO_SINT24 = 0x4; /*!< Upper 3 bytes of 32-bit signed integer. */
-static const RtAudioFormat RTAUDIO_SINT32 = 0x8; /*!< 32-bit signed integer. */
-static const RtAudioFormat RTAUDIO_FLOAT32 = 0x10; /*!< Normalized between plus/minus 1.0. */
-static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; /*!< Normalized between plus/minus 1.0. */
-
-typedef int (*RtAudioCallback)(char *buffer, int bufferSize, void *userData);
-
-//! The public device information structure for returning queried values.
-struct RtAudioDeviceInfo {
- std::string name; /*!< Character string device identifier. */
- bool probed; /*!< true if the device capabilities were successfully probed. */
- int outputChannels; /*!< Maximum output channels supported by device. */
- int inputChannels; /*!< Maximum input channels supported by device. */
- int duplexChannels; /*!< Maximum simultaneous input/output channels supported by device. */
- bool isDefault; /*!< true if this is the default output or input device. */
- std::vector sampleRates; /*!< Supported sample rates (queried from list of standard rates). */
- RtAudioFormat nativeFormats; /*!< Bit mask of supported data formats. */
-
- // Default constructor.
- RtAudioDeviceInfo()
- :probed(false), outputChannels(0), inputChannels(0),
- duplexChannels(0), isDefault(false), nativeFormats(0) {}
+ :object(0), callback(0), userData(0), apiInfo(0), isRunning(false) {}
};
// **************************************************************** //
//
// RtApi class declaration.
//
+// Subclasses of RtApi contain all API- and OS-specific code necessary
+// to fully implement the RtAudio API.
+//
// Note that RtApi is an abstract base class and cannot be
// explicitly instantiated. The class RtAudio will create an
// instance of an RtApi subclass (RtApiOss, RtApiAlsa,
@@ -123,36 +524,38 @@ struct RtAudioDeviceInfo {
//
// **************************************************************** //
+#if defined( HAVE_GETTIMEOFDAY )
+ #include
+#endif
+
+#include
+
class RtApi
{
public:
- enum StreamState {
- STREAM_STOPPED,
- STREAM_RUNNING
- };
-
RtApi();
virtual ~RtApi();
- void openStream( int outputDevice, int outputChannels,
- int inputDevice, int inputChannels,
- RtAudioFormat format, int sampleRate,
- int *bufferSize, int numberOfBuffers );
- void openStream( int outputDevice, int outputChannels,
- int inputDevice, int inputChannels,
- RtAudioFormat format, int sampleRate,
- int *bufferSize, int *numberOfBuffers );
- virtual void setStreamCallback( RtAudioCallback callback, void *userData ) = 0;
- virtual void cancelStreamCallback() = 0;
- int getDeviceCount(void);
- RtAudioDeviceInfo getDeviceInfo( int device );
- char * const getStreamBuffer();
- RtApi::StreamState getStreamState() const;
- virtual void tickStream() = 0;
- virtual void closeStream();
- virtual void startStream() = 0;
- virtual void stopStream() = 0;
- virtual void abortStream() = 0;
+ virtual RtAudio::Api getCurrentApi( void ) = 0;
+ virtual unsigned int getDeviceCount( void ) = 0;
+ virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0;
+ virtual unsigned int getDefaultInputDevice( void );
+ virtual unsigned int getDefaultOutputDevice( void );
+ void openStream( RtAudio::StreamParameters *outputParameters,
+ RtAudio::StreamParameters *inputParameters,
+ RtAudioFormat format, unsigned int sampleRate,
+ unsigned int *bufferFrames, RtAudioCallback callback,
+ void *userData, RtAudio::StreamOptions *options );
+ virtual void closeStream( void );
+ virtual void startStream( void ) = 0;
+ virtual void stopStream( void ) = 0;
+ virtual void abortStream( void ) = 0;
+ long getStreamLatency( void );
+ virtual double getStreamTime( void );
+ bool isStreamOpen( void ) { return stream_.state != STREAM_CLOSED; };
+ bool isStreamRunning( void ) { return stream_.state == STREAM_RUNNING; };
+ void showWarnings( bool value ) { showWarnings_ = value; };
+
protected:
@@ -161,6 +564,12 @@ protected:
enum { FAILURE, SUCCESS };
+ enum StreamState {
+ STREAM_STOPPED,
+ STREAM_RUNNING,
+ STREAM_CLOSED = -50
+ };
+
enum StreamMode {
OUTPUT,
INPUT,
@@ -179,51 +588,36 @@ protected:
// A protected structure for audio streams.
struct RtApiStream {
- int device[2]; // Playback and record, respectively.
- void *apiHandle; // void pointer for API specific stream handle information
- StreamMode mode; // OUTPUT, INPUT, or DUPLEX.
- StreamState state; // STOPPED or RUNNING
- char *userBuffer;
+ unsigned int device[2]; // Playback and record, respectively.
+ void *apiHandle; // void pointer for API specific stream handle information
+ StreamMode mode; // OUTPUT, INPUT, or DUPLEX.
+ StreamState state; // STOPPED, RUNNING, or CLOSED
+ char *userBuffer[2]; // Playback and record, respectively.
char *deviceBuffer;
- bool doConvertBuffer[2]; // Playback and record, respectively.
- bool deInterleave[2]; // Playback and record, respectively.
- bool doByteSwap[2]; // Playback and record, respectively.
- int sampleRate;
- int bufferSize;
- int nBuffers;
- int nUserChannels[2]; // Playback and record, respectively.
- int nDeviceChannels[2]; // Playback and record channels, respectively.
+ bool doConvertBuffer[2]; // Playback and record, respectively.
+ bool userInterleaved;
+ bool deviceInterleaved[2]; // Playback and record, respectively.
+ bool doByteSwap[2]; // Playback and record, respectively.
+ unsigned int sampleRate;
+ unsigned int bufferSize;
+ unsigned int nBuffers;
+ unsigned int nUserChannels[2]; // Playback and record, respectively.
+ unsigned int nDeviceChannels[2]; // Playback and record channels, respectively.
+ unsigned int channelOffset[2]; // Playback and record, respectively.
+ unsigned long latency[2]; // Playback and record, respectively.
RtAudioFormat userFormat;
- RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
+ RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
StreamMutex mutex;
CallbackInfo callbackInfo;
ConvertInfo convertInfo[2];
+ double streamTime; // Number of elapsed seconds since the stream started.
+
+#if defined(HAVE_GETTIMEOFDAY)
+ struct timeval lastTickTimestamp;
+#endif
RtApiStream()
- :apiHandle(0), userBuffer(0), deviceBuffer(0) {}
- };
-
- // A protected device structure for audio devices.
- struct RtApiDevice {
- std::string name; /*!< Character string device identifier. */
- bool probed; /*!< true if the device capabilities were successfully probed. */
- void *apiDeviceId; // void pointer for API specific device information
- int maxOutputChannels; /*!< Maximum output channels supported by device. */
- int maxInputChannels; /*!< Maximum input channels supported by device. */
- int maxDuplexChannels; /*!< Maximum simultaneous input/output channels supported by device. */
- int minOutputChannels; /*!< Minimum output channels supported by device. */
- int minInputChannels; /*!< Minimum input channels supported by device. */
- int minDuplexChannels; /*!< Minimum simultaneous input/output channels supported by device. */
- bool hasDuplexSupport; /*!< true if device supports duplex mode. */
- bool isDefault; /*!< true if this is the default output or input device. */
- std::vector sampleRates; /*!< Supported sample rates. */
- RtAudioFormat nativeFormats; /*!< Bit mask of supported data formats. */
-
- // Default constructor.
- RtApiDevice()
- :probed(false), apiDeviceId(0), maxOutputChannels(0), maxInputChannels(0),
- maxDuplexChannels(0), minOutputChannels(0), minInputChannels(0),
- minDuplexChannels(0), isDefault(false), nativeFormats(0) {}
+ :apiHandle(0), deviceBuffer(0) {}
};
typedef signed short Int16;
@@ -231,66 +625,38 @@ protected:
typedef float Float32;
typedef double Float64;
- char message_[1024];
- int nDevices_;
- std::vector devices_;
+ std::ostringstream errorStream_;
+ std::string errorText_;
+ bool showWarnings_;
RtApiStream stream_;
/*!
- Protected, api-specific method to count and identify the system
- audio devices. This function MUST be implemented by all subclasses.
- */
- virtual void initialize(void) = 0;
-
- /*!
- Protected, api-specific method which attempts to fill an
- RtAudioDevice structure for a given device. This function MUST be
- implemented by all subclasses. If an error is encountered during
- the probe, a "warning" message is reported and the value of
- "probed" remains false (no exception is thrown). A successful
- probe is indicated by probed = true.
- */
- virtual void probeDeviceInfo( RtApiDevice *info );
-
- /*!
- Protected, api-specific method which attempts to open a device
+ Protected, api-specific method that attempts to open a device
with the given parameters. This function MUST be implemented by
all subclasses. If an error is encountered during the probe, a
- "warning" message is reported and FAILURE is returned (no
- exception is thrown). A successful probe is indicated by a return
- value of SUCCESS.
+ "warning" message is reported and FAILURE is returned. A
+ successful probe is indicated by a return value of SUCCESS.
*/
- virtual bool probeDeviceOpen( int device, StreamMode mode, int channels,
- int sampleRate, RtAudioFormat format,
- int *bufferSize, int numberOfBuffers );
+ virtual bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
+ unsigned int firstChannel, unsigned int sampleRate,
+ RtAudioFormat format, unsigned int *bufferSize,
+ RtAudio::StreamOptions *options );
- /*!
- Protected method which returns the index in the devices array to
- the default input device.
- */
- virtual int getDefaultInputDevice(void);
-
- /*!
- Protected method which returns the index in the devices array to
- the default output device.
- */
- virtual int getDefaultOutputDevice(void);
-
- //! Protected common method to clear an RtApiDevice structure.
- void clearDeviceInfo( RtApiDevice *info );
+ //! A protected function used to increment the stream time.
+ void tickStreamTime( void );
//! Protected common method to clear an RtApiStream structure.
void clearStreamInfo();
+ /*!
+ Protected common method that throws an RtError (type =
+ INVALID_USE) if a stream is not open.
+ */
+ void verifyStream( void );
+
//! Protected common error method to allow global control over error handling.
void error( RtError::Type type );
- /*!
- Protected common method used to check whether a stream is open.
- If not, an "invalid identifier" exception is thrown.
- */
- void verifyStream();
-
/*!
Protected method used to perform format, channel number, and/or interleaving
conversions between the user and device buffers.
@@ -298,328 +664,38 @@ protected:
void convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info );
//! Protected common method used to perform byte-swapping on buffers.
- void byteSwapBuffer( char *buffer, int samples, RtAudioFormat format );
+ void byteSwapBuffer( char *buffer, unsigned int samples, RtAudioFormat format );
- //! Protected common method which returns the number of bytes for a given format.
- int formatBytes( RtAudioFormat format );
+ //! Protected common method that returns the number of bytes for a given format.
+ unsigned int formatBytes( RtAudioFormat format );
+
+ //! Protected common method that sets up the parameters for buffer conversion.
+ void setConvertInfo( StreamMode mode, unsigned int firstChannel );
};
-
// **************************************************************** //
//
-// RtAudio class declaration.
-//
-// RtAudio is a "controller" used to select an available audio i/o
-// interface. It presents a common API for the user to call but all
-// functionality is implemented by the class RtAudioApi and its
-// subclasses. RtAudio creates an instance of an RtAudioApi subclass
-// based on the user's API choice. If no choice is made, RtAudio
-// attempts to make a "logical" API selection.
+// Inline RtAudio definitions.
//
// **************************************************************** //
-class RtAudio
-{
-public:
-
- //! Audio API specifier arguments.
- enum RtAudioApi {
- UNSPECIFIED, /*!< Search for a working compiled API. */
- LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */
- LINUX_OSS, /*!< The Linux Open Sound System API. */
- LINUX_JACK, /*!< The Linux Jack Low-Latency Audio Server API. */
- MACOSX_CORE, /*!< Macintosh OS-X Core Audio API. */
- IRIX_AL, /*!< The Irix Audio Library API. */
- WINDOWS_ASIO, /*!< The Steinberg Audio Stream I/O API. */
- WINDOWS_DS /*!< The Microsoft Direct Sound API. */
- };
-
- //! The default class constructor.
- /*!
- Probes the system to make sure at least one audio input/output
- device is available and determines the api-specific identifier for
- each device found. An RtError error can be thrown if no devices
- are found or if a memory allocation error occurs.
-
- If no API argument is specified and multiple API support has been
- compiled, the default order of use is JACK, ALSA, OSS (Linux
- systems) and ASIO, DS (Windows systems).
- */
- RtAudio( RtAudioApi api=UNSPECIFIED );
-
- //! A constructor which can be used to open a stream during instantiation.
- /*!
- The specified output and/or input device identifiers correspond
- to those enumerated via the getDeviceInfo() method. If device =
- 0, the default or first available devices meeting the given
- parameters is selected. If an output or input channel value is
- zero, the corresponding device value is ignored. When a stream is
- successfully opened, its identifier is returned via the "streamId"
- pointer. An RtError can be thrown if no devices are found
- for the given parameters, if a memory allocation error occurs, or
- if a driver error occurs. \sa openStream()
- */
- RtAudio( int outputDevice, int outputChannels,
- int inputDevice, int inputChannels,
- RtAudioFormat format, int sampleRate,
- int *bufferSize, int numberOfBuffers, RtAudioApi api=UNSPECIFIED );
-
- //! An overloaded constructor which opens a stream and also returns \c numberOfBuffers parameter via pointer argument.
- /*!
- See the previous constructor call for details. This overloaded
- version differs only in that it takes a pointer argument for the
- \c numberOfBuffers parameter and returns the value used by the
- audio device (which may be different from that requested). Note
- that the \c numberofBuffers parameter is not used with the Linux
- Jack, Macintosh CoreAudio, and Windows ASIO APIs.
- */
- RtAudio( int outputDevice, int outputChannels,
- int inputDevice, int inputChannels,
- RtAudioFormat format, int sampleRate,
- int *bufferSize, int *numberOfBuffers, RtAudioApi api=UNSPECIFIED );
-
- //! The destructor.
- /*!
- Stops and closes an open stream and devices and deallocates
- buffer and structure memory.
- */
- ~RtAudio();
-
- //! A public method for opening a stream with the specified parameters.
- /*!
- An RtError is thrown if a stream cannot be opened.
-
- \param outputDevice: If equal to 0, the default or first device
- found meeting the given parameters is opened. Otherwise, the
- device number should correspond to one of those enumerated via
- the getDeviceInfo() method.
- \param outputChannels: The desired number of output channels. If
- equal to zero, the outputDevice identifier is ignored.
- \param inputDevice: If equal to 0, the default or first device
- found meeting the given parameters is opened. Otherwise, the
- device number should correspond to one of those enumerated via
- the getDeviceInfo() method.
- \param inputChannels: The desired number of input channels. If
- equal to zero, the inputDevice identifier is ignored.
- \param format: An RtAudioFormat specifying the desired sample data format.
- \param sampleRate: The desired sample rate (sample frames per second).
- \param *bufferSize: A pointer value indicating the desired internal buffer
- size in sample frames. The actual value used by the device is
- returned via the same pointer. A value of zero can be specified,
- in which case the lowest allowable value is determined.
- \param numberOfBuffers: A value which can be used to help control device
- latency. More buffers typically result in more robust performance,
- though at a cost of greater latency. A value of zero can be
- specified, in which case the lowest allowable value is used.
- */
- void openStream( int outputDevice, int outputChannels,
- int inputDevice, int inputChannels,
- RtAudioFormat format, int sampleRate,
- int *bufferSize, int numberOfBuffers );
-
- //! A public method for opening a stream and also returning \c numberOfBuffers parameter via pointer argument.
- /*!
- See the previous function call for details. This overloaded
- version differs only in that it takes a pointer argument for the
- \c numberOfBuffers parameter and returns the value used by the
- audio device (which may be different from that requested). Note
- that the \c numberofBuffers parameter is not used with the Linux
- Jack, Macintosh CoreAudio, and Windows ASIO APIs.
- */
- void openStream( int outputDevice, int outputChannels,
- int inputDevice, int inputChannels,
- RtAudioFormat format, int sampleRate,
- int *bufferSize, int *numberOfBuffers );
-
- //! A public method which sets a user-defined callback function for a given stream.
- /*!
- This method assigns a callback function to a previously opened
- stream for non-blocking stream functionality. A separate process
- is initiated, though the user function is called only when the
- stream is "running" (between calls to the startStream() and
- stopStream() methods, respectively). The callback process remains
- active for the duration of the stream and is automatically
- shutdown when the stream is closed (via the closeStream() method
- or by object destruction). The callback process can also be
- shutdown and the user function de-referenced through an explicit
- call to the cancelStreamCallback() method. Note that the stream
- can use only blocking or callback functionality at a particular
- time, though it is possible to alternate modes on the same stream
- through the use of the setStreamCallback() and
- cancelStreamCallback() methods (the blocking tickStream() method
- can be used before a callback is set and/or after a callback is
- cancelled). An RtError will be thrown if called when no stream is
- open or a thread errors occurs.
- */
- void setStreamCallback(RtAudioCallback callback, void *userData) { rtapi_->setStreamCallback( callback, userData ); };
-
- //! A public method which cancels a callback process and function for the stream.
- /*!
- This method shuts down a callback process and de-references the
- user function for the stream. Callback functionality can
- subsequently be restarted on the stream via the
- setStreamCallback() method. An RtError will be thrown if called
- when no stream is open.
- */
- void cancelStreamCallback() { rtapi_->cancelStreamCallback(); };
-
- //! A public method which returns the number of audio devices found.
- int getDeviceCount(void) { return rtapi_->getDeviceCount(); };
-
- //! Return an RtAudioDeviceInfo structure for a specified device number.
- /*!
- Any device integer between 1 and getDeviceCount() is valid. If
- a device is busy or otherwise unavailable, the structure member
- "probed" will have a value of "false" and all other members are
- undefined. If the specified device is the current default input
- or output device, the "isDefault" member will have a value of
- "true". An RtError will be thrown for an invalid device argument.
- */
- RtAudioDeviceInfo getDeviceInfo(int device) { return rtapi_->getDeviceInfo( device ); };
-
- //! A public method which returns a pointer to the buffer for an open stream.
- /*!
- The user should fill and/or read the buffer data in interleaved format
- and then call the tickStream() method. An RtError will be
- thrown if called when no stream is open.
- */
- char * const getStreamBuffer() { return rtapi_->getStreamBuffer(); };
-
- //! Public method used to trigger processing of input/output data for a stream.
- /*!
- This method blocks until all buffer data is read/written. An
- RtError will be thrown if a driver error occurs or if called when
- no stream is open.
- */
- void tickStream() { rtapi_->tickStream(); };
-
- //! Public method which closes a stream and frees any associated buffers.
- /*!
- If a stream is not open, this method issues a warning and
- returns (an RtError is not thrown).
- */
- void closeStream() { rtapi_->closeStream(); };
-
- //! Public method which starts a stream.
- /*!
- An RtError will be thrown if a driver error occurs or if called
- when no stream is open.
- */
- void startStream() { rtapi_->startStream(); };
-
- //! Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.
- /*!
- An RtError will be thrown if a driver error occurs or if called
- when no stream is open.
- */
- void stopStream() { rtapi_->stopStream(); };
-
- //! Stop a stream, discarding any samples remaining in the input/output queue.
- /*!
- An RtError will be thrown if a driver error occurs or if called
- when no stream is open.
- */
- void abortStream() { rtapi_->abortStream(); };
-
-
- protected:
-
- void initialize( RtAudioApi api );
-
- RtApi *rtapi_;
-};
-
+inline RtAudio::Api RtAudio :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); };
+inline unsigned int RtAudio :: getDeviceCount( void ) throw() { return rtapi_->getDeviceCount(); };
+inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); };
+inline unsigned int RtAudio :: getDefaultInputDevice( void ) throw() { return rtapi_->getDefaultInputDevice(); };
+inline unsigned int RtAudio :: getDefaultOutputDevice( void ) throw() { return rtapi_->getDefaultOutputDevice(); };
+inline void RtAudio :: closeStream( void ) throw() { return rtapi_->closeStream(); };
+inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); };
+inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); };
+inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); };
+inline bool RtAudio :: isStreamOpen( void ) throw() { return rtapi_->isStreamOpen(); };
+inline bool RtAudio :: isStreamRunning( void ) throw() { return rtapi_->isStreamRunning(); };
+inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); };
+inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); };
+inline void RtAudio :: showWarnings( bool value ) throw() { rtapi_->showWarnings( value ); };
// RtApi Subclass prototypes.
-#if defined(__LINUX_ALSA__)
-
-class RtApiAlsa: public RtApi
-{
-public:
-
- RtApiAlsa();
- ~RtApiAlsa();
- void tickStream();
- void closeStream();
- void startStream();
- void stopStream();
- void abortStream();
- int streamWillBlock();
- void setStreamCallback( RtAudioCallback callback, void *userData );
- void cancelStreamCallback();
-
- private:
-
- void initialize(void);
- void probeDeviceInfo( RtApiDevice *info );
- bool probeDeviceOpen( int device, StreamMode mode, int channels,
- int sampleRate, RtAudioFormat format,
- int *bufferSize, int numberOfBuffers );
-};
-
-#endif
-
-#if defined(__LINUX_JACK__)
-
-class RtApiJack: public RtApi
-{
-public:
-
- RtApiJack();
- ~RtApiJack();
- void tickStream();
- void closeStream();
- void startStream();
- void stopStream();
- void abortStream();
- void setStreamCallback( RtAudioCallback callback, void *userData );
- void cancelStreamCallback();
- // This function is intended for internal use only. It must be
- // public because it is called by the internal callback handler,
- // which is not a member of RtAudio. External use of this function
- // will most likely produce highly undesireable results!
- void callbackEvent( unsigned long nframes );
-
- private:
-
- void initialize(void);
- void probeDeviceInfo( RtApiDevice *info );
- bool probeDeviceOpen( int device, StreamMode mode, int channels,
- int sampleRate, RtAudioFormat format,
- int *bufferSize, int numberOfBuffers );
-};
-
-#endif
-
-#if defined(__LINUX_OSS__)
-
-class RtApiOss: public RtApi
-{
-public:
-
- RtApiOss();
- ~RtApiOss();
- void tickStream();
- void closeStream();
- void startStream();
- void stopStream();
- void abortStream();
- int streamWillBlock();
- void setStreamCallback( RtAudioCallback callback, void *userData );
- void cancelStreamCallback();
-
- private:
-
- void initialize(void);
- void probeDeviceInfo( RtApiDevice *info );
- bool probeDeviceOpen( int device, StreamMode mode, int channels,
- int sampleRate, RtAudioFormat format,
- int *bufferSize, int numberOfBuffers );
-};
-
-#endif
-
#if defined(__MACOSX_CORE__)
#include
@@ -630,112 +706,65 @@ public:
RtApiCore();
~RtApiCore();
- int getDefaultOutputDevice(void);
- int getDefaultInputDevice(void);
- void tickStream();
- void closeStream();
- void startStream();
- void stopStream();
- void abortStream();
- void setStreamCallback( RtAudioCallback callback, void *userData );
- void cancelStreamCallback();
+ RtAudio::Api getCurrentApi( void ) { return RtAudio::MACOSX_CORE; };
+ unsigned int getDeviceCount( void );
+ RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
+ unsigned int getDefaultOutputDevice( void );
+ unsigned int getDefaultInputDevice( void );
+ void closeStream( void );
+ void startStream( void );
+ void stopStream( void );
+ void abortStream( void );
+ long getStreamLatency( void );
// This function is intended for internal use only. It must be
// public because it is called by the internal callback handler,
// which is not a member of RtAudio. External use of this function
// will most likely produce highly undesireable results!
- void callbackEvent( AudioDeviceID deviceId, void *inData, void *outData );
+ bool callbackEvent( AudioDeviceID deviceId,
+ const AudioBufferList *inBufferList,
+ const AudioBufferList *outBufferList );
private:
- void initialize(void);
- void probeDeviceInfo( RtApiDevice *info );
- bool probeDeviceOpen( int device, StreamMode mode, int channels,
- int sampleRate, RtAudioFormat format,
- int *bufferSize, int numberOfBuffers );
+ bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
+ unsigned int firstChannel, unsigned int sampleRate,
+ RtAudioFormat format, unsigned int *bufferSize,
+ RtAudio::StreamOptions *options );
+ static const char* getErrorCode( OSStatus code );
};
#endif
-#if defined(__WINDOWS_DS__)
+#if defined(__UNIX_JACK__)
-class RtApiDs: public RtApi
+class RtApiJack: public RtApi
{
public:
- RtApiDs();
- ~RtApiDs();
- int getDefaultOutputDevice(void);
- int getDefaultInputDevice(void);
- void tickStream();
- void closeStream();
- void startStream();
- void stopStream();
- void abortStream();
- int streamWillBlock();
- void setStreamCallback( RtAudioCallback callback, void *userData );
- void cancelStreamCallback();
+ RtApiJack();
+ ~RtApiJack();
+ RtAudio::Api getCurrentApi( void ) { return RtAudio::UNIX_JACK; };
+ unsigned int getDeviceCount( void );
+ RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
+ void closeStream( void );
+ void startStream( void );
+ void stopStream( void );
+ void abortStream( void );
+ long getStreamLatency( void );
- public:
- // \brief Internal structure that provide debug information on the state of a running DSound device.
- struct RtDsStatistics {
- // \brief Sample Rate.
- long sampleRate;
- // \brief The size of one sample * number of channels on the input device.
- int inputFrameSize;
- // \brief The size of one sample * number of channels on the output device.
- int outputFrameSize;
- /* \brief The number of times the read pointer had to be adjusted to avoid reading from an unsafe buffer position.
- *
- * This field is only used when running in DUPLEX mode. INPUT mode devices just wait until the data is
- * available.
- */
- int numberOfReadOverruns;
- // \brief The number of times the write pointer had to be adjusted to avoid writing in an unsafe buffer position.
- int numberOfWriteUnderruns;
- // \brief Number of bytes by attribute to buffer configuration by which writing must lead the current write pointer.
- int writeDeviceBufferLeadBytes;
- // \brief Number of bytes by attributable to the device driver by which writing must lead the current write pointer on this output device.
- unsigned long writeDeviceSafeLeadBytes;
- // \brief Number of bytes by which reading must trail the current read pointer on this input device.
- unsigned long readDeviceSafeLeadBytes;
- /* \brief Estimated latency in seconds.
- *
- * For INPUT mode devices, based the latency of the device's safe read pointer, plus one buffer's
- * worth of additional latency.
- *
- * For OUTPUT mode devices, the latency of the device's safe write pointer, plus N buffers of
- * additional buffer latency.
- *
- * For DUPLEX devices, the sum of latencies for both input and output devices. DUPLEX devices
- * also back off the read pointers an additional amount in order to maintain synchronization
- * between out-of-phase read and write pointers. This time is also included.
- *
- * Note that most software packages report latency between the safe write pointer
- * and the software lead pointer, excluding the hardware device's safe write pointer
- * latency. Figures of 1 or 2ms of latency on Windows audio devices are invariably of this type.
- * The reality is that hardware devices often have latencies of 30ms or more (often much
- * higher for duplex operation).
- */
-
- double latency;
- };
- // \brief Report on the current state of a running DSound device.
- static RtDsStatistics getDsStatistics();
+ // This function is intended for internal use only. It must be
+ // public because it is called by the internal callback handler,
+ // which is not a member of RtAudio. External use of this function
+ // will most likely produce highly undesireable results!
+ bool callbackEvent( unsigned long nframes );
private:
- void initialize(void);
- void probeDeviceInfo( RtApiDevice *info );
- bool probeDeviceOpen( int device, StreamMode mode, int channels,
- int sampleRate, RtAudioFormat format,
- int *bufferSize, int numberOfBuffers );
-
- bool coInitialized;
- bool buffersRolling;
- long duplexPrerollBytes;
- static RtDsStatistics statistics;
-
+ bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
+ unsigned int firstChannel, unsigned int sampleRate,
+ RtAudioFormat format, unsigned int *bufferSize,
+ RtAudio::StreamOptions *options );
};
#endif
@@ -748,65 +777,166 @@ public:
RtApiAsio();
~RtApiAsio();
- void tickStream();
- void closeStream();
- void startStream();
- void stopStream();
- void abortStream();
- void setStreamCallback( RtAudioCallback callback, void *userData );
- void cancelStreamCallback();
+ RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_ASIO; };
+ unsigned int getDeviceCount( void );
+ RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
+ void closeStream( void );
+ void startStream( void );
+ void stopStream( void );
+ void abortStream( void );
+ long getStreamLatency( void );
// This function is intended for internal use only. It must be
// public because it is called by the internal callback handler,
// which is not a member of RtAudio. External use of this function
// will most likely produce highly undesireable results!
- void callbackEvent( long bufferIndex );
+ bool callbackEvent( long bufferIndex );
private:
- void initialize(void);
- void probeDeviceInfo( RtApiDevice *info );
- bool probeDeviceOpen( int device, StreamMode mode, int channels,
- int sampleRate, RtAudioFormat format,
- int *bufferSize, int numberOfBuffers );
-
- bool coInitialized;
-
+ bool coInitialized_;
+ bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
+ unsigned int firstChannel, unsigned int sampleRate,
+ RtAudioFormat format, unsigned int *bufferSize,
+ RtAudio::StreamOptions *options );
};
#endif
-#if defined(__IRIX_AL__)
+#if defined(__WINDOWS_DS__)
-class RtApiAl: public RtApi
+class RtApiDs: public RtApi
{
public:
- RtApiAl();
- ~RtApiAl();
- int getDefaultOutputDevice(void);
- int getDefaultInputDevice(void);
- void tickStream();
- void closeStream();
- void startStream();
- void stopStream();
- void abortStream();
- int streamWillBlock();
- void setStreamCallback( RtAudioCallback callback, void *userData );
- void cancelStreamCallback();
+ RtApiDs();
+ ~RtApiDs();
+ RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_DS; };
+ unsigned int getDeviceCount( void );
+ unsigned int getDefaultOutputDevice( void );
+ unsigned int getDefaultInputDevice( void );
+ RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
+ void closeStream( void );
+ void startStream( void );
+ void stopStream( void );
+ void abortStream( void );
+ long getStreamLatency( void );
+
+ // This function is intended for internal use only. It must be
+ // public because it is called by the internal callback handler,
+ // which is not a member of RtAudio. External use of this function
+ // will most likely produce highly undesireable results!
+ void callbackEvent( void );
private:
- void initialize(void);
- void probeDeviceInfo( RtApiDevice *info );
- bool probeDeviceOpen( int device, StreamMode mode, int channels,
- int sampleRate, RtAudioFormat format,
- int *bufferSize, int numberOfBuffers );
+ bool coInitialized_;
+ bool buffersRolling;
+ long duplexPrerollBytes;
+ bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
+ unsigned int firstChannel, unsigned int sampleRate,
+ RtAudioFormat format, unsigned int *bufferSize,
+ RtAudio::StreamOptions *options );
};
#endif
-// Define the following flag to have extra information spewed to stderr.
-//#define __RTAUDIO_DEBUG__
+#if defined(__LINUX_ALSA__)
+
+class RtApiAlsa: public RtApi
+{
+public:
+
+ RtApiAlsa();
+ ~RtApiAlsa();
+ RtAudio::Api getCurrentApi() { return RtAudio::LINUX_ALSA; };
+ unsigned int getDeviceCount( void );
+ RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
+ void closeStream( void );
+ void startStream( void );
+ void stopStream( void );
+ void abortStream( void );
+
+ // This function is intended for internal use only. It must be
+ // public because it is called by the internal callback handler,
+ // which is not a member of RtAudio. External use of this function
+ // will most likely produce highly undesireable results!
+ void callbackEvent( void );
+
+ private:
+
+ bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
+ unsigned int firstChannel, unsigned int sampleRate,
+ RtAudioFormat format, unsigned int *bufferSize,
+ RtAudio::StreamOptions *options );
+};
#endif
+
+#if defined(__LINUX_OSS__)
+
+class RtApiOss: public RtApi
+{
+public:
+
+ RtApiOss();
+ ~RtApiOss();
+ RtAudio::Api getCurrentApi() { return RtAudio::LINUX_OSS; };
+ unsigned int getDeviceCount( void );
+ RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
+ void closeStream( void );
+ void startStream( void );
+ void stopStream( void );
+ void abortStream( void );
+
+ // This function is intended for internal use only. It must be
+ // public because it is called by the internal callback handler,
+ // which is not a member of RtAudio. External use of this function
+ // will most likely produce highly undesireable results!
+ void callbackEvent( void );
+
+ private:
+
+ bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
+ unsigned int firstChannel, unsigned int sampleRate,
+ RtAudioFormat format, unsigned int *bufferSize,
+ RtAudio::StreamOptions *options );
+};
+
+#endif
+
+#if defined(__RTAUDIO_DUMMY__)
+
+class RtApiDummy: public RtApi
+{
+public:
+
+ RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( WARNING ); };
+ RtAudio::Api getCurrentApi( void ) { return RtAudio::RTAUDIO_DUMMY; };
+ unsigned int getDeviceCount( void ) { return 0; };
+ RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) { RtAudio::DeviceInfo info; return info; };
+ void closeStream( void ) {};
+ void startStream( void ) {};
+ void stopStream( void ) {};
+ void abortStream( void ) {};
+
+ private:
+
+ bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
+ unsigned int firstChannel, unsigned int sampleRate,
+ RtAudioFormat format, unsigned int *bufferSize,
+ RtAudio::StreamOptions *options ) { return false; };
+};
+
+#endif
+
+#endif
+
+// Indentation settings for Vim and Emacs
+//
+// Local Variables:
+// c-basic-offset: 2
+// indent-tabs-mode: nil
+// End:
+//
+// vim: et sts=2 sw=2
diff --git a/include/RtDuplex.h b/include/RtDuplex.h
deleted file mode 100644
index f8c2818..0000000
--- a/include/RtDuplex.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/***************************************************/
-/*! \class RtDuplex
- \brief STK realtime audio (blocking) input/output class.
-
- This class provides a simplified interface to
- RtAudio for realtime audio input/output. It
- may also be possible to achieve duplex
- operation using separate RtWvIn and RtWvOut
- classes, but this class ensures better
- input/output synchronization.
-
- Because this class makes use of RtAudio's
- blocking input/output routines, its
- performance is less robust on systems where
- the audio API is callback-based (Macintosh
- CoreAudio and Windows ASIO).
-
- RtDuplex supports multi-channel data in
- interleaved format. It is important to
- distinguish the tick() methods, which output
- single samples to all channels in a sample
- frame and return samples produced by averaging
- across sample frames, from the tickFrame()
- methods, which take/return pointers to
- multi-channel sample frames.
-
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
-*/
-/***************************************************/
-
-#ifndef STK_RTDUPLEX_H
-#define STK_RTDUPLEX_H
-
-#include "Stk.h"
-#include "RtAudio.h"
-
-class RtDuplex : public Stk
-{
-public:
- //! Default constructor.
- /*!
- The \e device argument is passed to RtAudio during
- instantiation. The default value (zero) will select the default
- device on your system or the first device found meeting the
- specified parameters. On systems with multiple
- soundcards/devices, values greater than zero can be specified in
- accordance with the order that the devices are enumerated by the
- underlying audio API. The default buffer size of RT_BUFFER_SIZE
- is defined in Stk.h. An StkError will be thrown if an error
- occurs duing instantiation.
- */
- RtDuplex(int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
-
- //! Class destructor.
- ~RtDuplex();
-
- //! Start the audio input/output stream.
- /*!
- The stream is started automatically, if necessary, when a tick() or tickFrame method is called.
- */
- void start(void);
-
- //! Stop the audio input/output stream.
- /*!
- It may be necessary to use this method to avoid audio overflow/underflow problems if you wish to temporarily stop the audio stream.
- */
- void stop(void);
-
- //! Return the average across the last output sample frame.
- StkFloat lastOut(void) const;
-
- //! Output a single sample to all channels in a sample frame and return the average across one new input sample frame of data.
- /*!
- An StkError will be thrown if an error occurs during input/output.
- */
- StkFloat tick(const StkFloat sample);
-
- //! Output each sample in \e vector to all channels per frame and return averaged input sample frames of new data in \e vector.
- /*!
- An StkError will be thrown if an error occurs during input/output.
- */
- StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
-
- //! Output a channel of the StkFrames object to all channels and replace with averaged sample frames of input.
- /*!
- The \c channel argument should be one or greater (the first
- channel is specified by 1). An StkError will be thrown if an
- error occurs during input/outpu or the \c channel argument is zero
- or it is greater than the number of channels in the StkFrames
- object.
- */
- StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
-
- //! Return a pointer to the last output sample frame.
- const StkFloat *lastFrame(void) const;
-
- //! Output sample \e frames from \e frameVector and return new input frames in \e frameVector.
- /*!
- An StkError will be thrown if an error occurs during input/output.
- */
- StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames = 1);
-
- //! Output the StkFrames data and replace with new input frames.
- /*!
- An StkError will be thrown if an error occurs during
- input/output or if there is an incompatability between the number
- of channels in the RtDuplex object and that in the StkFrames
- object.
- */
- StkFrames& tickFrame( StkFrames& frames );
-
-protected:
-
- RtAudio *audio_;
- StkFloat *data_;
- StkFloat *lastOutput_;
- int bufferSize_;
- bool stopped_;
- long counter_;
- unsigned int channels_;
-
-};
-
-#endif
diff --git a/include/RtError.h b/include/RtError.h
index cb1283d..ac5c414 100644
--- a/include/RtError.h
+++ b/include/RtError.h
@@ -12,12 +12,13 @@
#ifndef RTERROR_H
#define RTERROR_H
+#include
#include
#include
-class RtError
+class RtError : public std::exception
{
-public:
+ public:
//! Defined RtError types.
enum Type {
WARNING, /*!< A non-critical error. */
@@ -25,36 +26,35 @@ public:
UNSPECIFIED, /*!< The default, unspecified error type. */
NO_DEVICES_FOUND, /*!< No devices found on system. */
INVALID_DEVICE, /*!< An invalid device ID was specified. */
- INVALID_STREAM, /*!< An invalid stream ID was specified. */
MEMORY_ERROR, /*!< An error occured during memory allocation. */
INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
+ INVALID_USE, /*!< The function was called incorrectly. */
DRIVER_ERROR, /*!< A system driver error occured. */
SYSTEM_ERROR, /*!< A system error occured. */
THREAD_ERROR /*!< A thread error occured. */
};
-protected:
- std::string message_;
- Type type_;
-
-public:
//! The constructor.
- RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type) {}
-
+ RtError( const std::string& message, Type type = RtError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
+
//! The destructor.
- virtual ~RtError(void) {};
+ virtual ~RtError( void ) throw() {}
//! Prints thrown error message to stderr.
- virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
+ virtual void printMessage( void ) throw() { std::cerr << '\n' << message_ << "\n\n"; }
//! Returns the thrown error message type.
- virtual const Type& getType(void) { return type_; }
+ virtual const Type& getType(void) throw() { return type_; }
//! Returns the thrown error message string.
- virtual const std::string& getMessage(void) { return message_; }
+ virtual const std::string& getMessage(void) throw() { return message_; }
- //! Returns the thrown error message as a C string.
- virtual const char *getMessageString(void) { return message_.c_str(); }
+ //! Returns the thrown error message as a c-style string.
+ virtual const char* what( void ) const throw() { return message_.c_str(); }
+
+ protected:
+ std::string message_;
+ Type type_;
};
#endif
diff --git a/include/RtMidi.h b/include/RtMidi.h
index c80462c..b6113f6 100644
--- a/include/RtMidi.h
+++ b/include/RtMidi.h
@@ -35,7 +35,7 @@
*/
/**********************************************************************/
-// RtMidi: Version 1.0.4, 14 October 2005
+// RtMidi: Version 1.0.5, in development
#ifndef RTMIDI_H
#define RTMIDI_H
@@ -51,7 +51,7 @@ class RtMidi
virtual void openPort( unsigned int portNumber = 0 ) = 0;
//! Pure virtual openVirtualPort() function.
- virtual void openVirtualPort() = 0;
+ virtual void openVirtualPort( const std::string portName = std::string( "RtMidi" ) ) = 0;
//! Pure virtual getPortCount() function.
virtual unsigned int getPortCount() = 0;
@@ -128,7 +128,7 @@ class RtMidiIn : public RtMidi
is currently only supported by the Macintosh OS-X and Linux ALSA
APIs (the function does nothing for the other APIs).
*/
- void openVirtualPort();
+ void openVirtualPort( const std::string portName = std::string( "RtMidi Input" ) );
//! Set a callback function to be invoked for incoming MIDI messages.
/*!
@@ -270,7 +270,7 @@ class RtMidiOut : public RtMidi
exception is thrown if an error occurs while attempting to create
the virtual port.
*/
- void openVirtualPort();
+ void openVirtualPort( const std::string portName = std::string( "RtMidi Output" ) );
//! Return the number of available MIDI output ports.
unsigned int getPortCount();
@@ -279,7 +279,7 @@ class RtMidiOut : public RtMidi
/*!
An exception is thrown if an invalid port specifier is provided.
*/
- std::string getPortName( unsigned int portNumber );
+ std::string getPortName( unsigned int portNumber = 0 );
//! Immediately send a single message out an open MIDI output port.
/*!
diff --git a/include/RtWvIn.h b/include/RtWvIn.h
index 5e6f4d0..8b625a2 100644
--- a/include/RtWvIn.h
+++ b/include/RtWvIn.h
@@ -3,18 +3,18 @@
\brief STK realtime audio (blocking) input class.
This class provides a simplified interface to RtAudio for realtime
- audio input. It is a subclass of WvIn. Because this class makes
- use of RtAudio's blocking output routines, its performance is less
- robust on systems where the audio API is callback-based (Macintosh
- CoreAudio and Windows ASIO).
+ audio input. It is a subclass of WvIn. This class makes use of
+ RtAudio's callback functionality by creating a large ring-buffer
+ from which data is read. This class should not be used when
+ low-latency is desired.
- RtWvIn supports multi-channel data in interleaved format. It is
- important to distinguish the tick() methods, which return samples
- produced by averaging across sample frames, from the tickFrame()
- methods, which return references or pointers to multi-channel
- sample frames.
+ RtWvIn supports multi-channel data in both interleaved and
+ non-interleaved formats. It is important to distinguish the
+ tick() methods, which return samples produced by averaging across
+ sample frames, from the tickFrame() methods, which return
+ references or pointers to multi-channel sample frames.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -39,8 +39,7 @@ public:
is defined in Stk.h. An StkError will be thrown if an error
occurs duing instantiation.
*/
- RtWvIn( unsigned int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(),
- int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 4 );
+ RtWvIn( unsigned int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 20 );
//! Class destructor.
~RtWvIn();
@@ -59,15 +58,19 @@ public:
*/
void stop( void );
+ // This function is not intended for general use but had to be made
+ // public for access from the audio callback function.
+ void fillBuffer( void *buffer, unsigned int nFrames );
+
protected:
void computeFrame( void );
- RtAudio *adc_;
- StkFloat *buffer_;
+ RtAudio adc_;
bool stopped_;
- unsigned int bufferFrames_;
- unsigned int bufferIndex_;
+ unsigned int readIndex_;
+ unsigned int writeIndex_;
+ unsigned int framesFilled_;
};
diff --git a/include/RtWvOut.h b/include/RtWvOut.h
index b5bc56e..7e8545c 100644
--- a/include/RtWvOut.h
+++ b/include/RtWvOut.h
@@ -3,10 +3,10 @@
\brief STK realtime audio (blocking) output class.
This class provides a simplified interface to RtAudio for realtime
- audio output. It is a subclass of WvOut. Because this class
- makes use of RtAudio's blocking output routines, its performance
- is less robust on systems where the audio API is callback-based
- (Macintosh CoreAudio and Windows ASIO).
+ audio output. It is a subclass of WvOut. This class makes use of
+ RtAudio's callback functionality by creating a large ring-buffer
+ into which data is written. This class should not be used when
+ low-latency is desired.
RtWvOut supports multi-channel data in interleaved format. It is
important to distinguish the tick() methods, which output single
@@ -14,7 +14,7 @@
method, which take a pointer or reference to multi-channel sample
frame data.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -32,8 +32,7 @@ class RtWvOut : public WvOut
/*!
The \e device argument is passed to RtAudio during
instantiation. The default value (zero) will select the default
- device on your system or the first device found meeting the
- specified parameters. On systems with multiple
+ device on your system. On systems with multiple
soundcards/devices, values greater than zero can be specified in
accordance with the order that the devices are enumerated by the
underlying audio API. The default buffer size of RT_BUFFER_SIZE
@@ -41,7 +40,7 @@ class RtWvOut : public WvOut
occurs duing instantiation.
*/
RtWvOut( unsigned int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(),
- int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 4 );
+ int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 20 );
//! Class destructor.
~RtWvOut();
@@ -51,30 +50,30 @@ class RtWvOut : public WvOut
The stream is started automatically, if necessary, when a
tick() or tickFrame method is called.
*/
- void start(void);
+ void start( void );
//! Stop the audio output stream.
/*!
It may be necessary to use this method to avoid undesireable
audio buffer cycling if you wish to temporarily stop audio output.
*/
- void stop(void);
+ void stop( void );
+
+ // This function is not intended for general use but had to be made
+ // public for access from the audio callback function.
+ int readBuffer( void *buffer, unsigned int frameCount );
protected:
void computeSample( const StkFloat sample );
-
void computeFrames( const StkFrames& frames );
- void incrementFrame( void );
-
- RtAudio *dac_;
- StkFloat *buffer_;
+ RtAudio dac_;
bool stopped_;
- unsigned int nChannels_;
- unsigned int bufferIndex_;
- unsigned int iBuffer_;
- unsigned int bufferFrames_;
+ unsigned int readIndex_;
+ unsigned int writeIndex_;
+ long framesFilled_;
+ unsigned int status_; // running = 0, emptying buffer = 1, finished = 2
};
diff --git a/include/Sampler.h b/include/Sampler.h
index 518035c..0aa8e3b 100644
--- a/include/Sampler.h
+++ b/include/Sampler.h
@@ -5,7 +5,7 @@
This instrument provides an ADSR envelope, a one-pole filter, and
structures for an arbitrary number of attack and loop waves.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Saxofony.h b/include/Saxofony.h
index 8221344..4f5b337 100644
--- a/include/Saxofony.h
+++ b/include/Saxofony.h
@@ -31,7 +31,7 @@
- Vibrato Gain = 1
- Breath Pressure = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Simple.h b/include/Simple.h
index 6a65558..9230264 100644
--- a/include/Simple.h
+++ b/include/Simple.h
@@ -13,7 +13,7 @@
- Envelope Rate = 11
- Gain = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/SineWave.h b/include/SineWave.h
index e4ca79a..ca1a0cd 100644
--- a/include/SineWave.h
+++ b/include/SineWave.h
@@ -9,7 +9,7 @@
The "table" length, set in SineWave.h, is 2048 samples by default.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -69,6 +69,7 @@ public:
protected:
StkFloat computeSample( void );
+ void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
static StkFrames table_;
StkFloat time_;
diff --git a/include/SingWave.h b/include/SingWave.h
index 5ec836f..34ff920 100644
--- a/include/SingWave.h
+++ b/include/SingWave.h
@@ -9,7 +9,7 @@
from pitch shifting. It will be used as an
excitation source for other instruments.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Sitar.h b/include/Sitar.h
index 4cb9edb..240d5c7 100644
--- a/include/Sitar.h
+++ b/include/Sitar.h
@@ -13,7 +13,7 @@
Stanford, bearing the names of Karplus and/or
Strong.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Skini.h b/include/Skini.h
index 3e8d1bc..a7e92fe 100644
--- a/include/Skini.h
+++ b/include/Skini.h
@@ -21,7 +21,7 @@
\sa \ref skini
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Socket.h b/include/Socket.h
index 8fe0e9d..fec4cde 100644
--- a/include/Socket.h
+++ b/include/Socket.h
@@ -7,7 +7,7 @@
number of static functions for use with external socket
descriptors.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/StifKarp.h b/include/StifKarp.h
index aae4a32..6f106b9 100644
--- a/include/StifKarp.h
+++ b/include/StifKarp.h
@@ -17,7 +17,7 @@
- String Sustain = 11
- String Stretch = 1
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Stk.h b/include/Stk.h
index 75e6363..cd78200 100644
--- a/include/Stk.h
+++ b/include/Stk.h
@@ -8,7 +8,31 @@
this class provides error handling and
byte-swapping functions.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ Any person wishing to distribute modifications to the Software is
+ asked to send the modifications to the original developer so that
+ they can be incorporated into the canonical version. This is,
+ however, not a binding provision of this license.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/***************************************************/
@@ -18,6 +42,7 @@
#include
#include
#include
+#include
// Most data in STK is passed and calculated with the
// following user-definable floating-point type. You
@@ -25,19 +50,6 @@
// a "long double" in the future.
typedef double StkFloat;
-// The "MY_FLOAT" type was deprecated in STK
-// versions higher than 4.1.3 and replaced with the variable
-// "StkFloat".
-#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
- typedef StkFloat MY_FLOAT;
- #pragma deprecated(MY_FLOAT)
-#elif defined(__GXX__)
- typedef StkFloat MY_FLOAT __attribute__ ((deprecated));
-#else
- typedef StkFloat MY_FLOAT; // temporary
-#endif
-
-
//! STK error handling class.
/*!
This is a fairly abstract exception handling class. There could
@@ -104,36 +116,53 @@ public:
static const StkFormat STK_FLOAT64; /*!< Normalized between plus/minus 1.0. */
//! Static method which returns the current STK sample rate.
- static StkFloat sampleRate(void) { return srate_; }
+ static StkFloat sampleRate( void ) { return srate_; }
- //! Static method which sets the STK sample rate.
+ //! Static method that sets the STK sample rate.
/*!
The sample rate set using this method is queried by all STK
classes which depend on its value. It is initialized to the
default SRATE set in Stk.h. Many STK classes use the sample rate
during instantiation. Therefore, if you wish to use a rate which
is different from the default rate, it is imperative that it be
- set \e BEFORE STK objects are instantiated.
+ set \e BEFORE STK objects are instantiated. A few classes that
+ make use of the global STK sample rate are automatically notified
+ when the rate changes so that internal class data can be
+ appropriately updated. However, this has not been fully
+ implemented. Specifically, classes that appropriately update
+ their own data when either a setFrequency() or noteOn() function
+ is called do not currently receive the automatic notification of
+ rate change. If the user wants a specific class instance to
+ ignore such notifications, perhaps in a multi-rate context, the
+ function Stk::ignoreSampleRateChange() should be called.
*/
- static void setSampleRate(StkFloat rate) { if (rate > 0.0) srate_ = rate; }
+ static void setSampleRate( StkFloat rate );
+
+ //! A function to enable/disable the automatic updating of class data when the STK sample rate changes.
+ /*!
+ This function allows the user to enable or disable class data
+ updates in response to global sample rate changes on a class by
+ class basis.
+ */
+ void ignoreSampleRateChange( bool ignore = true ) { ignoreSampleRateChange_ = ignore; };
//! Static method which returns the current rawwave path.
static std::string rawwavePath(void) { return rawwavepath_; }
//! Static method which sets the STK rawwave path.
- static void setRawwavePath(std::string path);
+ static void setRawwavePath( std::string path );
//! Static method which byte-swaps a 16-bit data type.
- static void swap16(unsigned char *ptr);
+ static void swap16( unsigned char *ptr );
//! Static method which byte-swaps a 32-bit data type.
- static void swap32(unsigned char *ptr);
+ static void swap32( unsigned char *ptr );
//! Static method which byte-swaps a 64-bit data type.
- static void swap64(unsigned char *ptr);
+ static void swap64( unsigned char *ptr );
//! Static cross-platform method to sleep for a number of milliseconds.
- static void sleep(unsigned long milliseconds);
+ static void sleep( unsigned long milliseconds );
//! Static function for error reporting and handling using c-strings.
static void handleError( const char *message, StkError::Type type );
@@ -152,16 +181,27 @@ private:
static std::string rawwavepath_;
static bool showWarnings_;
static bool printErrors_;
+ static std::vector alertList_;
protected:
std::ostringstream errorString_;
+ bool ignoreSampleRateChange_;
//! Default constructor.
- Stk(void);
+ Stk( void );
//! Class destructor.
- virtual ~Stk(void);
+ virtual ~Stk( void );
+
+ //! This function should be implemented in subclasses that depend on the sample rate.
+ virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
+
+ //! Add class pointer to list for sample rate change notification.
+ void addSampleRateAlert( Stk *ptr );
+
+ //! Remove class pointer from list for sample rate change notification.
+ void removeSampleRateAlert( Stk *ptr );
//! Internal function for error reporting which assumes message in \c errorString_ variable.
void handleError( StkError::Type type );
@@ -181,7 +221,7 @@ protected:
to inter- or de-interleave the data and to convert to and return
other data types.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -348,13 +388,12 @@ const StkFloat ONE_OVER_128 = 0.0078125;
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_MM__)
#define __OS_WINDOWS__
#define __STK_REALTIME__
-#elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__) || defined(__LINUX_JACK__)
+#elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__) || defined(__UNIX_JACK__)
#define __OS_LINUX__
#define __STK_REALTIME__
#elif defined(__IRIX_AL__)
#define __OS_IRIX__
- #define __STK_REALTIME__
-#elif defined(__MACOSX_CORE__)
+#elif defined(__MACOSX_CORE__) || defined(__UNIX_JACK__)
#define __OS_MACOSX__
#define __STK_REALTIME__
#endif
diff --git a/include/SubNoise.h b/include/SubNoise.h
index 3dad039..eb17a93 100644
--- a/include/SubNoise.h
+++ b/include/SubNoise.h
@@ -6,7 +6,7 @@
using the C rand() function. The quality of the
rand() function varies from one OS to another.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/TcpClient.h b/include/TcpClient.h
index 8c5ef1a..99c9f62 100644
--- a/include/TcpClient.h
+++ b/include/TcpClient.h
@@ -19,7 +19,7 @@
less than or equal to zero indicate a closed
or lost connection or the occurence of an error.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/TcpServer.h b/include/TcpServer.h
index 7951ee2..0ec5082 100644
--- a/include/TcpServer.h
+++ b/include/TcpServer.h
@@ -19,7 +19,7 @@
less than or equal to zero indicate a closed
or lost connection or the occurence of an error.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Thread.h b/include/Thread.h
index f082ff2..7253a82 100644
--- a/include/Thread.h
+++ b/include/Thread.h
@@ -16,7 +16,7 @@
THREAD_RETURN THREAD_TYPE thread_function(void *ptr)
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/TubeBell.h b/include/TubeBell.h
index ac993c3..64acc8c 100644
--- a/include/TubeBell.h
+++ b/include/TubeBell.h
@@ -26,7 +26,7 @@
type who should worry about this (making
money) worry away.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/TwoPole.h b/include/TwoPole.h
index 94a76d8..b8060ea 100644
--- a/include/TwoPole.h
+++ b/include/TwoPole.h
@@ -8,7 +8,7 @@
frequency response while maintaining a nearly
constant filter gain.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -27,6 +27,9 @@ class TwoPole : protected Filter
//! Class destructor.
~TwoPole();
+ //! A function to enable/disable the automatic updating of class data when the STK sample rate changes.
+ void ignoreSampleRateChange( bool ignore = true ) { ignoreSampleRateChange_ = ignore; };
+
//! Clears the internal states of the filter.
void clear(void);
@@ -79,6 +82,10 @@ class TwoPole : protected Filter
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
+
+ protected:
+
+ virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
};
#endif
diff --git a/include/TwoZero.h b/include/TwoZero.h
index 1054a42..2e63488 100644
--- a/include/TwoZero.h
+++ b/include/TwoZero.h
@@ -8,7 +8,7 @@
frequency response while maintaining a
constant filter gain.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -26,6 +26,9 @@ class TwoZero : protected Filter
//! Class destructor.
~TwoZero();
+ //! A function to enable/disable the automatic updating of class data when the STK sample rate changes.
+ void ignoreSampleRateChange( bool ignore = true ) { ignoreSampleRateChange_ = ignore; };
+
//! Clears the internal states of the filter.
void clear(void);
@@ -75,6 +78,10 @@ class TwoZero : protected Filter
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
+
+ protected:
+
+ virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
};
#endif
diff --git a/include/UdpSocket.h b/include/UdpSocket.h
index c81e6fd..2e6c881 100644
--- a/include/UdpSocket.h
+++ b/include/UdpSocket.h
@@ -17,7 +17,7 @@
read/write methods. Values less than or equal to zero indicate
the occurence of an error.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/VoicForm.h b/include/VoicForm.h
index 1e6bbf1..41f47b0 100644
--- a/include/VoicForm.h
+++ b/include/VoicForm.h
@@ -21,7 +21,7 @@
- Vibrato Gain = 1
- Loudness (Spectral Tilt) = 128
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/Voicer.h b/include/Voicer.h
index ab5a5ca..ba404a4 100644
--- a/include/Voicer.h
+++ b/include/Voicer.h
@@ -25,7 +25,7 @@
an ensemble. Alternately, control changes can
be sent to all voices on a given channel.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/WaveLoop.h b/include/WaveLoop.h
index 27d4c2e..b77b2fd 100644
--- a/include/WaveLoop.h
+++ b/include/WaveLoop.h
@@ -12,7 +12,7 @@
which return references or pointers to multi-channel sample
frames.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -83,6 +83,7 @@ public:
protected:
virtual void computeFrame( void );
+ virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
StkFrames firstFrame_;
StkFloat phaseOffset_;
diff --git a/include/Wurley.h b/include/Wurley.h
index deecf08..1159353 100644
--- a/include/Wurley.h
+++ b/include/Wurley.h
@@ -26,7 +26,7 @@
type who should worry about this (making
money) worry away.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/WvIn.h b/include/WvIn.h
index e3e3c3f..7722b80 100644
--- a/include/WvIn.h
+++ b/include/WvIn.h
@@ -13,7 +13,7 @@
Both interleaved and non-interleaved data is supported via the use
of StkFrames objects.
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/include/WvOut.h b/include/WvOut.h
index 5ee2d3b..d2b4820 100644
--- a/include/WvOut.h
+++ b/include/WvOut.h
@@ -16,7 +16,7 @@
Currently, WvOut is non-interpolating and the output rate is
always Stk::sampleRate().
- by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
+ by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
diff --git a/projects/demo/Makefile.in b/projects/demo/Makefile.in
index 9f64d42..0caef5f 100644
--- a/projects/demo/Makefile.in
+++ b/projects/demo/Makefile.in
@@ -1,6 +1,6 @@
### STK demo Makefile - for various flavors of unix
-PROGRAMS = demo Md2Skini
+PROGRAMS = demo
RM = /bin/rm
SRC_PATH = ../../src
OBJECT_PATH = @object_path@
@@ -39,6 +39,7 @@ LIBRARY += @frameworks@
REALTIME = @realtime@
ifeq ($(REALTIME),yes)
+ PROGRAMS += demo
OBJECTS += RtMidi.o RtAudio.o Thread.o Mutex.o Socket.o TcpServer.o
DEFS += @audio_apis@
endif
diff --git a/projects/demo/Md2Skini.vcproj b/projects/demo/Md2Skini.vcproj
new file mode 100755
index 0000000..6028ef6
--- /dev/null
+++ b/projects/demo/Md2Skini.vcproj
@@ -0,0 +1,240 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/demo/demo.cpp b/projects/demo/demo.cpp
index 04f3a4f..3d82072 100644
--- a/projects/demo/demo.cpp
+++ b/projects/demo/demo.cpp
@@ -20,11 +20,10 @@
#include "utilities.h"
#include
+#include
#include
#include
-#if !defined(__OS_WINDOWS__) // Windoze bogosity for VC++ 6.0
- using std::min;
-#endif
+using std::min;
bool done;
static void finish(int ignore){ done = true; }
@@ -48,6 +47,7 @@ struct TickData {
bool realtime;
bool settling;
bool haveMessage;
+ int frequency;
// Default constructor.
TickData()
@@ -75,13 +75,13 @@ void processMessage( TickData* data )
case __SK_NoteOn_:
if ( value2 == 0.0 ) // velocity is zero ... really a NoteOff
- data->voicer->noteOff( value1, 64.0 );
+ data->voicer->noteOff( value1, 64.0, data->message.channel );
else // a NoteOn
- data->voicer->noteOn( value1, value2 );
+ data->voicer->noteOn( value1, value2, data->message.channel );
break;
case __SK_NoteOff_:
- data->voicer->noteOff( value1, value2 );
+ data->voicer->noteOff( value1, value2, data->message.channel );
break;
case __SK_ControlChange_:
@@ -90,21 +90,31 @@ void processMessage( TickData* data )
else if (value1 == 7.0)
data->volume = value2 * ONE_OVER_128;
else if (value1 == 49.0)
- data->voicer->setFrequency( value2 );
+ data->voicer->setFrequency( value2, data->message.channel );
+ else if (value1 == 50.0)
+ data->voicer->controlChange( 128, value2, data->message.channel );
+ else if (value1 == 51.0)
+ data->frequency = data->message.intValues[1];
+ else if (value1 == 52.0) {
+ data->frequency += ( data->message.intValues[1] << 7 );
+ // Convert to a fractional MIDI note value
+ StkFloat note = 12.0 * log( data->frequency / 220.0 ) / log( 2.0 ) + 57.0;
+ data->voicer->setFrequency( note, data->message.channel );
+ }
else
- data->voicer->controlChange( (int) value1, value2 );
+ data->voicer->controlChange( (int) value1, value2, data->message.channel );
break;
case __SK_AfterTouch_:
- data->voicer->controlChange( 128, value1 );
+ data->voicer->controlChange( 128, value1, data->message.channel );
break;
case __SK_PitchChange_:
- data->voicer->setFrequency( value1 );
+ data->voicer->setFrequency( value1, data->message.channel );
break;
case __SK_PitchBend_:
- data->voicer->pitchBend( value1 );
+ data->voicer->pitchBend( value1, data->message.channel );
break;
case __SK_Volume_:
@@ -124,7 +134,7 @@ void processMessage( TickData* data )
data->currentVoice = voiceByNumber( (int)value1, &data->instrument[i] );
if ( data->currentVoice < 0 )
data->currentVoice = voiceByNumber( 0, &data->instrument[i] );
- data->voicer->addInstrument( data->instrument[i] );
+ data->voicer->addInstrument( data->instrument[i], data->message.channel );
data->settling = false;
}
@@ -144,11 +154,12 @@ void processMessage( TickData* data )
// The tick() function handles sample computation and scheduling of
// control updates. If doing realtime audio output, it will be called
// automatically when the system needs a new buffer of audio samples.
-int tick(char *buffer, int bufferSize, void *dataPointer)
+int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+ double streamTime, RtAudioStreamStatus status, void *dataPointer )
{
TickData *data = (TickData *) dataPointer;
- register StkFloat sample, *samples = (StkFloat *) buffer;
- int counter, nTicks = bufferSize;
+ register StkFloat sample, *samples = (StkFloat *) outputBuffer;
+ int counter, nTicks = (int) nBufferFrames;
while ( nTicks > 0 && !done ) {
@@ -186,7 +197,7 @@ int main( int argc, char *argv[] )
int i;
#if defined(__STK_REALTIME__)
- RtAudio *dac = 0;
+ RtAudio dac;
#endif
// If you want to change the default sample rate (set in Stk.h), do
@@ -219,7 +230,7 @@ int main( int argc, char *argv[] )
data.voicer = (Voicer *) new Voicer( data.nVoices );
for ( i=0; iaddInstrument( data.instrument[i] );
+ data.voicer->addInstrument( data.instrument[i], i+1 );
// Parse the command-line flags, instantiate WvOut objects, and
// instantiate the input message controller (in utilities.cpp).
@@ -234,11 +245,14 @@ int main( int argc, char *argv[] )
#if defined(__STK_REALTIME__)
if ( data.realtime ) {
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
- int bufferSize = RT_BUFFER_SIZE;
+ RtAudio::StreamParameters parameters;
+ parameters.deviceId = dac.getDefaultOutputDevice();
+ parameters.nChannels = data.channels;
+ unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
- dac = new RtAudio(0, data.channels, 0, 0, format, (int)Stk::sampleRate(), &bufferSize, 4);
+ dac.openStream( ¶meters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
- catch (RtError& error) {
+ catch ( RtError& error ) {
error.printMessage();
goto cleanup;
}
@@ -256,10 +270,9 @@ int main( int argc, char *argv[] )
#if defined(__STK_REALTIME__)
if ( data.realtime ) {
try {
- dac->setStreamCallback(&tick, (void *)&data);
- dac->startStream();
+ dac.startStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -275,17 +288,16 @@ int main( int argc, char *argv[] )
else
#endif
// Call the "tick" function to process data.
- tick( NULL, 256, (void *)&data );
+ tick( NULL, NULL, 256, 0, 0, (void *)&data );
}
- // Shut down the callback and output stream.
+ // Shut down the output stream.
#if defined(__STK_REALTIME__)
if ( data.realtime ) {
try {
- dac->cancelStreamCallback();
- dac->closeStream();
+ dac.closeStream();
}
- catch (RtError& error) {
+ catch ( RtError& error ) {
error.printMessage();
}
}
@@ -296,9 +308,6 @@ int main( int argc, char *argv[] )
for ( i=0; i<(int)data.nWvOuts; i++ ) delete data.wvout[i];
free( data.wvout );
-#if defined(__STK_REALTIME__)
- delete dac;
-#endif
delete data.reverb;
delete data.voicer;
diff --git a/projects/demo/demo.vcproj b/projects/demo/demo.vcproj
new file mode 100755
index 0000000..eb0cf20
--- /dev/null
+++ b/projects/demo/demo.vcproj
@@ -0,0 +1,2103 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/demo/tcl/Physical.tcl b/projects/demo/tcl/Physical.tcl
index b1c0f01..e0e33e4 100644
--- a/projects/demo/tcl/Physical.tcl
+++ b/projects/demo/tcl/Physical.tcl
@@ -68,6 +68,7 @@ pack .radios2.pluk -side left -padx 5 -pady 10
pack .radios2.karp -side left -padx 5 -pady 10
pack .radios2.sitr -side left -padx 5 -pady 10
pack .radios2.mand -side left -padx 5 -pady 10
+pack .radios2.blot -side left -padx 5 -pady 10
pack .radios1
pack .radios2
diff --git a/projects/effects/Makefile.in b/projects/effects/Makefile.in
index 84ce68e..51ce25d 100644
--- a/projects/effects/Makefile.in
+++ b/projects/effects/Makefile.in
@@ -1,6 +1,6 @@
### STK effects Makefile - for various flavors of unix
-PROGRAMS = effects
+PROGRAMS =
RM = /bin/rm
SRC_PATH = ../../src
OBJECT_PATH = @object_path@
@@ -28,6 +28,7 @@ LIBRARY += @frameworks@
REALTIME = @realtime@
ifeq ($(REALTIME),yes)
+ PROGRAMS += effects
OBJECTS += RtMidi.o RtAudio.o Thread.o Mutex.o Socket.o TcpServer.o
DEFS += @audio_apis@
endif
diff --git a/projects/effects/Makefile.sgi b/projects/effects/Makefile.sgi
deleted file mode 100644
index cf9e7f1..0000000
--- a/projects/effects/Makefile.sgi
+++ /dev/null
@@ -1,50 +0,0 @@
-# STK Makefile for Effects project- SGI solo version (non-GNU Makefile utilities version)
-
-# The following definition indicates the relative location of
-# the core STK classes.
-STK_PATH = ../../src/
-
-OBJECTS = $(STK_PATH)Stk.o $(STK_PATH)Envelope.o $(STK_PATH)Filter.o \
- $(STK_PATH)DelayL.o $(STK_PATH)Delay.o $(STK_PATH)SKINI.o \
- $(STK_PATH)WvIn.o $(STK_PATH)Reverb.o $(STK_PATH)PRCRev.o \
- $(STK_PATH)JCRev.o $(STK_PATH)NRev.o $(STK_PATH)RtAudio.o \
- $(STK_PATH)RtMidi.o $(STK_PATH)RtDuplex.o $(STK_PATH)Messager.o \
- $(STK_PATH)WaveLoop.o $(STK_PATH)Thread.o $(STK_PATH)Socket.o
-
-O_LOCAL_FILES = Echo.o PitShift.o Chorus.o
-
-RM = /bin/rm
-
-PROGRAMS = effects
-CC = CC -O2 -D__IRIX_AL__ # -g -fullwarn -D__SGI_CC__
-LIBRARY = -L/usr/sgitcl/lib -laudio -lmd -lm -lpthread
-INCLUDE = -I../../include/
-
-.SUFFIXES: .cpp
-.cpp.o: $(OBJECTS)
- $(CC) $(INCLUDE) -c -o $@ $<
-
-all: $(PROGRAMS)
-
-effects: effects.cpp $(OBJECTS) $(O_LOCAL_FILES)
- $(CC) -o effects effects.cpp $(OBJECTS) $(O_LOCAL_FILES) $(LIBRARY) $(INCLUDE)
-
-clean :
- rm *.o
- rm $(STK_PATH)*.o
- rm $(PROGRAMS)
-
-strip :
- strip $(PROGRAMS)
-
-# Project specific objects:
-
-Echo.o: Echo.cpp
- $(CC) $(INCLUDE) -c Echo.cpp
-
-PitShift.o: PitShift.cpp
- $(CC) $(INCLUDE) -c PitShift.cpp
-
-Chorus.o: Chorus.cpp
- $(CC) $(INCLUDE) -c Chorus.cpp
-
diff --git a/projects/effects/README-effects.txt b/projects/effects/README-effects.txt
index d6200e3..6fa532a 100644
--- a/projects/effects/README-effects.txt
+++ b/projects/effects/README-effects.txt
@@ -1,6 +1,6 @@
The Synthesis ToolKit in C++ (STK)
-By Perry R. Cook and Gary P. Scavone, 1995-2005.
+By Perry R. Cook and Gary P. Scavone, 1995-2007.
EFFECTS PROJECT:
@@ -20,7 +20,7 @@ NOTES:
2. Audio input from either a microphone or line-input device MUST be
available to the audio input port when the program is started.
-3. Latency can be controlled using the RtDuplex bufferSize and
- nBuffers constructor arguments. The default settings in
- effects.cpp are relatively high because some Windows soundcard
- drivers crash if the settings are too low.
+3. Latency can be controlled using the nBufferFrames argument to the
+ RtAudio openStream() function. The default settings in effects.cpp
+ are relatively high because some Windows soundcard drivers crash if
+ the settings are too low.
diff --git a/projects/effects/effects.cpp b/projects/effects/effects.cpp
index 310678f..8f33313 100644
--- a/projects/effects/effects.cpp
+++ b/projects/effects/effects.cpp
@@ -149,11 +149,13 @@ void processMessage( TickData* data )
// The tick() function handles sample computation and scheduling of
// control updates. It will be called automatically by RtAudio when
// the system needs a new buffer of audio samples.
-int tick(char *buffer, int bufferSize, void *dataPointer)
+int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+ double streamTime, RtAudioStreamStatus status, void *dataPointer )
{
TickData *data = (TickData *) dataPointer;
- register StkFloat sample, *samples = (StkFloat *) buffer;
- int i, counter, nTicks = bufferSize;
+ register StkFloat *oSamples = (StkFloat *) outputBuffer, *iSamples = (StkFloat *) inputBuffer;
+ register StkFloat sample;
+ int i, counter, nTicks = (int) nBufferFrames;
while ( nTicks > 0 && !done ) {
@@ -170,9 +172,9 @@ int tick(char *buffer, int bufferSize, void *dataPointer)
counter = min( nTicks, data->counter );
data->counter -= counter;
for ( i=0; ienvelope.tick() * data->effect->tick( *samples );
- *samples++ = sample; // two channels interleaved
- *samples++ = sample;
+ sample = data->envelope.tick() * data->effect->tick( *iSamples++ );
+ *oSamples++ = sample; // two channels interleaved
+ *oSamples++ = sample;
nTicks--;
}
if ( nTicks == 0 ) break;
@@ -188,10 +190,10 @@ int tick(char *buffer, int bufferSize, void *dataPointer)
int main( int argc, char *argv[] )
{
TickData data;
- RtAudio *adac = 0;
+ RtAudio adac;
int i;
- if (argc < 2 || argc > 6) usage();
+ if ( argc < 2 || argc > 6 ) usage();
// If you want to change the default sample rate (set in Stk.h), do
// it before instantiating any objects! If the sample rate is
@@ -215,27 +217,31 @@ int main( int argc, char *argv[] )
// Allocate the adac here.
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
- int bufferSize = RT_BUFFER_SIZE;
+ RtAudio::StreamParameters oparameters, iparameters;
+ oparameters.deviceId = adac.getDefaultOutputDevice();
+ oparameters.nChannels = 2;
+ iparameters.deviceId = adac.getDefaultInputDevice();
+ iparameters.nChannels = 1;
+ unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
- adac = new RtAudio(0, 2, 0, 2, format, (int)Stk::sampleRate(), &bufferSize, 4);
+ adac.openStream( &oparameters, &iparameters, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
- catch (RtError& error) {
+ catch ( RtError& error ) {
error.printMessage();
goto cleanup;
}
data.envelope.setRate( 0.001 );
- data.effect = &(data.echo);
+ data.effect = &( data.echo );
// Install an interrupt handler function.
(void) signal( SIGINT, finish );
// If realtime output, set our callback function and start the dac.
try {
- adac->setStreamCallback( &tick, (void *)&data );
- adac->startStream();
+ adac.startStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -246,19 +252,16 @@ int main( int argc, char *argv[] )
Stk::sleep( 50 );
}
- // Shut down the callback and output stream.
+ // Shut down the output stream.
try {
- adac->cancelStreamCallback();
- adac->closeStream();
+ adac.closeStream();
}
- catch (RtError& error) {
+ catch ( RtError& error ) {
error.printMessage();
}
cleanup:
- delete adac;
-
std::cout << "\neffects finished ... goodbye.\n\n";
return 0;
}
diff --git a/projects/effects/effects.vcproj b/projects/effects/effects.vcproj
new file mode 100755
index 0000000..8c7d246
--- /dev/null
+++ b/projects/effects/effects.vcproj
@@ -0,0 +1,732 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/Makefile.in b/projects/examples/Makefile.in
index 4cc94c1..64fd041 100644
--- a/projects/examples/Makefile.in
+++ b/projects/examples/Makefile.in
@@ -1,6 +1,6 @@
### STK examples Makefile - for various flavors of unix
-PROGRAMS = sine play record io inetIn inetOut sineosc rtsine crtsine bethree controlbee foursine threebees playsmf grains
+PROGRAMS = sine sineosc foursine
RM = /bin/rm
SRC_PATH = ../../src
OBJECT_PATH = @object_path@
@@ -22,6 +22,7 @@ LIBRARY += @frameworks@
REALTIME = @realtime@
ifeq ($(REALTIME),yes)
+ PROGRAMS += play record probe duplex inetIn inetOut rtsine crtsine bethree controlbee threebees playsmf grains
DEFS += @audio_apis@
endif
@@ -45,6 +46,9 @@ clean :
strip :
strip $(PROGRAMS)
+probe: RtAudio.o
+ $(CC) $(CFLAGS) $(DEFS) -o probe probe.cpp $(OBJECT_PATH)/RtAudio.o $(LIBRARY)
+
play: play.cpp Stk.o FileRead.o WvIn.o FileWvIn.o RtAudio.o
$(CC) $(CFLAGS) $(DEFS) -o play play.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/WvIn.o $(OBJECT_PATH)/FileRead.o $(OBJECT_PATH)/FileWvIn.o $(OBJECT_PATH)/RtAudio.o $(LIBRARY)
@@ -54,8 +58,8 @@ record: record.cpp Stk.o WvIn.o FileWrite.o WvOut.o FileWvOut.o RtWvIn.o RtAudio
sine: sine.cpp Stk.o Generator.o SineWave.o FileWrite.o WvOut.o FileWvOut.o
$(CC) $(CFLAGS) $(DEFS) -o sine sine.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/Generator.o $(OBJECT_PATH)/SineWave.o $(OBJECT_PATH)/FileWrite.o $(OBJECT_PATH)/WvOut.o $(OBJECT_PATH)/FileWvOut.o $(LIBRARY)
-io: io.cpp Stk.o RtAudio.o RtDuplex.o
- $(CC) $(CFLAGS) $(DEFS) -o io io.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/RtAudio.o $(OBJECT_PATH)/RtDuplex.o $(LIBRARY)
+duplex: duplex.cpp RtAudio.o
+ $(CC) $(CFLAGS) $(DEFS) -o duplex duplex.cpp $(OBJECT_PATH)/RtAudio.o $(LIBRARY)
inetIn: inetIn.cpp Stk.o WvIn.o InetWvIn.o WvOut.o RtWvOut.o RtAudio.o Socket.o TcpServer.o UdpSocket.o Thread.o Mutex.o
$(CC) $(CFLAGS) $(DEFS) -o inetIn inetIn.cpp $(OBJECT_PATH)/Stk.o $(OBJECT_PATH)/WvIn.o $(OBJECT_PATH)/InetWvIn.o $(OBJECT_PATH)/Socket.o $(OBJECT_PATH)/TcpServer.o $(OBJECT_PATH)/UdpSocket.o $(OBJECT_PATH)/Thread.o $(OBJECT_PATH)/Mutex.o $(OBJECT_PATH)/WvOut.o $(OBJECT_PATH)/RtWvOut.o $(OBJECT_PATH)/RtAudio.o $(LIBRARY)
diff --git a/projects/examples/bethree.cpp b/projects/examples/bethree.cpp
index 10db363..0767c03 100644
--- a/projects/examples/bethree.cpp
+++ b/projects/examples/bethree.cpp
@@ -20,12 +20,13 @@ struct TickData {
// This tick() function handles sample computation only. It will be
// called automatically when the system needs a new buffer of audio
// samples.
-int tick(char *buffer, int bufferSize, void *dataPointer)
+int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+ double streamTime, RtAudioStreamStatus status, void *userData )
{
- TickData *data = (TickData *) dataPointer;
- register StkFloat *samples = (StkFloat *) buffer;
+ TickData *data = (TickData *) userData;
+ register StkFloat *samples = (StkFloat *) outputBuffer;
- for ( int i=0; iinstrument->tick();
if ( ++data->counter % 2000 == 0 ) {
data->scaler += 0.025;
@@ -46,15 +47,18 @@ int main()
Stk::setRawwavePath( "../../rawwaves/" );
TickData data;
- RtAudio *dac = 0;
+ RtAudio dac;
- // Figure out how many bytes in an StkFloat and setup the RtAudio object.
+ // Figure out how many bytes in an StkFloat and setup the RtAudio stream.
+ RtAudio::StreamParameters parameters;
+ parameters.deviceId = dac.getDefaultOutputDevice();
+ parameters.nChannels = 1;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
- int bufferSize = RT_BUFFER_SIZE;
+ unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
- dac = new RtAudio(0, 1, 0, 0, format, (int)Stk::sampleRate(), &bufferSize, 4);
+ dac.openStream( ¶meters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
- catch (RtError& error) {
+ catch ( RtError& error ) {
error.printMessage();
goto cleanup;
}
@@ -63,7 +67,7 @@ int main()
// Define and load the BeeThree instrument
data.instrument = new BeeThree();
}
- catch (StkError &) {
+ catch ( StkError & ) {
goto cleanup;
}
@@ -71,10 +75,9 @@ int main()
data.instrument->noteOn( data.frequency, 0.5 );
try {
- dac->setStreamCallback(&tick, (void *)&data);
- dac->startStream();
+ dac.startStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -85,16 +88,14 @@ int main()
// Shut down the callback and output stream.
try {
- dac->cancelStreamCallback();
- dac->closeStream();
+ dac.closeStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
}
cleanup:
delete data.instrument;
- delete dac;
return 0;
}
diff --git a/projects/examples/bethree.vcproj b/projects/examples/bethree.vcproj
new file mode 100755
index 0000000..a0db11e
--- /dev/null
+++ b/projects/examples/bethree.vcproj
@@ -0,0 +1,562 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/controlbee.cpp b/projects/examples/controlbee.cpp
index 9dae23f..cbfd067 100644
--- a/projects/examples/controlbee.cpp
+++ b/projects/examples/controlbee.cpp
@@ -78,11 +78,12 @@ void processMessage( TickData* data )
// This tick() function handles sample computation and scheduling of
// control updates. It will be called automatically when the system
// needs a new buffer of audio samples.
-int tick(char *buffer, int bufferSize, void *dataPointer)
+int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+ double streamTime, RtAudioStreamStatus status, void *dataPointer )
{
TickData *data = (TickData *) dataPointer;
- register StkFloat *samples = (StkFloat *) buffer;
- int counter, nTicks = bufferSize;
+ register StkFloat *samples = (StkFloat *) outputBuffer;
+ int counter, nTicks = (int) nBufferFrames;
while ( nTicks > 0 && !data->done ) {
@@ -121,15 +122,18 @@ int main( int argc, char *argv[] )
Stk::setRawwavePath( "../../rawwaves/" );
TickData data;
- RtAudio *dac = 0;
+ RtAudio dac;
- // Figure out how many bytes in an StkFloat and setup the RtAudio object.
+ // Figure out how many bytes in an StkFloat and setup the RtAudio stream.
+ RtAudio::StreamParameters parameters;
+ parameters.deviceId = dac.getDefaultOutputDevice();
+ parameters.nChannels = 1;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
- int bufferSize = RT_BUFFER_SIZE;
+ unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
- dac = new RtAudio(0, 1, 0, 0, format, (int)Stk::sampleRate(), &bufferSize, 4);
+ dac.openStream( ¶meters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
- catch (RtError& error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -138,7 +142,7 @@ int main( int argc, char *argv[] )
// Define and load the BeeThree instrument
data.instrument = new BeeThree();
}
- catch (StkError &) {
+ catch ( StkError & ) {
goto cleanup;
}
@@ -146,10 +150,9 @@ int main( int argc, char *argv[] )
goto cleanup;
try {
- dac->setStreamCallback(&tick, (void *)&data);
- dac->startStream();
+ dac.startStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -158,18 +161,16 @@ int main( int argc, char *argv[] )
while ( !data.done )
Stk::sleep( 100 );
- // Shut down the callback and output stream.
+ // Shut down the output stream.
try {
- dac->cancelStreamCallback();
- dac->closeStream();
+ dac.closeStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
}
cleanup:
delete data.instrument;
- delete dac;
return 0;
}
diff --git a/projects/examples/controlbee.vcproj b/projects/examples/controlbee.vcproj
new file mode 100755
index 0000000..6c94122
--- /dev/null
+++ b/projects/examples/controlbee.vcproj
@@ -0,0 +1,708 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/crtblit.cpp b/projects/examples/crtblit.cpp
deleted file mode 100644
index 7d53916..0000000
--- a/projects/examples/crtblit.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-// crtblit.cpp STK tutorial program
-
-#include "Blit.h"
-#include "BlitSaw.h"
-#include "RtAudio.h"
-
-unsigned long counter = 0;
-StkFloat frequency = 200.0;
-
-// This tick() function handles sample computation only. It will be
-// called automatically when the system needs a new buffer of audio
-// samples.
-int tick(char *buffer, int bufferSize, void *dataPointer)
-{
- BlitSaw *blit = (BlitSaw *) dataPointer;
- register StkFloat *samples = (StkFloat *) buffer;
-
- for ( int i=0; itick();
-
- if ( counter++ % 500 == 0 && frequency < 3000.0 ) {
- frequency *= 1.01;
- blit->setFrequency( frequency );
- }
- }
-
- return 0;
-}
-
-int main()
-{
- // Set the global sample rate before creating class instances.
- Stk::setSampleRate( 44100.0 );
- Stk::showWarnings( true );
-
- BlitSaw blit;
- RtAudio *dac = 0;
-
- // Figure out how many bytes in an StkFloat and setup the RtAudio object.
- RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
- int bufferSize = RT_BUFFER_SIZE;
- try {
- dac = new RtAudio(0, 1, 0, 0, format, (int)Stk::sampleRate(), &bufferSize, 4);
- }
- catch (RtError& error) {
- error.printMessage();
- exit(0);
- }
-
- blit.setFrequency( frequency );
- blit.setHarmonics( 20 );
-
- try {
- dac->setStreamCallback(&tick, (void *)&blit);
- dac->startStream();
- }
- catch (RtError &error) {
- error.printMessage();
- goto cleanup;
- }
-
- // Block waiting here.
- char keyhit;
- std::cout << "\nPlaying ... press to quit.\n";
- std::cin.get(keyhit);
-
- // Shut down the callback and output stream.
- try {
- dac->cancelStreamCallback();
- dac->closeStream();
- }
- catch (RtError &error) {
- error.printMessage();
- }
-
- cleanup:
-
- delete dac;
-
- return 0;
-}
diff --git a/projects/examples/crtsine.cpp b/projects/examples/crtsine.cpp
index 68acb9b..b959c08 100644
--- a/projects/examples/crtsine.cpp
+++ b/projects/examples/crtsine.cpp
@@ -6,12 +6,13 @@
// This tick() function handles sample computation only. It will be
// called automatically when the system needs a new buffer of audio
// samples.
-int tick(char *buffer, int bufferSize, void *dataPointer)
+int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+ double streamTime, RtAudioStreamStatus status, void *dataPointer )
{
SineWave *sine = (SineWave *) dataPointer;
- register StkFloat *samples = (StkFloat *) buffer;
+ register StkFloat *samples = (StkFloat *) outputBuffer;
- for ( int i=0; itick();
return 0;
@@ -23,26 +24,28 @@ int main()
Stk::setSampleRate( 44100.0 );
SineWave sine;
- RtAudio *dac = 0;
+ RtAudio dac;
- // Figure out how many bytes in an StkFloat and setup the RtAudio object.
+ // Figure out how many bytes in an StkFloat and setup the RtAudio stream.
+ RtAudio::StreamParameters parameters;
+ parameters.deviceId = dac.getDefaultOutputDevice();
+ parameters.nChannels = 1;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
- int bufferSize = RT_BUFFER_SIZE;
+ unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
- dac = new RtAudio(0, 1, 0, 0, format, (int)Stk::sampleRate(), &bufferSize, 4);
+ dac.openStream( ¶meters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&sine );
}
- catch (RtError& error) {
+ catch ( RtError &error ) {
error.printMessage();
- exit(0);
+ goto cleanup;
}
sine.setFrequency(440.0);
try {
- dac->setStreamCallback(&tick, (void *)&sine);
- dac->startStream();
+ dac.startStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -50,20 +53,17 @@ int main()
// Block waiting here.
char keyhit;
std::cout << "\nPlaying ... press to quit.\n";
- std::cin.get(keyhit);
+ std::cin.get( keyhit );
- // Shut down the callback and output stream.
+ // Shut down the output stream.
try {
- dac->cancelStreamCallback();
- dac->closeStream();
+ dac.closeStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
}
cleanup:
- delete dac;
-
return 0;
}
diff --git a/projects/examples/crtsine.vcproj b/projects/examples/crtsine.vcproj
new file mode 100755
index 0000000..b7dc8a8
--- /dev/null
+++ b/projects/examples/crtsine.vcproj
@@ -0,0 +1,346 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/duplex.cpp b/projects/examples/duplex.cpp
new file mode 100644
index 0000000..5e63cd7
--- /dev/null
+++ b/projects/examples/duplex.cpp
@@ -0,0 +1,131 @@
+/******************************************/
+/*
+ duplex.cpp
+ by Gary P. Scavone, 2006-2007.
+
+ This program opens a duplex stream and passes
+ input directly through to the output.
+*/
+/******************************************/
+
+#include "RtAudio.h"
+#include
+
+/*
+typedef signed long MY_TYPE;
+#define FORMAT RTAUDIO_SINT24
+
+typedef char MY_TYPE;
+#define FORMAT RTAUDIO_SINT8
+
+typedef signed short MY_TYPE;
+#define FORMAT RTAUDIO_SINT16
+
+typedef signed long MY_TYPE;
+#define FORMAT RTAUDIO_SINT32
+
+typedef float MY_TYPE;
+#define FORMAT RTAUDIO_FLOAT32
+*/
+
+typedef double MY_TYPE;
+#define FORMAT RTAUDIO_FLOAT64
+
+void usage( void ) {
+ // Error function in case of incorrect command-line
+ // argument specifications
+ std::cout << "\nuseage: duplex N fs \n";
+ std::cout << " where N = number of channels,\n";
+ std::cout << " fs = the sample rate,\n";
+ std::cout << " iDevice = optional input device to use (default = 0),\n";
+ std::cout << " oDevice = optional output device to use (default = 0),\n";
+ std::cout << " iChannelOffset = an optional input channel offset (default = 0),\n";
+ std::cout << " and oChannelOffset = optional output channel offset (default = 0).\n\n";
+ exit( 0 );
+}
+
+int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+ double streamTime, RtAudioStreamStatus status, void *data )
+{
+ // Since the number of input and output channels is equal, we can do
+ // a simple buffer copy operation here.
+ if ( status ) std::cout << "Stream over/underflow detected." << std::endl;
+
+ unsigned long *bytes = (unsigned long *) data;
+ memcpy( outputBuffer, inputBuffer, *bytes );
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned int channels, fs, bufferBytes, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0;
+
+ // Minimal command-line checking
+ if (argc < 3 || argc > 7 ) usage();
+
+ RtAudio adac;
+ if ( adac.getDeviceCount() < 1 ) {
+ std::cout << "\nNo audio devices found!\n";
+ exit( 0 );
+ }
+
+ channels = (unsigned int) atoi(argv[1]);
+ fs = (unsigned int) atoi(argv[2]);
+ if ( argc > 3 )
+ iDevice = (unsigned int) atoi(argv[3]);
+ if ( argc > 4 )
+ oDevice = (unsigned int) atoi(argv[4]);
+ if ( argc > 5 )
+ iOffset = (unsigned int) atoi(argv[5]);
+ if ( argc > 6 )
+ oOffset = (unsigned int) atoi(argv[6]);
+
+ // Let RtAudio print messages to stderr.
+ adac.showWarnings( true );
+
+ // Set the same number of channels for both input and output.
+ unsigned int bufferFrames = 512;
+ RtAudio::StreamParameters iParams, oParams;
+ iParams.deviceId = iDevice;
+ iParams.nChannels = channels;
+ iParams.firstChannel = iOffset;
+ oParams.deviceId = oDevice;
+ oParams.nChannels = channels;
+ oParams.firstChannel = oOffset;
+
+ RtAudio::StreamOptions options;
+ //options.flags |= RTAUDIO_NONINTERLEAVED;
+
+ try {
+ adac.openStream( &oParams, &iParams, FORMAT, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options );
+ }
+ catch ( RtError& e ) {
+ std::cout << '\n' << e.getMessage() << '\n' << std::endl;
+ exit( 0 );
+ }
+
+ bufferBytes = bufferFrames * channels * sizeof( MY_TYPE );
+
+ // Test RtAudio functionality for reporting latency.
+ std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl;
+
+ try {
+ adac.startStream();
+
+ char input;
+ std::cout << "\nRunning ... press to quit (buffer frames = " << bufferFrames << ").\n";
+ std::cin.get(input);
+
+ // Stop the stream.
+ adac.stopStream();
+ }
+ catch ( RtError& e ) {
+ std::cout << '\n' << e.getMessage() << '\n' << std::endl;
+ goto cleanup;
+ }
+
+ cleanup:
+ if ( adac.isStreamOpen() ) adac.closeStream();
+
+ return 0;
+}
diff --git a/projects/examples/duplex.dsp b/projects/examples/duplex.dsp
new file mode 100755
index 0000000..cb2aa46
--- /dev/null
+++ b/projects/examples/duplex.dsp
@@ -0,0 +1,161 @@
+# Microsoft Developer Studio Project File - Name="duplex" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=duplex - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "duplex.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "duplex.mak" CFG="duplex - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "duplex - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "duplex - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "duplex - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "duplex___Win32_Release"
+# PROP BASE Intermediate_Dir "duplex___Win32_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__WINDOWS_ASIO__" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "duplex - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "duplex___Win32_Debug"
+# PROP BASE Intermediate_Dir "duplex___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__WINDOWS_ASIO__" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "duplex - Win32 Release"
+# Name "duplex - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\src\asio\asio.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\asiodrivers.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\asiolist.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\duplex.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\iasiothiscallresolver.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\RtAudio.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\src\asio\asio.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\asiodrivers.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\asiodrvr.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\asiolist.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\asiosys.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\ginclude.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\iasiodrv.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\iasiothiscallresolver.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\RtAudio.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\RtError.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/projects/examples/duplex.vcproj b/projects/examples/duplex.vcproj
new file mode 100755
index 0000000..70e4fd0
--- /dev/null
+++ b/projects/examples/duplex.vcproj
@@ -0,0 +1,290 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/examples.dsw b/projects/examples/examples.dsw
index ea2061a..1187690 100644
--- a/projects/examples/examples.dsw
+++ b/projects/examples/examples.dsw
@@ -39,6 +39,18 @@ Package=<4>
###############################################################################
+Project: "duplex"=".\duplex.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "foursine"=".\foursine.dsp" - Package Owner=<4>
Package=<5>
@@ -87,18 +99,6 @@ Package=<4>
###############################################################################
-Project: "io"=".\io.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
Project: "play"=".\play.dsp" - Package Owner=<4>
Package=<5>
@@ -123,6 +123,18 @@ Package=<4>
###############################################################################
+Project: "probe"=".\probe.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "record"=".\record.dsp" - Package Owner=<4>
Package=<5>
diff --git a/projects/examples/foursine.vcproj b/projects/examples/foursine.vcproj
new file mode 100755
index 0000000..66b5efd
--- /dev/null
+++ b/projects/examples/foursine.vcproj
@@ -0,0 +1,390 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/grains.cpp b/projects/examples/grains.cpp
index 0268cbc..2ab6c2b 100644
--- a/projects/examples/grains.cpp
+++ b/projects/examples/grains.cpp
@@ -8,12 +8,13 @@
// This tick() function handles sample computation only. It will be
// called automatically when the system needs a new buffer of audio
// samples.
-int tick(char *buffer, int bufferSize, void *dataPointer)
+int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+ double streamTime, RtAudioStreamStatus status, void *dataPointer )
{
Granulate *grani = (Granulate *) dataPointer;
- register StkFloat *samples = (StkFloat *) buffer;
+ register StkFloat *samples = (StkFloat *) outputBuffer;
- for ( int i=0; itick();
return 0;
@@ -49,7 +50,7 @@ int main( int argc, char *argv[] )
// Set the global sample rate before creating class instances.
Stk::setSampleRate( 44100.0 );
- RtAudio *dac = 0;
+ RtAudio dac;
Granulate grani;
grani.setRandomFactor( random );
grani.setStretch( stretch );
@@ -63,22 +64,24 @@ int main( int argc, char *argv[] )
}
grani.setVoices( N );
- // Figure out how many bytes in an StkFloat and setup the RtAudio object.
+ // Figure out how many bytes in an StkFloat and setup the RtAudio stream.
+ RtAudio::StreamParameters parameters;
+ parameters.deviceId = dac.getDefaultOutputDevice();
+ parameters.nChannels = 1;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
- int bufferSize = RT_BUFFER_SIZE;
+ unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
- dac = new RtAudio(0, 1, 0, 0, format, (int)Stk::sampleRate(), &bufferSize, 4);
+ dac.openStream( ¶meters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&grani );
}
- catch (RtError& error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
try {
- dac->setStreamCallback(&tick, (void *)&grani);
- dac->startStream();
+ dac.startStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -87,19 +90,17 @@ int main( int argc, char *argv[] )
// Block waiting here.
char keyhit;
std::cout << "\nPlaying ... press to quit.\n";
- std::cin.get(keyhit);
+ std::cin.get( keyhit );
// Shut down the callback and output stream.
try {
- dac->cancelStreamCallback();
- dac->closeStream();
+ dac.closeStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
}
cleanup:
- delete dac;
return 0;
}
diff --git a/projects/examples/grains.vcproj b/projects/examples/grains.vcproj
new file mode 100755
index 0000000..78fed15
--- /dev/null
+++ b/projects/examples/grains.vcproj
@@ -0,0 +1,312 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/inetIn.vcproj b/projects/examples/inetIn.vcproj
new file mode 100755
index 0000000..579f521
--- /dev/null
+++ b/projects/examples/inetIn.vcproj
@@ -0,0 +1,415 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/inetOut.vcproj b/projects/examples/inetOut.vcproj
new file mode 100755
index 0000000..0182d61
--- /dev/null
+++ b/projects/examples/inetOut.vcproj
@@ -0,0 +1,372 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/io.cpp b/projects/examples/io.cpp
deleted file mode 100644
index 24e0d40..0000000
--- a/projects/examples/io.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/******************************************/
-/*
- Example program for realtime input/output
- by Gary P. Scavone, 2000.
-
- NOTE: This program makes use of blocking audio
- input/output routines. On systems where the
- underlying audio API is based on a callback scheme
- (Macintosh OS-X, Windows ASIO, and Linux JACK), these
- routines are not fully robust (over/underruns can
- happen with some frequency). See the STK tutorial
- for example programs using callback schemes and/or
- visit the RtAudio tutorial page
- (http://music.mcgill.ca/~gary/rtaudio/) for more
- information.
-
- This program reads N channels of realtime audio input
- for a specified amount of time and immediately play
- them back in realtime (duplex mode). This program
- also demonstrates the use of FIFO scheduling
- priority. To be run with such priority, the program
- must be set suid (chmod +s) and owned by root.
-*/
-/******************************************/
-
-#include "RtDuplex.h"
-#include
-
-#if defined(__OS_LINUX__) || defined(__OS_IRIX__)
- #include
- #include
-#endif
-
-void usage(void) {
- // Error function in case of incorrect command-line
- // argument specifications.
- printf("\nuseage: io N time \n");
- printf(" where N = number of channels,\n");
- printf(" and time = the amount of time to run (in seconds).\n\n");
- exit(0);
-}
-
-int
-main(int argc, char *argv[])
-{
- // Minimal command-line checking.
- if (argc != 3) usage();
-
- unsigned int channels = (unsigned int) atoi(argv[1]);
- double time = atof(argv[2]);
-
- // If you want to change the default sample rate (set in Stk.h), do
- // it before instantiating any objects! If the sample rate is
- // specified in the command line, it will override this setting.
- Stk::setSampleRate( 44100.0 );
-
- // Open the realtime duplex device.
- RtDuplex *inout = 0;
- try {
- inout = new RtDuplex(channels, Stk::sampleRate(), 0, RT_BUFFER_SIZE, 10);
- }
- catch (StkError &) {
- exit(0);
- }
-
-#if defined(__OS_LINUX__) || defined(__OS_IRIX__)
- // Set schedulling priority to SCHED_FIFO.
- struct sched_param p;
- int min, max, priority;
-
- if (!getuid() || !geteuid()) {
- min=sched_get_priority_min(SCHED_FIFO);
- max=sched_get_priority_max(SCHED_FIFO);
- priority=min+(max-min)/2;
- p.sched_priority=priority;
- if (sched_setscheduler(0, SCHED_FIFO, &p)==-1) {
- fprintf(stderr, "\nCould not activate scheduling with priority %d\n", priority);
- }
- seteuid(getuid());
- }
-#endif
-
- // Here's the runtime loop
- unsigned long i, counter = 0;
- StkFloat *newFrame = new StkFloat[channels];
- const StkFloat *lastFrame = inout->lastFrame();
- unsigned long samples = (unsigned long) (time * Stk::sampleRate());
- while ( counter < samples ) {
- for ( i=0; itickFrame( newFrame );
- counter++;
-#if defined(__OS_LINUX__) || defined(__OS_IRIX__)
- if ( counter % 1024 == 0 )
- sched_yield();
-#endif
- }
-
- // Clean up
- delete [] newFrame;
- delete inout;
- return 0;
-}
diff --git a/projects/examples/io.dsp b/projects/examples/io.dsp
deleted file mode 100644
index cca49a8..0000000
--- a/projects/examples/io.dsp
+++ /dev/null
@@ -1,126 +0,0 @@
-# Microsoft Developer Studio Project File - Name="io" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=io - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "io.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "io.mak" CFG="io - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "io - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "io - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "io - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../include" /D "NDEBUG" /D "__WINDOWS_DS__" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__LITTLE_ENDIAN__" /D "__WINDOWS_MM__" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "io - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "io___Win32_Debug"
-# PROP BASE Intermediate_Dir "io___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /D "_DEBUG" /D "__WINDOWS_DS__" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__LITTLE_ENDIAN__" /D "__WINDOWS_MM__" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "io - Win32 Release"
-# Name "io - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\io.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\RtAudio.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\RtDuplex.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\src\Stk.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\include\RtAudio.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\RtDuplex.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\Stk.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/projects/examples/libMakefile.in b/projects/examples/libMakefile.in
index e16dff8..15bd48c 100644
--- a/projects/examples/libMakefile.in
+++ b/projects/examples/libMakefile.in
@@ -1,6 +1,6 @@
### STK examples Makefile - for various flavors of unix
-PROGRAMS = sine play record io inetIn inetOut sineosc rtsine crtsine bethree controlbee foursine threebees playsmf grains
+PROGRAMS = sine sineosc foursine
RM = /bin/rm
INCLUDE = @include@
@@ -19,6 +19,7 @@ LIBRARY += @frameworks@
REALTIME = @realtime@
ifeq ($(REALTIME),yes)
+ PROGRAMS += play record io inetIn inetOut rtsine crtsine bethree controlbee threebees playsmf grains
DEFS += @audio_apis@
endif
@@ -41,14 +42,17 @@ strip :
play: play.cpp
$(CC) $(CFLAGS) $(DEFS) -o play play.cpp -L../../src $(LIBRARY) -lstk
+probe: probe.cpp
+ $(CC) $(CFLAGS) $(DEFS) -o probe probe.cpp -L../../src $(LIBRARY) -lstk
+
record: record.cpp
$(CC) $(CFLAGS) $(DEFS) -o record record.cpp -L../../src $(LIBRARY) -lstk
sine: sine.cpp
$(CC) $(CFLAGS) $(DEFS) -o sine sine.cpp -L../../src $(LIBRARY) -lstk
-io: io.cpp
- $(CC) $(CFLAGS) $(DEFS) -o io io.cpp -L../../src $(LIBRARY) -lstk
+duplex: duplex.cpp
+ $(CC) $(CFLAGS) $(DEFS) -o duplex duplex.cpp -L../../src $(LIBRARY) -lstk
inetIn: inetIn.cpp
$(CC) $(CFLAGS) $(DEFS) -o inetIn inetIn.cpp -L../../src $(LIBRARY) -lstk
diff --git a/projects/examples/play.cpp b/projects/examples/play.cpp
index b113a91..a2c41fe 100644
--- a/projects/examples/play.cpp
+++ b/projects/examples/play.cpp
@@ -38,10 +38,11 @@ void usage(void) {
// This tick() function handles sample computation only. It will be
// called automatically when the system needs a new buffer of audio
// samples.
-int tick(char *buffer, int bufferSize, void *dataPointer)
+int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+ double streamTime, RtAudioStreamStatus status, void *userData )
{
- FileWvIn *input = (FileWvIn *) dataPointer;
- register StkFloat *samples = (StkFloat *) buffer;
+ FileWvIn *input = (FileWvIn *) userData;
+ register StkFloat *samples = (StkFloat *) outputBuffer;
input->tickFrame( frames );
for ( unsigned int i=0; i 4) usage();
+ if ( argc < 3 || argc > 4 ) usage();
// Set the global sample rate before creating class instances.
Stk::setSampleRate( (StkFloat) atof(argv[2]) );
// Initialize our WvIn and RtAudio pointers.
- RtAudio *dac = 0;
- FileWvIn *input = 0;
+ RtAudio dac;
+ FileWvIn input;
// Try to load the soundfile.
try {
- input = new FileWvIn( argv[1] );
+ input.openFile( argv[1] );
}
catch (StkError &) {
exit(0);
@@ -77,21 +78,25 @@ int main(int argc, char *argv[])
// Set input read rate based on the default STK sample rate.
double rate = 1.0;
- rate = input->getFileRate() / Stk::sampleRate();
+ rate = input.getFileRate() / Stk::sampleRate();
if ( argc == 4 ) rate *= atof(argv[3]);
- input->setRate( rate );
+ input.setRate( rate );
+
+ input.ignoreSampleRateChange();
// Find out how many channels we have.
- int channels = input->getChannels();
+ int channels = input.getChannels();
- // Define and open the realtime output device.
- // Figure out how many bytes in an StkFloat and setup the RtAudio object.
+ // Figure out how many bytes in an StkFloat and setup the RtAudio stream.
+ RtAudio::StreamParameters parameters;
+ parameters.deviceId = dac.getDefaultOutputDevice();
+ parameters.nChannels = channels;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
- int bufferSize = RT_BUFFER_SIZE;
+ unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
- dac = new RtAudio(0, channels, 0, 0, format, (int)Stk::sampleRate(), &bufferSize, 4);
+ dac.openStream( ¶meters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&input );
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -100,13 +105,12 @@ int main(int argc, char *argv[])
(void) signal(SIGINT, finish);
// Resize the StkFrames object appropriately.
- frames.resize( bufferSize, channels );
+ frames.resize( bufferFrames, channels );
try {
- dac->setStreamCallback(&tick, (void *)input);
- dac->startStream();
+ dac.startStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -118,15 +122,12 @@ int main(int argc, char *argv[])
// By returning a non-zero value in the callback above, the stream
// is automatically stopped. But we should still close it.
try {
- dac->cancelStreamCallback();
- dac->closeStream();
+ dac.closeStream();
}
- catch (RtError &error) {
+ catch ( RtError &error ) {
error.printMessage();
}
cleanup:
- delete input;
- delete dac;
return 0;
}
diff --git a/projects/examples/play.vcproj b/projects/examples/play.vcproj
new file mode 100755
index 0000000..aaf7009
--- /dev/null
+++ b/projects/examples/play.vcproj
@@ -0,0 +1,329 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/playsmf.vcproj b/projects/examples/playsmf.vcproj
new file mode 100755
index 0000000..6fb9139
--- /dev/null
+++ b/projects/examples/playsmf.vcproj
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/projects/examples/probe.cpp b/projects/examples/probe.cpp
new file mode 100644
index 0000000..e756346
--- /dev/null
+++ b/projects/examples/probe.cpp
@@ -0,0 +1,86 @@
+/******************************************/
+/*
+ probe.cpp
+ by Gary P. Scavone, 2001
+
+ Probe audio system and prints device info.
+*/
+/******************************************/
+
+#include "RtAudio.h"
+#include
+#include