mirror of
https://github.com/thestk/stk
synced 2026-01-11 20:11:52 +00:00
Version 4.2.0
This commit is contained in:
committed by
Stephen Sinclair
parent
cf06b7598b
commit
a6381b9d38
10
INSTALL
10
INSTALL
@@ -6,7 +6,7 @@ The Synthesis ToolKit in C++ can be used in a variety of ways, depending on your
|
||||
|
||||
To configure and compile (on Unix systems):
|
||||
|
||||
1. Unpack the STK distribution (tar -xzf stk-4.x.tar.gz).
|
||||
1. Unpack the STK distribution (tar -xzf stk-4.x.x.tar.gz).
|
||||
2. From within the directory containing this file, run configure:
|
||||
|
||||
./configure
|
||||
@@ -18,11 +18,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 (linux only)
|
||||
--with-alsa = choose native ALSA API support (default, linux only)
|
||||
--with-jack = choose native JACK server API support (linux only)
|
||||
--enable-midiator = enable native MS-124W MIDI support (linux only)
|
||||
--with-oss = choose native OSS API support (linux only)
|
||||
|
||||
At the moment, it is not possible to specify more than one Linux audio API, though this will change in the next release. 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 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):
|
||||
|
||||
./configure RAWWAVE_PATH="/home/gary/rawwaves/"
|
||||
./configure INCLUDE_PATH="/home/gary/include/"
|
||||
@@ -33,7 +33,7 @@ If you wish to use a different compiler than that selected by configure, specify
|
||||
|
||||
./configure CXX=CC
|
||||
|
||||
In addition, a linux RPM is available from the STK WWW site (http://www-ccrma.stanford.edu/software/stk/).
|
||||
In addition, a linux RPM is available from the Planet CCRMA WWW site (http://ccrma.stanford.edu/planetccrma/software/).
|
||||
|
||||
|
||||
For Windows Users:
|
||||
|
||||
57
README
57
README
@@ -8,7 +8,7 @@ include: STK class header files
|
||||
src: STK class source files
|
||||
rawwaves: STK audio files (1-channel, 16-bit, big-endian)
|
||||
doc: STK documentation
|
||||
projects: example STK programs
|
||||
projects: example STK projects and programs
|
||||
|
||||
Please read the Legal and Ethical notes near the bottom of this document.
|
||||
|
||||
@@ -17,7 +17,7 @@ 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 C++. 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 8 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 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 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).
|
||||
|
||||
@@ -31,13 +31,15 @@ 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.
|
||||
|
||||
|
||||
WHAT'S NEW:
|
||||
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. Thus, backward compatability has not been a priority. 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 which 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.
|
||||
|
||||
Realtime audio input capabilities were added to STK with release 3.0, though the behavior of such is very hardware dependent. Under Linux 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.
|
||||
|
||||
@@ -46,7 +48,7 @@ For those who wish to make a library from the core STK classes, the configure sc
|
||||
|
||||
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 prc@cs.princeton.edu and gary@ccrma.stanford.edu.
|
||||
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:
|
||||
@@ -62,53 +64,30 @@ The good news is that large hunks of the techniques used here are public domain.
|
||||
|
||||
FURTHER READING:
|
||||
|
||||
For complete documentation on this ToolKit, the classes, etc., see the doc directory of the distribution or surf to http://www-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 (see Object.cpp), 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.
|
||||
|
||||
1) I needed to port many of the things I've done
|
||||
into something which is generic enough to port
|
||||
further to different machines.
|
||||
1) I needed to port many of the things I've done into something which is generic enough to port further to different machines.
|
||||
|
||||
2) I really plan to document this stuff, so that
|
||||
you don't have to be me to figure out what's
|
||||
going on. (I'll probably be sorry I said this
|
||||
in a couple of years, when even I can't figure
|
||||
out what I was thinking.)
|
||||
2) I really plan to document this stuff, so that you don't have to be me to figure out what's going on. (I'll probably be sorry I said this in a couple of years, when even I can't figure out what I was thinking.)
|
||||
|
||||
3) The classic difficulties most people have in
|
||||
trying to implement physical models are:
|
||||
3) The classic difficulties most people have in trying to implement physical models are:
|
||||
|
||||
A) They have trouble understanding the papers,
|
||||
and/or in turning the theory into practice.
|
||||
A) They have trouble understanding the papers, and/or in turning the theory into practice.
|
||||
|
||||
B) The Physical Model instruments are a pain to get
|
||||
to oscillate, and coming up with stable and
|
||||
meaningful parameter values is required to
|
||||
get the models to work at all.
|
||||
B) The Physical Model instruments are a pain to get to oscillate, and coming up with stable and meaningful parameter values is required to get the models to work at all.
|
||||
|
||||
This set of C++ unit generators and instruments
|
||||
might help to diminish the scores of emails I
|
||||
get asking what to do with those block diagrams
|
||||
I put in my papers.
|
||||
This set of C++ unit generators and instruments might help to diminish the scores of emails I get asking what to do with those block diagrams I put in my papers.
|
||||
|
||||
4) I wanted to try some new stuff with modal synthesis,
|
||||
and implement some classic FM patches as well.
|
||||
4) I wanted to try some new stuff with modal synthesis, and implement some classic FM patches as well.
|
||||
|
||||
5) I wanted to reimplement, and newly implement
|
||||
more of the intelligent and physical performer
|
||||
models I've talked about in some of my papers.
|
||||
But I wanted to do it in a portable way, and in
|
||||
such a way that I can hook up modules quickly.
|
||||
I also wanted to make these instruments connectable
|
||||
to such player objects, so folks like Brad Garton
|
||||
who really think a lot about the players can connect
|
||||
them to my instruments, a lot about which I think.
|
||||
5) I wanted to reimplement, and newly implement more of the intelligent and physical performer models I've talked about in some of my papers. But I wanted to do it in a portable way, and in such a way that I can hook up modules quickly. I also wanted to make these instruments connectable to such player objects, so folks like Brad Garton who really think a lot about the players can connect them to my instruments, a lot about which I think.
|
||||
|
||||
6) More rationalizations to follow . . .
|
||||
|
||||
|
||||
29
configure.ac
29
configure.ac
@@ -1,5 +1,5 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(STK, 4.1.2, gary@ccrma.stanford.edu, stk)
|
||||
AC_INIT(STK, 4.2.0, 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)
|
||||
|
||||
@@ -48,12 +48,12 @@ fi
|
||||
AC_MSG_CHECKING(whether to compile debug version)
|
||||
AC_ARG_ENABLE(debug,
|
||||
[ --enable-debug = enable various debug output],
|
||||
[AC_SUBST( debug, [-D_STK_DEBUG_] ) AC_SUBST( cflags, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
|
||||
[AC_SUBST( debug, [] ) AC_SUBST( cflags, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
|
||||
[AC_SUBST( debug, ["-D_STK_DEBUG_ -D__RTAUDIO_DEBUG__"] ) AC_SUBST( cflags, ["-g -O2"] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
|
||||
[AC_SUBST( debug, [] ) AC_SUBST( cflags, [-O3] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
|
||||
|
||||
# Check compiler and use -Wall if gnu.
|
||||
if test $GXX = "yes" ; then
|
||||
AC_SUBST( warn, ["-Wall -g"] )
|
||||
AC_SUBST( warn, ["-Wall -g -Woverloaded-virtual -D__GXX__"] )
|
||||
fi
|
||||
|
||||
if test $realtime = yes; then
|
||||
@@ -64,20 +64,22 @@ if test $realtime = yes; then
|
||||
*-*-linux*)
|
||||
AC_SUBST( sound_api, [_NO_API_] )
|
||||
|
||||
# Look for ALSA library because we need it for RtMidi
|
||||
AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(STK in Linux requires the ALSA asound library for RtMidi!))
|
||||
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
|
||||
TEMP_LIBS=$LIBS
|
||||
AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
|
||||
AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
|
||||
LIBS="`pkg-config --cflags --libs jack` $TEMP_LIBS -lasound"
|
||||
audio_apis="-D__LINUX_JACK__"
|
||||
audio_apis="-D__LINUX_JACK__ $audio_apis"
|
||||
fi
|
||||
|
||||
# Look for Alsa flag
|
||||
AC_ARG_WITH(alsa, [ --with-alsa = choose native ALSA API support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_ALSA__] ) AC_MSG_RESULT(using ALSA)], )
|
||||
if test $sound_api = -D__LINUX_ALSA__; then
|
||||
AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
|
||||
audio_apis="-D__LINUX_ALSA__ $audio_apis"
|
||||
fi
|
||||
|
||||
@@ -87,18 +89,15 @@ if test $realtime = yes; then
|
||||
audio_apis="-D__LINUX_OSS__ $audio_apis"
|
||||
fi
|
||||
|
||||
# If no audio api flags specified, use OSS
|
||||
# If no audio api flags specified, use ALSA
|
||||
if [test $sound_api = _NO_API_;] then
|
||||
AC_SUBST( sound_api, [-D__LINUX_OSS__] )
|
||||
AC_MSG_RESULT(using OSS)
|
||||
AC_SUBST( audio_apis, [-D__LINUX_OSS__] )
|
||||
AC_MSG_RESULT(using ALSA)
|
||||
audio_apis="-D__LINUX_ALSA__ $audio_apis"
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(midiator, [ --enable-midiator = enable native MS-124W MIDI support (linux only)], [AC_SUBST( midiator, [-D__MIDIATOR__] )], [AC_SUBST( midiator, [] )])
|
||||
;;
|
||||
|
||||
*-sgi*)
|
||||
AC_SUBST( audio_apis, ["-D__IRIX_AL__ -LANG:std -w"] )
|
||||
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!) )
|
||||
@@ -110,8 +109,6 @@ if test $realtime = yes; then
|
||||
[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"] )
|
||||
# Explicitly link with c++ library.
|
||||
AC_CHECK_LIB(stdc++, printf, , AC_MSG_ERROR(Stk requires the C++ library!) )
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
@@ -4,11 +4,13 @@ By Perry R. Cook and Gary P. Scavone, 1995-2004.
|
||||
|
||||
STK Classes - See the HTML documentation in the html directory for complete information.
|
||||
|
||||
.- Envelope - ADSR
|
||||
|
||||
.- Generator - (Modulate, Noise, SingWave, Envelope)
|
||||
| | |
|
||||
| SubNoise ADSR
|
||||
| Asymp
|
||||
|
|
||||
|- Noise - SubNoise
|
||||
|
|
||||
|- Table
|
||||
|- Function - (Table, BowTable, JetTable, ReedTable)
|
||||
|
|
||||
|- WvIn - (WaveLoop, RtWvIn, TcpWvIn)
|
||||
|
|
||||
@@ -19,24 +21,14 @@ STK Classes - See the HTML documentation in the html directory for complete info
|
||||
| DelayL FormSwep
|
||||
| DelayA
|
||||
|
|
||||
|- Echo, Chorus, PitShift
|
||||
|
|
||||
|- RtAudio, RtMidi, Socket, Thread
|
||||
|- RtAudio, RtMidi, RtDuplex, Socket, Thread, Mutex
|
||||
Stk -|
|
||||
|- Reverb - (PRCRev, JCRev, NRev)
|
||||
|- Effect - (Echo, Chorus, PitShift, PRCRev, JCRev, NRev)
|
||||
|
|
||||
|- Modulate
|
||||
|
|
||||
|- SingWave
|
||||
|
|
||||
|- Voicer
|
||||
|- Voicer, Message, Skini, MidiFileIn, Phonemes, Sphere, Vector3D
|
||||
|
|
||||
|- Messager
|
||||
|
|
||||
|- SKINI
|
||||
|
|
||||
|- ReedTabl, JetTabl, BowTabl
|
||||
|
|
||||
| .- FM - (HevyMetl, PercFlut, Rhodey, Wurley, TubeBell, BeeThree, FMVoices)
|
||||
| |
|
||||
| |- Modal - ModalBar
|
||||
@@ -66,8 +58,11 @@ Stk -|
|
||||
|
||||
Master Class: Stk.cpp Sample rate, byte-swapping, error handling functionality
|
||||
|
||||
Sources: Envelope.cpp Linearly Goes to Target by Rate
|
||||
Sources: Generator.cpp Abstract Base Class for Various Source Signal Classes
|
||||
Function.cpp Abstract Base Class for Various Input/Output Mapping Classes
|
||||
Envelope.cpp Linearly Goes to Target by Rate
|
||||
ADSR.cpp ADSR Flavor of Envelope
|
||||
Asymp.cpp Exponentially Approaches Target
|
||||
Noise.cpp Random Number Generator
|
||||
SubNoise.cpp Random Numbers each N samples
|
||||
Table.cpp Lookup Table (assumes given data in big-endian format)
|
||||
@@ -140,7 +135,7 @@ Shakers.cpp PhISM statistical model for shakers and real-world sound effects
|
||||
Mesh2D.cpp Two-dimensional, rectilinear digital waveguide mesh.
|
||||
Whistle.cpp Hybrid physical/spectral model of a police whistle.
|
||||
|
||||
Reverb.cpp Reverberator Effects Processor Master Class for reverberators
|
||||
Effect.cpp Effects Processor Base Class
|
||||
JCRev.cpp Chowning Reverberator 3 series allpass units, 4 parallel combs, 2 stereo delays
|
||||
NRev.cpp Another famous CCRMA Reverb 8 allpass, 6 parallel comb filters
|
||||
PRCRev.cpp Dirt Cheap Reverb by Cook 2 allpass, 2 comb filters
|
||||
@@ -160,7 +155,7 @@ demo.cpp Demonstration program for most synthesis algorithms
|
||||
effects.cpp Effects demonstration program
|
||||
ragamatic.cpp Nirvana just waiting to happen
|
||||
|
||||
SKINI.cpp SKINI file/message parser object
|
||||
Skini.cpp SKINI file/message parser object
|
||||
SKINI.msg #defines for often used and universal MIDI/SKINI symbols
|
||||
SKINI.tbl Table of SKINI messages
|
||||
|
||||
|
||||
@@ -4,20 +4,15 @@ By Perry R. Cook and Gary P. Scavone, 1995-2004.
|
||||
|
||||
Please read the file README and INSTALL for more general STK information.
|
||||
|
||||
Realtime support for Linux is currently using either the Open Sound System (OSS) or the Advanced Linux Sound Architecture (ALSA) sound and MIDI APIs. The free version of OSS 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. The API is selected during compilation using either the __LINUX_ALSA__ or __LINUX_OSS__ definitions. The configure script uses the OSS API by default. The ALSA API can be selected by passing the "--with-alsa" option to configure.
|
||||
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 <TT>pthread</TT> library. The OSS audio API can be selected by passing the "--with-oss" option to configure.
|
||||
|
||||
STK should compile without much trouble under Linux ... afterall, it is primarily developed on Linux platforms. 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.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
MIDIATOR SERIAL PORT MIDI SUPPORT:
|
||||
|
||||
STK now has special support for the MIDIator serial port MIDI interface. This is of primary interest to us laptop users, whose computers usually don't have a gameport. If you want to buy one of these devices, make sure you get the MS-124w model (www.midiator.com). For it to work in STK, you must provide the __MIDIATOR__ definition during compilation (in addition to either __LINUX_ALSA__ or __LINUX_OSS__) or pass the "--enable-midiator" option to configure.
|
||||
|
||||
There are a few things that need to be done on your system to get the MIDIator working. Assuming you wish to attach the MIDIator to serial port 0, add the following lines to your bootup sequence in /etc/rc.d/rc.local:
|
||||
|
||||
setserial /dev/ttyS0 baud_base 57600
|
||||
setserial /dev/ttyS0 divisor 1
|
||||
|
||||
You may need to specify the full path to the setserial function, depending on how your PATH variable is set up. Also, you may need to modify the permissions of /dev/ttyS0 (chmod a+rwx). And finally, the MIDIator should be set for "single addresssed" mode (the S/A switch on S and the A/B switch on A), which puts identical output on all 4 MIDI output ports. It is possible to use the MIDIator in a "multi-port" mode, though I'm not currently supporting that in STK.
|
||||
MIDIator support has been removed from RtMidi with STK versions 4.2 and higher. If you really need it, you can contact us to get an old distribution.
|
||||
|
||||
NOTE REGARDING PTHREADS:
|
||||
|
||||
|
||||
@@ -6,17 +6,16 @@ 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.
|
||||
|
||||
It is necessary to download the OS X developer kit in order to compile STK. STK was successfully tested on OS X version 10.2.
|
||||
It is necessary to install the OS X developer kit in order to compile STK. STK was successfully tested on OS X versions 10.2 and 10.3.
|
||||
|
||||
The internal Macintosh audio hardware typically supports a sample rate of 44100 Hz only. Therefore, it is necessary to either specify this rate as a command-line option to the STK example programs or to change the default sample rate inside the Stk.h file before compilation. In addition, the RT_BUFFER_SIZE, specified in Stk.h, could be increased (to a higher power of two) for more robust performance.
|
||||
The internal Macintosh audio hardware typically supports a sample rate of 44100 Hz only. The default STK sample rate is now 44100 Hz and all current example programs use this rate. However, it is possible to manually override this value in some programs from the command-line. The default sample rate is set in Stk.h. In addition, the RT_BUFFER_SIZE, specified in Stk.h, could be increased (to a higher power of two) for more robust performance.
|
||||
|
||||
There is a potential conflict between the STK Delay class and a Delay() function declared in OSUtils.h (which is included via <CoreServices/CoreServices.h>). In general, this conflict can be avoided via the use of a namespace (an explicit Delay::Delay declaration), though this made the Windows Visual C++ compiler barf. If you use STK classes within a project that includes the OSUtils.h file, you will likely need to make changes in STK classes that use the Delay class.
|
||||
|
||||
|
||||
Tcl/Tk on OS X:
|
||||
|
||||
The tcl/tk interpreter does not ship by default with OS X, but must be downloaded from the internet. The latest Tcl/Tk Aqua distribution (http://www.apple.com/downloads/macosx/unix_open_source/tcltk.html) has been successfully tested on a 10.2 system. The default installation will place a link to the wish interpretor at /usr/bin/wish.
|
||||
The tcl/tk interpreter does not ship by default with OS X, but must be downloaded from the internet. The latest Tcl/Tk Aqua distribution (http://www.apple.com/downloads/macosx/unix_open_source/tcltk.html) has been successfully tested on 10.2 and 10.3 systems. The default installation will place a link to the wish interpretor at /usr/bin/wish.
|
||||
|
||||
Initial tests have shown somewhat poor response between changes made in the tcl/tk script and the resulting audio updates.
|
||||
It appears that socket support in Tcl/Tk on OS X uses the Nagle algorithm, which produces poor response between changes made in the tcl/tk script and the resulting audio updates. Note that this is only a problem when using a socket connection from a Tcl/Tk script.
|
||||
|
||||
It is possible to connect a tcl/tk interface to an STK program via a socket connection. However, the tcl/tk interpreter does not appear to properly close the socket connection during disconnection. It is therefore necessary to type "Exit" in the STK program terminal window to properly exit the STK program.
|
||||
|
||||
@@ -8,6 +8,8 @@ The project Makefiles are created by configure. If you have trouble running "ma
|
||||
|
||||
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.
|
||||
|
||||
The __IRIX_AL__ and __IRIX_MD__ preprocessor definitions are required for realtime audio and MIDI support.
|
||||
|
||||
NOTE REGARDING PTHREADS:
|
||||
|
||||
Since release 3.1, STK has used the pthread API under Irix. It appears that pthread functionality is standard on SGI, so this change shouldn't cause any problems. If I'm wrong, let me know!
|
||||
|
||||
@@ -15,7 +15,7 @@ Both the DirectSound and Steinberg ASIO audio APIs are supported for realtime au
|
||||
|
||||
When using the DirectSound API for audio input, latency is typically pretty horrendous (should we be surprised?). Also, there is a slight chance you don't have DirectSoundCapture support on your computer. If not, you should download the DirectX 6.0 (or higher) runtime libraries from Microsoft's WWW site (http://www.microsoft.com/directx/download.asp) in order to run the pre-compiled STK executables for Windoze. The last time I checked, there was no DirectSoundCapture support for WindowsNT ... you'll have to switch to Windows 2000 or XP or use an ASIO driver. I stopped supporting the WinMM audio output code with release 3.2.
|
||||
|
||||
Realtime MIDI input is supported using the winmm.lib API.
|
||||
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":
|
||||
|
||||
@@ -27,7 +27,7 @@ Visual C++ 6.0 workspaces have been created for the various STK projects. Every
|
||||
|
||||
4. Under C/C++ > Preprocessor: Add "../../include" directory to the "extra include" field.
|
||||
|
||||
5. Under C/C++ > Preprocessor: Add "__WINDOWS_DS__" to the definitions field.
|
||||
5. Under C/C++ > Preprocessor: Add "__WINDOWS_DS__", "__WINDOWS_MM__", and "__LITTLE_ENDIAN__ to the definitions field.
|
||||
|
||||
6. Add all the necessary files to the project.
|
||||
|
||||
@@ -49,7 +49,7 @@ WINDOWS 95/98:
|
||||
|
||||
PLAY SKINI SCOREFILES IN REALTIME:
|
||||
|
||||
demo Clarinet -or < scores/streetsf.ski
|
||||
demo Clarinet -or -if scores/streetsf.ski
|
||||
|
||||
USE TCL/TK GUIs FOR REALTIME CONTROL:
|
||||
|
||||
|
||||
@@ -2,6 +2,28 @@ The Synthesis ToolKit in C++ (STK)
|
||||
|
||||
By Perry R. Cook and Gary P. Scavone, 1995-2004.
|
||||
|
||||
v4.2.0: (4 October 2004)
|
||||
- simultaneous multiple audio APIs supported at compile time
|
||||
- fixed hidden overloaded virtual functions
|
||||
- new Asymp exponential envelope class
|
||||
- various changes to better conform to standard C++ programming practices
|
||||
- MY_FLOAT type converted to StkFloat and changed throughout (use treesed utility to search/replace in old files)
|
||||
- most example programs rewritten to use an audio callback paradigm (which works better in OS-X)
|
||||
- new StkFrames class for vectorized multichannel data and associated new tick() functions making use of StkFrames
|
||||
- new RtMidi class with MIDI output capabilities (API changes)
|
||||
- new MidiFileIn class for reading MIDI files
|
||||
- revised Filter classes to use std::vectors for coefficients (API changes)
|
||||
- revised Messager class (now queues messages for retrieval) (API changes)
|
||||
- new abstract parent Effect class for various effects
|
||||
- added setT60 function to all reverbs
|
||||
- new abstract parent Generator class for various signal sources
|
||||
- new abstract parent Function class for tables and various non-linear functions
|
||||
- Skini class completely rewritten (simplified) using the C++ STL (API changes)
|
||||
- WvOut classes now clip to -1.0 to +1.0 and report out of range
|
||||
- new Mutex class
|
||||
- turned Nagle algorithm off by default in Socket class
|
||||
- error reporting standardized in all classes
|
||||
|
||||
v4.1.3: (22 March 2004)
|
||||
- bug fix in RtAudio for Windows DirectSound output only support
|
||||
|
||||
@@ -108,7 +130,7 @@ v3.0: (10 October 1999)
|
||||
- added RawWvOut class
|
||||
- new WvIn class with RawWvIn, SndWvIn, WavWvIn, MatWvIn, and RTWvIn subclasses
|
||||
- removed RawWave, RawShot, RawInterp, and RawLoop classes (supplanted by RawWvIn)
|
||||
- multi-channel data support in WvIn and WvOut classes using MY_MULTI data type (pointer to MY_FLOAT) and the methods mtick() and mlastOutput()
|
||||
- multi-channel data support in WvIn and WvOut classes using MY_MULTI data type (pointer to StkFloat) and the methods mtick() and mlastOutput()
|
||||
- now writing to primary buffer under Windoze when allowed by hardware
|
||||
- cleaned up Object.h a bit
|
||||
- pulled various utility and thread functions out of syntmono.cpp (to aid readability of the code)
|
||||
|
||||
111
doc/SKINI.txt
111
doc/SKINI.txt
@@ -10,7 +10,7 @@ for the Synthesis Toolkit in C++ by Perry R. Cook.
|
||||
* A SKINI Haiku. *
|
||||
*********************************
|
||||
|
||||
Profound thanks to Dan Trueman, Brad Garton, and
|
||||
Profound thanks to Dan trueman, Brad Garton, and
|
||||
Gary Scavone for input on this revision. Thanks
|
||||
also to MIDI, the NeXT MusicKit, ZIPI and all
|
||||
the creators and modifiers of these for good bases
|
||||
@@ -120,7 +120,7 @@ upon/from which to build and depart.
|
||||
|
||||
4) C Files Used To Implement SKINI
|
||||
|
||||
SKINI.cpp is an object which can either open a SKINI file, and
|
||||
Skini.cpp is an object which can either open a SKINI file, and
|
||||
successively read and parse lines of text as SKINI strings, or
|
||||
accept strings from another object and parse them. The latter
|
||||
functionality would be used by a socket, pipe, or other connection
|
||||
@@ -128,11 +128,11 @@ upon/from which to build and depart.
|
||||
but not restricted to real time.
|
||||
|
||||
SKINI.msg should be included by anything wanting to use the
|
||||
SKINI.cpp object. This is not mandatory, but use of the __SK_blah_
|
||||
Skini.cpp object. This is not mandatory, but use of the __SK_blah_
|
||||
symbols which are defined in the .msg file will help to ensure
|
||||
clarity and consistency when messages are added and changed.
|
||||
|
||||
SKINI.tbl is used only by the SKINI parser object (SKINI.cpp).
|
||||
SKINI.tbl is used only by the SKINI parser object (Skini.cpp).
|
||||
In the file SKINI.tbl, an array of structures is declared and
|
||||
assigned values which instruct the parser as to what the message
|
||||
types are, and what the fields mean for those message types.
|
||||
@@ -240,7 +240,7 @@ upon/from which to build and depart.
|
||||
7) The SKINI.tbl File, How Messages are Parsed:
|
||||
|
||||
The SKINI.tbl file contains an array of structures which
|
||||
are accessed by the parser object SKINI.cpp. The struct is:
|
||||
are accessed by the parser object Skini.cpp. The struct is:
|
||||
|
||||
struct SKINISpec { char messageString[32];
|
||||
long type;
|
||||
@@ -322,70 +322,67 @@ upon/from which to build and depart.
|
||||
|
||||
8) Objects using SKINI
|
||||
|
||||
Here's a simple example of code which uses the SKINI object
|
||||
Here's a simple example of code which uses the Skini object
|
||||
to read a SKINI file and control a single instrument.
|
||||
|
||||
Skini score;
|
||||
Skini::Message message;
|
||||
instrument = new Mandolin(50.0);
|
||||
score = new SKINI(argv[1]);
|
||||
while(score->getType() > 0) {
|
||||
tempDouble = score->getDelta();
|
||||
if (tempDouble < 0) {
|
||||
tempDouble = - tempDouble;
|
||||
tempDouble = tempDouble - output.getTime();
|
||||
if (tempDouble < 0) {
|
||||
printf("Bad News Here!!! Backward Absolute Time Required.\n");
|
||||
tempDouble = 0.0;
|
||||
}
|
||||
score.setFile( argv[1] );
|
||||
while ( score.nextMessage( message ) != 0 ) {
|
||||
tempDouble = message.time;
|
||||
if (tempDouble < 0) {
|
||||
tempDouble = - tempDouble;
|
||||
tempDouble = tempDouble - output.getTime();
|
||||
if (tempDouble < 0) {
|
||||
printf("Bad News Here!!! Backward Absolute Time Required.\n");
|
||||
tempDouble = 0.0;
|
||||
}
|
||||
tempLong = (long) (tempDouble * Stk::sampleRate());
|
||||
for (i=0;i<tempLong;i++) {
|
||||
output.tick(instrument->tick());
|
||||
}
|
||||
tempLong = (long) ( tempDouble * Stk::sampleRate() );
|
||||
for ( i=0; i<tempLong; i++ ) {
|
||||
output.tick( instrument->tick() );
|
||||
}
|
||||
|
||||
tempDouble3 = message.floatValues[1] * NORM_MIDI;
|
||||
if ( message.type == __SK_NoteOn_ ) {
|
||||
if ( tempDouble3 == 0.0 ) {
|
||||
tempDouble3 = 0.5;
|
||||
instrument->noteOff( tempDouble3 );
|
||||
}
|
||||
tempDouble3 = score->getByteThree();
|
||||
if (score->getType()== __SK_NoteOn_ ) {
|
||||
tempDouble3 *= NORM_MIDI;
|
||||
if (score->getByteThree() == 0) {
|
||||
tempDouble3 = 0.5;
|
||||
instrument->noteOff(tempDouble3);
|
||||
}
|
||||
else {
|
||||
tempLong = (int) score->getByteTwo();
|
||||
tempDouble2 = Midi2Pitch[tempLong];
|
||||
instrument->noteOn(tempDouble2,tempDouble3);
|
||||
}
|
||||
else {
|
||||
tempLong = message.intValues[0];
|
||||
tempDouble2 = Midi2Pitch[tempLong];
|
||||
instrument->noteOn( tempDouble2, tempDouble3 );
|
||||
}
|
||||
else if (score->getType() == __SK_NoteOff_) {
|
||||
tempDouble3 *= NORM_MIDI;
|
||||
instrument->noteOff(tempDouble3);
|
||||
}
|
||||
else if (score->getType() == __SK_ControlChange_) {
|
||||
tempLong = score->getByteTwoInt();
|
||||
instrument->controlChange(tempLong,temp3.0);
|
||||
}
|
||||
score->nextMessage();
|
||||
}
|
||||
else if ( message.type == __SK_NoteOff_ ) {
|
||||
instrument->noteOff( tempDouble3 );
|
||||
}
|
||||
else if ( message.type == __SK_ControlChange_ ) {
|
||||
tempLong = message.intValues[0];
|
||||
instrument->controlChange( tempLong, tempDouble3 );
|
||||
}
|
||||
}
|
||||
|
||||
When the score (SKINI object) object is created from the
|
||||
filename in argv[1], the first valid command line is read
|
||||
from the file and parsed.
|
||||
When a SKINI score is passed to a Skini object using the
|
||||
Skini::setFile() function, valid messages are read from
|
||||
the file and returned using the Skini::nextMessage() function.
|
||||
|
||||
The score->getType() retrieves the messageType. If this is
|
||||
-1, there are no more valid messages in the file and the
|
||||
synthesis loop terminates. Otherwise, the message type is
|
||||
returned.
|
||||
A Skini::Message structure contains all the information parsed
|
||||
from a single SKINI message. A returned message type of zero
|
||||
indicates either an invalid message or the end of a scorefile.
|
||||
|
||||
getDelta() retrieves the deltaTime until the current message
|
||||
should occur. If this is greater than 0, synthesis occurs
|
||||
until the deltaTime has elapsed. If deltaTime is less than
|
||||
zero, the time is interpreted as absolute time and the output
|
||||
device is queried as to what time it is now. That is used to
|
||||
form a deltaTime, and if it's positive we synthesize. If
|
||||
it's negative, we print an error and pretend this never
|
||||
happened and we hang around hoping to eventually catch up.
|
||||
The "time" member of a Skini::Message is the deltaTime until the
|
||||
current message should occur. If this is greater than 0,
|
||||
synthesis occurs until the deltaTime has elapsed. If deltaTime is
|
||||
less than zero, the time is interpreted as absolute time and the
|
||||
output device is queried as to what time it is now. That is used
|
||||
to form a deltaTime, and if it's positive we synthesize. If it's
|
||||
negative, we print an error, pretend this never happened and we
|
||||
hang around hoping to eventually catch up.
|
||||
|
||||
The rest of the code sorts out message types NoteOn, NoteOff
|
||||
(including NoteOn with velocity 0), and ControlChange. The
|
||||
code implicitly takes into account the integer type of the
|
||||
control number, but all other data is treated as double float.
|
||||
|
||||
The last line reads and parses the next message in the file.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = STK
|
||||
PROJECT_NUMBER =
|
||||
PROJECT_NUMBER = 4.2.0
|
||||
OUTPUT_DIRECTORY = .
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
@@ -18,10 +18,10 @@ STRIP_FROM_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
DETAILS_AT_TOP = YES
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
TAB_SIZE = 8
|
||||
TAB_SIZE = 9
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
@@ -67,13 +67,13 @@ WARN_LOGFILE =
|
||||
INPUT = . \
|
||||
../../include
|
||||
FILE_PATTERNS = *.txt \
|
||||
*.h \
|
||||
*.cpp
|
||||
*.msg \
|
||||
*.h
|
||||
RECURSIVE = YES
|
||||
EXCLUDE = ../../src/asio
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATH = ../../projects/examples
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
@@ -83,7 +83,7 @@ FILTER_SOURCE_FILES = NO
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = NO
|
||||
INLINE_SOURCES = YES
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
@@ -117,7 +117,7 @@ TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = YES
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
|
||||
@@ -5,7 +5,7 @@ The Synthesis ToolKit can be used in a variety of ways, depending on your partic
|
||||
|
||||
\section rtvsnonrt "Realtime" vs. "Non-Realtime"
|
||||
|
||||
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) <I>dependent</I>. STK classes which require specific platform/OS support include RtAudio, RtWvOut, RtWvIn, RtDuplex, RtMidi, TcpWvIn, TcpWvOut, Socket, and Thread. These classes currently can only be compiled on Linux, Irix, Macintosh OS X, and Windows systems using the <TT>__LINUX_OSS__</TT>, <TT>__LINUX_ALSA__</TT>, <TT>__IRIX_AL__</TT>, <TT>__MACOSX_CORE__</TT>, <TT>__WINDOWS_DS__</TT>, or <TT>__WINDOWS_ASIO__</TT> preprocessor definitions.
|
||||
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) <I>dependent</I>. STK classes which require specific platform/OS support include RtAudio, RtWvOut, RtWvIn, RtDuplex, RtMidi, TcpWvIn, TcpWvOut, Socket, Thread, and Mutex. These classes currently can only be compiled on Linux, Irix, 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 of audio file formats (WAV, SND, AIFF, MAT-file, and RAW). If compiling for a "little-endian" host processor, the <TT>__LITTLE_ENDIAN__</TT> preprocessor definition should be provided.
|
||||
|
||||
@@ -25,25 +25,25 @@ STK compiles with realtime support on the following flavors of the Unix operatin
|
||||
<TR>
|
||||
<TD>Linux</TD>
|
||||
<TD>ALSA</TD>
|
||||
<TD>__LINUX_ALSA__, __LITTLE_ENDIAN__</TD>
|
||||
<TD>__LINUX_ALSA__, __LINUX_ALSASEQ__, __LITTLE_ENDIAN__</TD>
|
||||
<TD><TT>asound, pthread</TT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Linux</TD>
|
||||
<TD>OSS</TD>
|
||||
<TD>__LINUX_OSS__, __LITTLE_ENDIAN__</TD>
|
||||
<TD><TT>pthread</TT></TD>
|
||||
<TD>OSS (audio only, use ALSA for MIDI support)</TD>
|
||||
<TD>__LINUX_OSS__, __LINUX_ALSASEQ__, __LITTLE_ENDIAN__</TD>
|
||||
<TD><TT>asound, pthread</TT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Macintosh OS X</TD>
|
||||
<TD>CoreAudio</TD>
|
||||
<TD>__MACOSX_CORE__</TD>
|
||||
<TD><TT>pthread, stdc++, CoreAudio, CoreMIDI, CoreFoundation</TT></TD>
|
||||
<TD><TT>pthread, CoreAudio, CoreMIDI, CoreFoundation</TT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Irix</TD>
|
||||
<TD>AL</TD>
|
||||
<TD>__IRIX_AL__</TD>
|
||||
<TD>__IRIX_AL__, __IRIX_MD__</TD>
|
||||
<TD><TT>audio, pthread</TT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
@@ -51,21 +51,21 @@ STK compiles with realtime support on the following flavors of the Unix operatin
|
||||
|
||||
The available C++ compilers on any of these systems can vary.
|
||||
|
||||
One approach in using STK is to simply copy the class files needed for a particular program into a project directory. Taking the <TT>sineosc.cpp</TT> example from the previous tutorial chapter, it would be necessary to set up a directory that includes the files <TT>sineosc.cpp</TT>, the rawwave file <TT>sinewave.raw</TT> in a subdirectory called <TT>rawwaves</TT>, and the header and source files for the classes Stk, WvIn, WaveLoop, and WvOut. The program could then be compiled on a Linux system using the GNU g++ compiler as follows:
|
||||
One approach in using STK is to simply copy the class files needed for a particular program into a project directory. Taking the <TT>sineosc.cpp</TT> example from the previous tutorial chapter, it would be necessary to set up a directory that includes the files <TT>sineosc.cpp</TT>, the rawwave file <TT>sinewave.raw</TT> in a subdirectory called <TT>rawwaves</TT>, and the header and source files for the classes Stk, WvIn, WaveLoop, and WvOut. The program could then be compiled on a little-endian system, such as a PC running Linux, using the GNU g++ compiler as follows:
|
||||
\code
|
||||
g++ -Wall -D__LITTLE_ENDIAN__ -o sineosc Stk.cpp WvIn.cpp WaveLoop.cpp WvOut.cpp sineosc.cpp
|
||||
\endcode
|
||||
|
||||
Note that the <TT>sineosc.cpp</TT> 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 <TT>Makefiles</TT> (built by the configure script) which compile project-specific class objects from the distribution <TT>src</TT> and <TT>include</TT> directories. This approach makes it relatively easy when upgrading to a new STK release (by making path substitutions in the <TT>Makefile</TT> or by moving the projects to a similar relative path within the new STK source tree). A <TT>Makefile</TT> is provided in the <TT>projects/examples</TT> directory for compiling all the tutorial programs, as well as other example programs. To compile the <TT>sineosc.cpp</TT> program, for example, one need only type <TT>make sineosc</TT> from within the <TT>projects/examples</TT> directory. Note that this particular <TT>Makefile</TT> depends on a static library, as described in the next section.
|
||||
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 <TT>Makefiles</TT> (built by the configure script) which compile project-specific class objects from the distribution <TT>src</TT> and <TT>include</TT> directories. This approach makes it relatively easy when upgrading to a new STK release (by making path substitutions in the <TT>Makefile</TT> or by moving the projects to a similar relative path within the new STK source tree). A <TT>Makefile</TT> is provided in the <TT>projects/examples</TT> directory for compiling all the tutorial programs, as well as other example programs. To compile the <TT>sineosc.cpp</TT> program, for example, one need only type <TT>make sineosc</TT> from within the <TT>projects/examples</TT> directory.
|
||||
|
||||
|
||||
\subsection library Library Use:
|
||||
|
||||
The STK distribution provides a <TT>Makefile</TT> that can be used on Unix systems to build a static library. After unpacking the distribution (<TT>tar -xzf stk-4.x.tar.gz</TT>), run the configure script by typing <TT>./configure</TT> from the top level distribution directory (see the INSTALL file in the same directory for more information). Then from within the <TT>src</TT> directory, type <TT>make</TT>. After a successful build, you may wish to move the library (<TT>libstk.a</TT>) and the contents of the <TT>include</TT> directory to standard library and include search paths on your system. For example, the linux RPM distribution of STK puts the library in <TT>/usr/lib/</TT> and the STK header files in <TT>/usr/include/stk/</TT>.
|
||||
The STK distribution provides a <TT>Makefile</TT> that can be used on Unix systems to build a static library. After unpacking the distribution (<TT>tar -xzf stk-4.x.x.tar.gz</TT>), run the configure script by typing <TT>./configure</TT> from the top level distribution directory (see the INSTALL file in the same directory for more information). Then from within the <TT>src</TT> directory, type <TT>make</TT>. After a successful build, you may wish to move the library (<TT>libstk.a</TT>) and the contents of the <TT>include</TT> directory to standard library and include search paths on your system. For example, the linux RPM distribution of STK puts the library in <TT>/usr/lib/</TT> and the STK header files in <TT>/usr/include/stk/</TT>.
|
||||
|
||||
Assuming the library is located in a standard search path and the header files are located in <TT>/usr/include/stk/</TT>, the <TT>sineosc.cpp</TT> example from the previous tutorial chapter can be compiled on a Linux system using the GNU g++ compiler as follows:
|
||||
Assuming the library is located in a standard search path and the header files are located in <TT>/usr/include/stk/</TT>, the <TT>sineosc.cpp</TT> example from the previous tutorial chapter can be compiled on a little-endian system using the GNU g++ compiler as follows:
|
||||
|
||||
\code
|
||||
g++ -Wall -D__LITTLE_ENDIAN__ -I/usr/include/stk -o sineosc sineosc.cpp -lstk
|
||||
@@ -91,9 +91,9 @@ STK has been tested on Windows platforms using the Visual C++ compiler only. It
|
||||
|
||||
The approach when using Visual C++ is to build a project which includes the necessary ToolKit files from the distribution <TT>src</TT> and <TT>include</TT> directories. For the example program from the previous tutorial chapter, create a VC++ console application project, add the Stk, WvIn, WaveLoop, and WvOut class files, as well as <TT>sineosc.cpp</TT>, and make sure the <TT>sinewave.raw</TT> file is in the subdirectory <TT>rawwaves</TT>.
|
||||
|
||||
For programs using any of the STK realtime classes mentioned above, it is necessary to link with the DirectSound (<TT>dsound.lib</TT>), <TT>winmm.lib</TT>, and <TT>Wsock32.lib</TT> libraries, select the multithreaded library, and provide the <TT>__LITTLE_ENDIAN__</TT> and <TT>__WINDOWS_DS__</TT> preprocessor definitions.
|
||||
For programs using any of the STK realtime classes mentioned above, it is necessary to link with the DirectSound (<TT>dsound.lib</TT>), <TT>winmm.lib</TT>, and <TT>Wsock32.lib</TT> libraries, select the multithreaded library, and provide the <TT>__LITTLE_ENDIAN__</TT>, <TT>__WINDOWS_DS__</TT>, and <TT>__WINDOWS_MM__</TT> preprocessor definitions.
|
||||
|
||||
For Steinberg ASIO support, use the <TT>__WINDOWS_ASIO__</TT> preprocessor definition, include all the files in the <TT>src/asio/</TT> directory (i.e., <TT>asio.h,cpp</TT>, <TT>asiodrivers.h,cpp</TT>, ...), and link with the <TT>winmm.lib</TT>, and <TT>Wsock32.lib</TT> libraries.
|
||||
For Steinberg ASIO support, use the <TT>__WINDOWS_ASIO__</TT> preprocessor definition (and the <TT>__WINDOWS_MM__</TT> definition for RtMidi support), include all the files in the <TT>src/asio/</TT> directory (i.e., <TT>asio.h,cpp</TT>, <TT>asiodrivers.h,cpp</TT>, ...), and link with the <TT>winmm.lib</TT>, and <TT>Wsock32.lib</TT> libraries.
|
||||
|
||||
[<A HREF="realtime.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
[<A HREF="filtering.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
*/
|
||||
|
||||
@@ -17,114 +17,27 @@ StringDetune 0.100000 2 12.0
|
||||
NoteOff 1.000000 2 69.0 64.0
|
||||
\endcode
|
||||
|
||||
MIDI messages (with the exception of Sysex) are easily represented within the SKINI protocol.
|
||||
MIDI messages are easily represented within the SKINI protocol.
|
||||
|
||||
The class Messager can be used to acquire and parse MIDI messages from a MIDI device and SKINI messages from STDIN and socket connections. Many of the example programs included with the ToolKit distribution use a Messager instance to accept control input from the accompanying tcl/tk graphical user interfaces, from external MIDI devices, or from SKINI scorefiles.
|
||||
The class Messager can be used to acquire and parse MIDI messages from a MIDI device and SKINI messages from STDIN and socket connections. Incoming messages are acquired asynchronously and saved to an internal message queue of Skini::Message types (MIDI messages are converted to the Skini:Message format). The user then uses the Messager:popMessage() function to retrieve incoming control messages. This function does not block, instead returning a message type of zero when no more messages are in the queue. Many of the example programs included with the ToolKit distribution use a Messager instance to accept control input from the accompanying tcl/tk graphical user interfaces, from external MIDI devices, or from SKINI scorefiles.
|
||||
|
||||
In the following example, we'll modify the <TT>bethree.cpp</TT> program from the previous tutorial chapter and incorporate a Messager class to allow control via a SKINI scorefile.
|
||||
In the following example, we'll modify the <TT>bethree.cpp</TT> program from the previous tutorial chapter and incorporate a Messager class to allow control via SKINI messages read from a SKINI file.
|
||||
|
||||
\include controlbee.cpp
|
||||
|
||||
A realtime control message will usually have a delta time of zero, in which case it is processed as soon as possible. Non-realtime messages, normally from a scorefile, will usually have non-zero delta times. The scheme used in this example is designed to work for both scorefile and realtime input types. When no message is available from the queue, the instrument is "ticked" for DELTA_CONTROL_TICKS and then the queue is checked again. The value of DELTA_CONTROL_TICKS roughly defines the program "control rate" in a realtime context, though multiple available messages in the queue are processed in immediate succession when their delta time values are zero.
|
||||
|
||||
The \c processMessage() function centralizes the handling of control messages. Other control update schemes can be implemented, perhaps using a separate thread or in the \c main() function, and this function should work in any context.
|
||||
|
||||
Assuming the program is compiled as <TT>controlbee</TT> and the SKINI scorefile <A HREF="tutorial/bookert.ski"><TT>bookert.ski</TT></A> is in the <TT>scores</TT> directory, the program can be run as:
|
||||
|
||||
\code
|
||||
// controlbee.cpp
|
||||
|
||||
#include "BeeThree.h"
|
||||
#include "RtWvOut.h"
|
||||
#include "Messager.h"
|
||||
#include "SKINI.msg"
|
||||
#include <math.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// Set the global sample rate before creating class instances.
|
||||
Stk::setSampleRate( 44100.0 );
|
||||
|
||||
Instrmnt *instrument = 0;
|
||||
RtWvOut *output = 0;
|
||||
Messager *messager = 0;
|
||||
bool done = FALSE;
|
||||
|
||||
try {
|
||||
// Define and load the BeeThree instrument
|
||||
instrument = new BeeThree();
|
||||
|
||||
// Define and open the default realtime output device for one-channel playback
|
||||
output = new RtWvOut(1);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
try {
|
||||
// Create a Messager instance to read from a redirected SKINI scorefile.
|
||||
messager = new Messager();
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Play the instrument until the end of the scorefile.
|
||||
int i, nTicks, type;
|
||||
MY_FLOAT byte2, byte3, frequency;
|
||||
while (!done) {
|
||||
|
||||
// Look for new messages and return a delta time (in samples).
|
||||
type = messager->nextMessage();
|
||||
if (type < 0)
|
||||
done = TRUE;
|
||||
|
||||
nTicks = messager->getDelta();
|
||||
try {
|
||||
for ( i=0; i<nTicks; i++ )
|
||||
output->tick( instrument->tick() );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ( type > 0 ) {
|
||||
// Process the new control message.
|
||||
byte2 = messager->getByteTwo();
|
||||
byte3 = messager->getByteThree();
|
||||
|
||||
switch(type) {
|
||||
|
||||
case __SK_NoteOn_:
|
||||
frequency = (MY_FLOAT) 220.0 * pow( 2.0, (byte2 - 57.0) / 12.0 );
|
||||
instrument->noteOn( frequency, byte3 * ONE_OVER_128 );
|
||||
break;
|
||||
|
||||
case __SK_NoteOff_:
|
||||
instrument->noteOff( byte3 * ONE_OVER_128 );
|
||||
break;
|
||||
|
||||
case __SK_ControlChange_:
|
||||
instrument->controlChange( (int) byte2, byte3 );
|
||||
break;
|
||||
|
||||
case __SK_AfterTouch_:
|
||||
instrument->controlChange( 128, byte2 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
delete instrument;
|
||||
delete output;
|
||||
delete messager;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
Assuming the program is compiled as <TT>controlbee</TT> and the SKINI scorefile <A HREF="tutorial/bookert.ski"><TT>bookert.ski</TT></A> is in the <TT>scores</TT> directory, the scorefile could be redirected to the program as:
|
||||
|
||||
\code
|
||||
controlbee < scores/bookert.ski
|
||||
controlbee scores/bookert.ski
|
||||
\endcode
|
||||
|
||||
Only a few basic SKINI message type case statements are included in this example. It is easy to extend the program to support a much more elaborate set of instrument control parameters.
|
||||
|
||||
This example could also be easily extended to accept "realtime" control input messages via STDIN, socket, or MIDI connections. The Messager class constructor takes an optional argument consisting of a bitmask of the following options: <TT>STK_PIPE</TT>, <TT>STK_SOCKET</TT>, and/or <TT>STK_MIDI</TT>.
|
||||
This example could also be easily extended to accept "realtime" control input messages via pipe, socket or MIDI connections. The Messager class provides Messager::startStdInput(), Messager::startSocketInput(), and Messager::startMidiInput() functions for this purpose.
|
||||
|
||||
[<A HREF="multichannel.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
*/
|
||||
|
||||
26
doc/doxygen/crealtime.txt
Normal file
26
doc/doxygen/crealtime.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
/*! \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 <TT>rtsine.cpp</TT> 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).
|
||||
|
||||
\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 <tt>StkFloat</tt>, and the RT_BUFFER_SIZE defined in Stk.h. The last 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 <tt>struct</tt> (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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
[<A HREF="instruments.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
*/
|
||||
@@ -1,15 +1,39 @@
|
||||
/*! \page download Download and Release Notes
|
||||
|
||||
<B>Version 4.1.3, 22 March 2004</B><P>
|
||||
<B>Version 4.2.0, 4 October 2004</B><P>
|
||||
<UL>
|
||||
<LI><A HREF="http://www-ccrma.stanford.edu/software/stk/release/stk-4.1.3.tar.gz">Source distribution</A></LI>
|
||||
<LI><A HREF="http://www-ccrma.stanford.edu/software/stk/release/stk-4.1.3.binaries.tar.gz">Source with precompiled Windows binaries</A></LI>
|
||||
<LI><A HREF="http://www-ccrma.stanford.edu/software/stk/release/stk-4.2.0.tar.gz">Source distribution</A></LI>
|
||||
<LI><A HREF="http://www-ccrma.stanford.edu/software/stk/release/stk-4.2.0.binaries.tar.gz">Source with precompiled Windows binaries</A></LI>
|
||||
<LI><A HREF="http://www-ccrma.stanford.edu/planetccrma/software/">Linux RPMs from Planet CCRMA</A></LI>
|
||||
</UL>
|
||||
|
||||
|
||||
\section notes Release Notes:
|
||||
|
||||
\subsection v4dot2dot0 Version 4.2.0
|
||||
|
||||
<ul>
|
||||
<li>Simultaneous multiple audio APIs supported at compile time.</li>
|
||||
<li>Various changes to better conform to standard C++ programming practices.</li>
|
||||
<li>Fixed hidden overloaded virtual functions.</li>
|
||||
<li>New Asymp exponential envelope class.</li>
|
||||
<li><tt>MY_FLOAT</tt> type converted to <tt>StkFloat</tt> and changed throughout (use \c treesed utility to search/replace in old files).</li>
|
||||
<li>Most example programs rewritten to use an audio callback paradigm (which works better in OS-X).</li>
|
||||
<li>New StkFrames class for vectorized multichannel data and associated new tick() functions making use of StkFrames.</li>
|
||||
<li>New RtMidi class with MIDI output capabilities (API changes).</li>
|
||||
<li>New MidiFileIn class for reading MIDI files.</li>
|
||||
<li>Revised Filter classes to use std::vectors for coefficients (API changes).</li>
|
||||
<li>Revised Messager class (API changes).</li>
|
||||
<li>New abstract parent Effect class for various effects.</li>
|
||||
<li>New abstract parent Generator class for various signal sources.</li>
|
||||
<li>New abstract parent Function class for tables and various non-linear functions.</li>
|
||||
<li>Skini class completely rewritten (simplified) using the C++ STL (API changes).</li>
|
||||
<li>WvOut classes now clip to -1.0 to +1.0 and report out of range.</li>
|
||||
<li>New Mutex class.</li>
|
||||
<li>Turned Nagle algorithm off by default in Socket class.</li>
|
||||
<li>Error reporting standardized in all classes.</li>
|
||||
</ul>
|
||||
|
||||
\subsection v4dot1dot3 Version 4.1.3
|
||||
|
||||
<ul>
|
||||
@@ -30,7 +54,7 @@
|
||||
<li>Update to the contentsAt() method of Delay class.</li>
|
||||
<li>WAV file fixes (8-bit) in WvIn and WvOut classes.</li>
|
||||
<li>Configure script changes.</li>
|
||||
<li>Updated <iostream> include statements and appended "std::" as necessary throughout for compatibility with gcc 3.</li>
|
||||
<li>Updated \<iostream\> include statements and appended "std::" as necessary throughout for compatibility with gcc 3.</li>
|
||||
</UL>
|
||||
|
||||
\subsection v4dot1dot1 Version 4.1.1
|
||||
@@ -138,7 +162,7 @@
|
||||
<LI>Added RawWvOut class.</LI>
|
||||
<LI>New WvIn class with RawWvIn, SndWvIn, WavWvIn, MatWvIn, and RTWvIn subclasses.</LI>
|
||||
<LI>Removed RawWave, RawShot, RawInterp, and RawLoop classes (supplanted by RawWvIn).</LI>
|
||||
<LI>Multi-channel data support in WvIn and WvOut classes using MY_MULTI data type (pointer to MY_FLOAT) and the methods mtick() and mlastOutput().</LI>
|
||||
<LI>Multi-channel data support in WvIn and WvOut classes using MY_MULTI data type (pointer to StkFloat) and the methods mtick() and mlastOutput().</LI>
|
||||
<LI>Now writing to primary buffer under Windoze when allowed by hardware.</LI>
|
||||
<LI>Cleaned up Object.h a bit.</LI>
|
||||
<LI>Pulled various utility and thread functions out of syntmono.cpp (to aid readability of the code).</LI>
|
||||
@@ -160,11 +184,11 @@
|
||||
<UL>
|
||||
<LI>Unification of the capabilities of STK across the various platforms. All of the previous SGI functionality has been ported to Linux and Windows, including realtime sound output and MIDI input.</LI>
|
||||
<LI>MIDI input (with optional time-stamping) supported on SGI, Linux (OSS device drivers only), and Windows operating systems. Time stamping under IRIX and Windows is quantized to milliseconds and under Linux to hundredths of a second.</LI>
|
||||
<LI>Various Sound Output Options - .wav, .snd, and .mat (Matlab MAT-file) soundfile outputs are supported on all operating systems. I hacked out the MAT-file structure, so you don't have to include any platform-specific libraries. Realtime sound output is provided as well, except under NeXTStep. </LI>
|
||||
<LI>Various Sound Output Options - .wav, .snd, and .mat (Matlab MAT-file) soundfile outputs are supported on all operating systems. I hacked out the MAT-file structure, so you don't have to include any platform-specific libraries. Realtime sound output is provided as well, except under NeXTStep.</LI>
|
||||
<LI>Multiple Reverberator Implementations - Reverb subclasses of JCRev and NRev (popular reverberator implementations from CCRMA) have been written. Perry's original reverb implementation still exists as PRCRev. All reverberators now take a T60 initializer argument.</LI>
|
||||
<LI>MD2SKINI - A program which parses a MIDI input stream and spits out SKINI code. The output of MD2SKINI is typically piped into an STK instrument executable (eg. <FONT FACE="Geneva">MD2SKINI | syntmono Clarinet -r -i</FONT>). In addition, you can supply a filename argument to MD2SKINI and have it simultaneously record a SKINI score file for future reuse.
|
||||
<LI>Modifications to <I>Object.h</I> for OS_TYPE compilation dependencies. <I>Makefile</I> automatically determines OS_TYPE when invoked (if you have the GNU makefile utilities installed on your system).
|
||||
<LI>A single distribution for all platforms. The Unix and Windows versions have been merged into a single set of classes. Makefiles and Visual C++ workspace/project files are provided for compiling.
|
||||
<LI>MD2SKINI - A program which parses a MIDI input stream and spits out SKINI code. The output of MD2SKINI is typically piped into an STK instrument executable (eg. <tt>MD2SKINI | syntmono Clarinet -r -i</tt>). In addition, you can supply a filename argument to MD2SKINI and have it simultaneously record a SKINI score file for future reuse.</LI>
|
||||
<LI>Modifications to <I>Object.h</I> for OS_TYPE compilation dependencies. <I>Makefile</I> automatically determines OS_TYPE when invoked (if you have the GNU makefile utilities installed on your system).</LI>
|
||||
<LI>A single distribution for all platforms. The Unix and Windows versions have been merged into a single set of classes. Makefiles and Visual C++ workspace/project files are provided for compiling.</LI>
|
||||
</UL>
|
||||
|
||||
*/
|
||||
|
||||
88
doc/doxygen/filtering.txt
Normal file
88
doc/doxygen/filtering.txt
Normal file
@@ -0,0 +1,88 @@
|
||||
/*! \page filtering Using Filters
|
||||
|
||||
In this section, we demonstrate the use of a few of the STK filter classes. The Filter class provides functionality to implement a generalized digital filter of any type, similar to the \c filter function in Matlab. In this example, we create a Filter instance and initialize it with specific numerator and denominator coefficients. We then compute its impulse response for 20 samples.
|
||||
|
||||
\code
|
||||
#include "Filter.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
StkFrames output( 20 ); // initialize StkFrames to 20 elements (defaults: 1 channel, interleaved)
|
||||
output[0] = 1.0;
|
||||
|
||||
std::vector<StkFloat> numerator( 5, 0.1 ); // create and initialize numerator coefficients
|
||||
std::vector<StkFloat> denominator; // create empty denominator coefficients
|
||||
denominator.push_back( 1.0 ); // populate our denomintor values
|
||||
denominator.push_back( 0.3 );
|
||||
denominator.push_back( -0.5 );
|
||||
|
||||
Filter filter( numerator, denominator );
|
||||
|
||||
filter.tick( output );
|
||||
for ( unsigned int i=0; i<output.size(); i++ ) {
|
||||
std::cout << "i = " << i << " : output = " << output[i] << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
The Filter class implements the standard difference equation
|
||||
\code
|
||||
a[0]*y[n] = b[0]*x[n] + ... + b[nb]*x[n-nb] - a[1]*y[n-1] - ... - a[na]*y[n-na],
|
||||
\endcode
|
||||
|
||||
where "b" values are numerator coefficients and "a" values are denominator coefficients. Note that if the first denominator coefficient is not 1.0, the Filter class automatically normalizes all filter coefficients by that value. The coefficient values are passed to the Filter class via a C++ <a href="http://www.roguewave.com/support/docs/sourcepro/stdlibref/vector.html">vector</a>, a container object provided by the C++ Standard Library.
|
||||
|
||||
Most STK classes use more specific types of digital filters, such as the OneZero, OnePole, TwoPole, or BiQuad varieties. These classes inherit from the Filter class and provide specific functionality particular to their use, as well as functions to independently control individual coefficient values.
|
||||
|
||||
\section reson Resonances:
|
||||
|
||||
The STK BiQuad and TwoPole classes provide functionality for creating resonance filters. The following example demonstrates how to create a resonance centered at 440 Hz that is used to filter the output of a Noise generator.
|
||||
|
||||
\code
|
||||
#include "BiQuad.h"
|
||||
#include "Noise.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
StkFrames output( 20 ); // initialize StkFrames to 20 elements (defaults: 1 channel, interleaved)
|
||||
Noise noise;
|
||||
|
||||
BiQuad biquad;
|
||||
biquad.setResonance( 440.0, 0.98, true ); // automatically normalize for unity peak gain
|
||||
|
||||
for ( unsigned int i=0; i<output.size(); i++ ) {
|
||||
output[i] = biquad.tick( noise.tick() ); // single-sample computations
|
||||
std::cout << "i = " << i << " : output = " << output[i] << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
By passing a boolian value of \c true as the third argument to the BiQuad::setResonance() function, the filter coefficients are automatically scaled to achieve unity gain at the resonance peak frequency. The previous code could be easily modified for "vector-based" calculations:
|
||||
|
||||
\code
|
||||
#include "BiQuad.h"
|
||||
#include "Noise.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
StkFrames output( 20 ); // initialize StkFrames to 20 elements (defaults: 1 channel, interleaved)
|
||||
Noise noise;
|
||||
|
||||
BiQuad biquad;
|
||||
biquad.setResonance( 440.0, 0.98, true ); // automatically normalize for unity peak gain
|
||||
|
||||
biquad.tick( noise.tick( output ) ); // vector-based computations
|
||||
for ( unsigned int i=0; i<output.size(); i++ ) {
|
||||
std::cout << "i = " << i << " : output = " << output[i] << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
[<A HREF="realtime.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
*/
|
||||
@@ -1,7 +1,7 @@
|
||||
<HR>
|
||||
|
||||
<table>
|
||||
<tr><td><A HREF="http://www-ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
|
||||
<tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
|
||||
<tr><td>©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
63
doc/doxygen/fundamentals.txt
Normal file
63
doc/doxygen/fundamentals.txt
Normal file
@@ -0,0 +1,63 @@
|
||||
/*! \page fundamentals STK Fundamentals
|
||||
|
||||
The Synthesis ToolKit is implemented in the C++ programming language. STK does not attempt to provide a new programming environment or paradigm but rather provides a set of objects which can be used within a normal C++ programming framework. Therefore, it is expected that users of STK will have some familiarity with C/C++ programming concepts. That said, the STK classes do have some particular idiosyncrasies that we will mention here.
|
||||
|
||||
\section Signal Computations:
|
||||
|
||||
Audio and control signals throughout STK use a floating-point data type, <tt>StkFloat</tt>, the exact precision of which can be controlled via a typedef statement in Stk.h. By default, an StkFloat is a double-precision floating-point value. Thus, the ToolKit can use any normalization scheme desired. The base instruments and algorithms are implemented with a general audio sample dynamic maximum of +/-1.0.
|
||||
|
||||
In general, the computation and/or passing of values is performed on a "single-sample" basis. For example, the Noise class outputs random floating-point numbers in the range +/-1.0. The computation of such values occurs in the Noise::tick() function. The following program will generate 20 random floating-point (<tt>StkFloat</tt>) values in the range -1.0 to +1.0:
|
||||
|
||||
\code
|
||||
#include "Noise.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
StkFloat output;
|
||||
Noise noise;
|
||||
|
||||
for ( unsigned int i=0; i<20; i++ ) {
|
||||
output = noise.tick();
|
||||
std::cout << "i = " << i << " : output = " << output << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
Nearly all STK classes implement <TT>tick()</TT> functions which take and/or return sample values. Within the <TT>tick()</TT> function, the fundamental sample calculations are performed for a given class. Most STK classes consume/generate a single sample per operation and their <TT>tick()</TT> method takes/returns each sample "by value". In addition, every class implementing a <TT>tick()</TT> function also provides one or more overloaded <TT>tick()</TT> functions which can be used for vectorized computations, as shown in the next example.
|
||||
|
||||
\code
|
||||
#include "Noise.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
StkFrames output(20); // initialize StkFrames to 20 elements (defaults: 1 channel, interleaved)
|
||||
Noise noise;
|
||||
|
||||
noise.tick( output );
|
||||
for ( unsigned int i=0; i<output.size(); i++ ) {
|
||||
std::cout << "i = " << i << " : output = " << output[i] << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
In this way, it might be possible to achieve improved processing efficiency using vectorized computations. The StkFrames class is a new addition to the ToolKit to provide a general "mechanism" for handling and passing vectorized, multi-channel audio data. The StkFrames "type" provides functions to set and/or determine the number of audio channels and sample frames it holds, as well as the format (interleaved or non-interleaved) of its data.
|
||||
|
||||
\section STK Inheritance:
|
||||
|
||||
Nearly all STK classes inherit from the Stk abstract base class, which provides common functionality related to error reporting, sample rate control, and byte swapping. Several other base classes exist which roughly group many of the classes according to function as follows:
|
||||
|
||||
- Generator: source signal unit generator classes [Envelope, ADSR, Asymp, Noise, SubNoise, Modulate, SingWave]
|
||||
- Filter: digital filtering classes [OneZero, OnePole, PoleZero, TwoZero, TwoPole, BiQuad, FormSwep, Delay, DelayL, DelayA]
|
||||
- Function: input to output function mappings [Table, BowTable, JetTable, ReedTable]
|
||||
- Instrmnt: sound synthesis algorithms, including physical, FM, modal, and particle models
|
||||
- Effect: sound processing effect classes [Echo, Chorus, PitShift, PRCRev, JCRev, NRev]
|
||||
- WvOut: audio file and streaming output classes [RtWvOut, TcpWvOut]
|
||||
- WvIn: audio file and streaming input classes [WaveLoop, RtWvIn, TcpWvIn]
|
||||
|
||||
|
||||
[<A HREF="hello.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
*/
|
||||
@@ -1,6 +1,6 @@
|
||||
/*! \page hello Hello Sine!
|
||||
|
||||
We'll begin our introduction to the Synthesis ToolKit with a simple sine-wave oscillator program. STK does not provide a specific oscillator for sine waves. Instead, it provides a generic waveform oscillator class, WaveLoop, which can load a variety of common file types. In this example, we load a sine "table" from an STK RAW file (defined as monophonic, 16-bit, big-endian data). We use the class WvOut to write the result to a 16-bit, WAV formatted audio file.
|
||||
We'll continue our introduction to the Synthesis ToolKit with a simple sine-wave oscillator program. STK does not provide a specific oscillator for sine waves. Instead, it provides a generic waveform oscillator class, WaveLoop, which can load a variety of common file types. In this example, we load a sine "table" from an STK RAW file (defined as monophonic, 16-bit, big-endian data). We use the class WvOut to write the result to a 16-bit, WAV formatted audio file.
|
||||
|
||||
\code
|
||||
|
||||
@@ -15,11 +15,11 @@ int main()
|
||||
Stk::setSampleRate( 44100.0 );
|
||||
|
||||
// Define and load the sine wave file
|
||||
WaveLoop *input = new WaveLoop( "rawwaves/sinewave.raw", TRUE );
|
||||
WaveLoop* input = new WaveLoop( "rawwaves/sinewave.raw", true );
|
||||
input->setFrequency( 440.0 );
|
||||
|
||||
// Define and open a 16-bit, one-channel WAV formatted output file
|
||||
output = new WvOut( "hellosine.wav", 1, WvOut::WVOUT_WAV, Stk::STK_SINT16 );
|
||||
WvOut* output = new WvOut( "hellosine.wav", 1, WvOut::WVOUT_WAV, Stk::STK_SINT16 );
|
||||
|
||||
// Run the oscillator for 40000 samples, writing to the output file
|
||||
int i;
|
||||
@@ -39,66 +39,17 @@ WaveLoop is a subclass of WvIn, which supports WAV, SND (AU), AIFF, MAT-file (Ma
|
||||
|
||||
The WvIn and WvOut classes are complementary, both supporting WAV, SND (AU), AIFF, MAT-file (Matlab), and RAW file formats with 8-, 16-, and 32-bit integer and 32- and 64-bit floating-point data types. However, WvOut does not perform data interpolation.
|
||||
|
||||
Nearly all STK classes implement <TT>tick()</TT> functions which take and/or return sample values. Within the <TT>tick()</TT> function, the fundamental sample calculations are performed for a given class. Most STK classes consume/generate a single sample per operation and their <TT>tick()</TT> method takes/returns each sample "by value". In addition, every class implementing a <TT>tick()</TT> function also provides an overloaded <TT>tick()</TT> function taking pointer and size arguments which can be used for vectorized computations.
|
||||
|
||||
The WvIn and WvOut classes support multi-channel sample frames. To distinguish single-sample frame operations from multi-channel frame operations, these classes also implement <TT>tickFrame()</TT> functions. When a <TT>tick()</TT> method is called for multi-channel data, frame averages are returned or the input sample is distributed across all channels of a sample frame.
|
||||
|
||||
Nearly all STK classes inherit from the Stk base class. Stk provides a static sample rate which is queried by subclasses as needed. Because many classes use the current sample rate value during instantiation, it is important that the desired value be set at the beginning of a program. The default STK sample rate is 22050 Hz.
|
||||
|
||||
Another primary concept that is somewhat obscurred in this example concerns the data format in which sample values are passed and received. Audio and control signals throughout STK use a floating-point data type, the exact precision of which can be controlled via the <TT>MY_FLOAT</TT> \#define statement in Stk.h. Thus, the ToolKit can use any normalization scheme desired. The base instruments and algorithms are implemented with a general audio sample dynamic maximum of +/-1.0, and the WvIn and WvOut classes and subclasses scale appropriately for DAC or soundfile input and output.
|
||||
Nearly all STK classes inherit from the Stk base class. Stk provides a static sample rate which is queried by subclasses as needed. Because many classes use the current sample rate value during instantiation, it is important that the desired value be set at the beginning of a program. The default STK sample rate is 44100 Hz.
|
||||
|
||||
\section error Error Handling
|
||||
|
||||
The ToolKit has some basic C++ error handling functionality built in. Classes which access files and/or hardware are most prone to runtime errors. To properly "catch" such errors, the above example should be rewritten as shown below.
|
||||
|
||||
\code
|
||||
// sineosc.cpp
|
||||
|
||||
#include "WaveLoop.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Set the global sample rate before creating class instances.
|
||||
Stk::setSampleRate( 44100.0 );
|
||||
|
||||
WaveLoop *input = 0;
|
||||
WvOut *output = 0;
|
||||
|
||||
try {
|
||||
// Define and load the sine wave file
|
||||
input = new WaveLoop( "rawwaves/sinewave.raw", TRUE );
|
||||
|
||||
// Define and open a 16-bit, one-channel WAV formatted output file
|
||||
output = new WvOut( "hellosine.wav", 1, WvOut::WVOUT_WAV, Stk::STK_SINT16 );
|
||||
}
|
||||
catch ( StkError & ) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
input->setFrequency( 440.0 );
|
||||
|
||||
// Run the oscillator for 40000 samples, writing to the output file
|
||||
for ( int i=0; i<40000; i++ ) {
|
||||
|
||||
try {
|
||||
output->tick( input->tick() );
|
||||
}
|
||||
catch ( StkError & ) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
\include sineosc.cpp
|
||||
|
||||
In this particular case, we simply exit the program if an error occurs (an error message is automatically printed to stderr). A more refined program might attempt to recover from or fix a particular problem and, if successful, continue processing. See the \ref classes to determine which constructors and functions can throw an error.
|
||||
|
||||
[<A HREF="compile.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
[<A HREF="compile.html">Next tutorial</A>] [<A HREF="fundamentals.html">Main tutorial page</A>]
|
||||
*/
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
<BODY BGCOLOR="white">
|
||||
|
||||
<center><h3>Perry R. Cook & Gary P. Scavone</h3></center>
|
||||
\htmlonly
|
||||
<h3><center><a href="http://www.cs.princeton.edu/~prc/">Perry R. Cook</a> & <a href="http://music.mcgill.ca/~gary/">Gary P. Scavone</a></center></h3>
|
||||
\endhtmlonly
|
||||
|
||||
The <B>Synthesis ToolKit in C++ (STK)</B> is a set of open source audio signal processing and algorithmic synthesis classes written in C++. 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 8 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 <B>Synthesis ToolKit in C++ (STK)</B> 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.
|
||||
|
||||
- \ref information
|
||||
- \ref classes
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
<UL>
|
||||
<LI><A HREF="Papers/stkicmc99.pdf">ICMC99 Paper</A></LI>
|
||||
<BR>
|
||||
A somewhat recent paper by Perry and Gary about the Synthesis ToolKit in C++.
|
||||
A not-so-recent paper by Perry and Gary about the Synthesis ToolKit in C++.
|
||||
<P>
|
||||
<LI><A HREF="Papers/STKsiggraph96.pdf">SIGGRAPH96 Paper</A></LI>
|
||||
<BR>
|
||||
A not-so-recent paper by Perry about the Synthesis ToolKit in C++.
|
||||
A very-not-so-recent paper by Perry about the Synthesis ToolKit in C++.
|
||||
<P>
|
||||
<LI><A HREF="http://www.cs.princeton.edu/~prc/NewWork.html#STK">Perry's STK Web Page</A></LI>
|
||||
<BR>
|
||||
@@ -18,14 +18,14 @@ This is a link to Perry Cook's STK Web page. He has information about the \ref
|
||||
|
||||
<H4>What is the <I>Synthesis ToolKit</I>?</H4>
|
||||
|
||||
The Synthesis ToolKit in C++ (STK) is a set of open source audio signal processing and algorithmic synthesis classes written in C++. 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 8 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 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 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 <A HREF="http://dev.scriptics.com">Tcl/Tk</A> 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. <A HREF="http://www-ccrma.stanford.edu/software/snd/">Snd</A>, Cool Edit, Matlab).
|
||||
|
||||
|
||||
<H4>What the <I>Synthesis ToolKit</I> is not.</H4>
|
||||
|
||||
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. It is easy to embed STK classes inside a GUI environment but we have chosen to focus our energy on the audio signal processing issues. Spending hundreds of hours making platform-dependent graphical user interfaces 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 <A HREF="http://dev.scriptics.com">Tcl/Tk</A> (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).
|
||||
|
||||
@@ -33,7 +33,7 @@ For those instances where a simple GUI with sliders and buttons is helpful, we u
|
||||
|
||||
Perry Cook began developing a pre-cursor to the Synthesis ToolKit (also called STK) under NeXTStep at the Center for Computer Research in Music and Acoustics (CCRMA) at Stanford University in the early-1990s. With his move to Princeton University in 1996, he ported everything to C++ on SGI hardware, added real-time capabilities, and greatly expanded the synthesis techniques available. With the help of Bill Putnam, Perry also made a port of STK to Windows95. Gary Scavone began using STK extensively in the summer of 1997 and completed a full port of STK to Linux early in 1998. He finished the fully compatable Windows port (using Direct Sound API) in June 1998. Numerous improvements and extensions have been made since then.
|
||||
|
||||
The Toolkit has been distributed continuously since 1996 via the <A HREF="http://www.music.princeton.edu/psk">Princeton Sound Kitchen</A>, <A HREF="http://www.cs.princeton.edu/~prc">Perry Cook's home page</A> at Princeton, <A HREF="http://www-ccrma.stanford.edu/~gary/">Gary Scavone's home page</A> at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), and the <A HREF="http://www-ccrma.stanford.edu/software/stk">Synthesis ToolKit home page</A>. The ToolKit has been in included in various collections of software. Much of it has also been ported to MAX/MSP on Macintosh computers by Dan Trueman and Luke Dubois of Columbia University, and is distributed as <A HREF="http://music.columbia.edu/PeRColate">PeRColate</A>. Help on real-time sound and MIDI has been provided by Tim Stilson, Bill Putnam, and Gabriel Maldonado.
|
||||
The Toolkit has been distributed continuously since 1996 via the <A HREF="http://www.music.princeton.edu/psk">Princeton Sound Kitchen</A>, <A HREF="http://www.cs.princeton.edu/~prc">Perry Cook's home page</A> at Princeton, <A HREF="http://www-ccrma.stanford.edu/~gary/">Gary Scavone's home page</A> at Stanford's Center for Computer Research in Music and Acoustics (CCRMA), and the <A HREF="http://www-ccrma.stanford.edu/software/stk">Synthesis ToolKit home page</A>. The ToolKit has been included in various collections of software. Much of it has also been ported to Max/MSP on Macintosh computers by Dan trueman and Luke Dubois of Columbia University, and is distributed as <A HREF="http://music.columbia.edu/PeRColate">PeRColate</A>. Help on real-time sound and MIDI has been provided over the years by Tim Stilson, Bill Putnam, and Gabriel Maldonado.
|
||||
|
||||
<H4>Legal and Ethical Notes</H4>
|
||||
|
||||
@@ -47,4 +47,32 @@ Some of the concepts are covered by various patents, some known to us and likely
|
||||
|
||||
STK is free and we do not guarantee anything. We've been hacking on this code for a while now and most of it seems to work pretty well. But, there surely are some bugs floating around. Sometimes things work fine on one computer platform but not so fine on another. FPU overflows and underflows cause <I>very</I> weird behavior which also depends on the particular CPU and OS. Let us know about bugs you find and we'll do our best to correct them.
|
||||
|
||||
*/
|
||||
<H4>Perry's Notes From the Original Distribution of STK</H4>
|
||||
|
||||
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.
|
||||
|
||||
<ol>
|
||||
<li>I needed to port many of the things I've done into something which is generic enough to port further to different machines.</li>
|
||||
|
||||
<li>I really plan to document this stuff, so that you don't have to be me to figure out what's going on. (I'll probably be sorry I said this in a couple of years, when even I can't figure out what I was thinking.)</li>
|
||||
|
||||
<li>The classic difficulties most people have in trying to implement physical models are:
|
||||
|
||||
<ul>
|
||||
<li>They have trouble understanding the papers, and/or in turning the theory into practice.</li>
|
||||
|
||||
<li>The physical model instruments are a pain to get to oscillate, and coming up with stable and meaningful parameter values is required to get the models to work at all.</li>
|
||||
</ul>
|
||||
|
||||
This set of C++ unit generators and instruments might help to diminish the scores of emails I get asking what to do with those block diagrams I put in my papers.</li>
|
||||
|
||||
<li>I wanted to try some new stuff with modal synthesis, and implement some classic FM patches as well.</li>
|
||||
|
||||
<li>I wanted to reimplement, and newly implement more of the intelligent and physical performer models I've talked about in some of my papers. But I wanted to do it in a portable way, and in such a way that I can hook up modules quickly. I also wanted to make these instruments connectable to such player objects, so folks like Brad Garton who really think a lot about the players can connect them to my instruments, a lot about which I think.</li>
|
||||
|
||||
<li>More rationalizations to follow ...</li>
|
||||
</ol>
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,66 +1,8 @@
|
||||
/*! \page instruments Instruments
|
||||
|
||||
The ToolKit comes with a wide variety of synthesis algorithms, all of which inherit from the Instrmnt class. In this example, we'll fire up an instance of the BeeThree FM synthesis class and show how it's frequency can be modified over time.
|
||||
The ToolKit comes with a wide variety of synthesis algorithms, all of which inherit from the Instrmnt class. In this example, we'll fire up an instance of the BeeThree FM synthesis class and show how its frequency can be modified over time.
|
||||
|
||||
\code
|
||||
// bethree.cpp
|
||||
|
||||
#include "BeeThree.h"
|
||||
#include "RtWvOut.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Set the global sample rate before creating class instances.
|
||||
Stk::setSampleRate( 44100.0 );
|
||||
|
||||
Instrmnt *instrument = 0;
|
||||
RtWvOut *output = 0;
|
||||
MY_FLOAT frequency, amplitude, scaler;
|
||||
long counter, i;
|
||||
|
||||
try {
|
||||
// Define and load the BeeThree instrument
|
||||
instrument = new BeeThree();
|
||||
|
||||
// Define and open the default realtime output device for one-channel playback
|
||||
output = new RtWvOut(1);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
scaler = 1.0;
|
||||
frequency = 220.0;
|
||||
amplitude = 0.5;
|
||||
instrument->noteOn( frequency, amplitude );
|
||||
|
||||
// Play the instrument for 80000 samples, changing the frequency every 2000 samples
|
||||
counter = 0;
|
||||
while ( counter < 80000 ) {
|
||||
for ( i=0; i<2000; i++ ) {
|
||||
try {
|
||||
output->tick( instrument->tick() );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
counter += 2000;
|
||||
scaler += 0.025;
|
||||
instrument->setFrequency( frequency * scaler );
|
||||
}
|
||||
|
||||
// Turn the instrument off with maximum decay envelope.
|
||||
instrument->noteOff( 1.0 );
|
||||
|
||||
cleanup:
|
||||
delete instrument;
|
||||
delete output;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
\include bethree.cpp
|
||||
|
||||
We have used an Instrmnt pointer when referencing the BeeThree instance above, so it would be simple to replace the BeeThree class with any other STK instrument class. It should be noted, however, that a few classes do not respond to the setFrequency() function (e.g., Shakers, Drummer).
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
/*! \page links Miscellaneous Links
|
||||
|
||||
- <A HREF="http://www-ccrma.stanford.edu/~gary/rtaudio/">The RtAudio WWW site</A>
|
||||
- <A HREF="http://music.mcgill.ca/~gary/rtaudio/">The %RtAudio WWW site</A>
|
||||
|
||||
- <A HREF="http://music.mcgill.ca/~gary/rtmidi/">The %RtMidi WWW site</A>
|
||||
|
||||
- <A HREF="http://chuck.cs.princeton.edu/">ChucK: Concurrent, On-the-fly Audio Programming Language</A> using STK unit generators
|
||||
|
||||
- <A HREF="http://www.music.princeton.edu/paul/stkugens.tar.gz">Paul Lansky's port of STK to SuperCollider</A>
|
||||
|
||||
- <A HREF="http://kern.humdrum.net/">Kern Scores: A Library of Electronic Musical Scores</A> (with automatic conversion to SKINI format)
|
||||
|
||||
|
||||
@@ -8,63 +8,7 @@ Multi-channel support for realtime audio input and output is dependent on the au
|
||||
|
||||
The following example demonstrates the use of the WvOut class for creating a four channel, 16-bit AIFF formatted audio file. We will use four sinewaves of different frequencies for the first two seconds and then a single sinewave for the last two seconds.
|
||||
|
||||
\code
|
||||
// foursine.cpp
|
||||
|
||||
#include "WaveLoop.h"
|
||||
#include "WvOut.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Set the global sample rate before creating class instances.
|
||||
Stk::setSampleRate( 44100.0 );
|
||||
|
||||
int i, j;
|
||||
WvOut *output = 0;
|
||||
WaveLoop *inputs[4];
|
||||
for ( i=0; i<4; i++ ) inputs[i] = 0;
|
||||
|
||||
// Define and load the sine waves
|
||||
try {
|
||||
for ( i=0; i<4; i++ ) {
|
||||
inputs[i] = new WaveLoop( "rawwaves/sinewave.raw", TRUE );
|
||||
inputs[i]->setFrequency( 220.0 * (i+1) );
|
||||
}
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Define and open a 16-bit, four-channel AIFF formatted output file
|
||||
try {
|
||||
output = new WvOut( "foursine.aif", 4, WvOut::WVOUT_AIF, Stk::STK_SINT16 );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Write two seconds of four sines to the output file
|
||||
MY_FLOAT frame[4];
|
||||
for ( j=0; j<88200; j++ ) {
|
||||
for ( i=0; i<4; i++ )
|
||||
frame[i] = inputs[i]->tick();
|
||||
|
||||
output->tickFrame( frame );
|
||||
}
|
||||
|
||||
// Now write the first sine to all four channels for two seconds
|
||||
for ( j=0; j<88200; j++ ) {
|
||||
output->tick( inputs[0]->tick() );
|
||||
}
|
||||
|
||||
cleanup:
|
||||
for ( i=0; i<4; i++ ) delete inputs[i];
|
||||
delete output;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\include foursine.cpp
|
||||
|
||||
[<A HREF="polyvoices.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
*/
|
||||
|
||||
@@ -1,122 +1,22 @@
|
||||
/*! \page polyvoices Voice Management
|
||||
|
||||
The previous tutorial chapters were concerned only with monophonic ToolKit instrument playback and control. At this point, it should be relatively clear that one can instantiate multiple instruments and perhaps sum together their sounds or even direct their sounds to separate output channels. It is less clear how one might go about controlling a group of instruments. The Voicer class is designed to serve just this purpose.
|
||||
The previous tutorial chapters were concerned only with monophonic ToolKit instrument playback and control. At this point, it should be relatively clear that one can instantiate multiple instruments and perhaps sum together their outputs or even direct their outputs to separate channels. It is less clear how one might go about controlling a group of instruments. The Voicer class is designed to serve just this purpose.
|
||||
|
||||
The STK Voicer class is a relatively simple voice manager. The user can dynamically add and delete instruments from its "control", with the option of controlling specific instruments via unique note tags and/or grouping sets of instruments via a "channel" number. All sounding instrument outputs are summed and returned via the <TT>tick()</TT> function. The Voicer class responds to noteOn, noteOff, setFrequency, pitchBend, and controlChange messages, automatically assigning incoming messages to the voices in its control. When all voices are sounding and a new noteOn is encountered, the Voicer interrupts the oldest sounding voice. The user is responsible for creating and deleting all instrument instances.
|
||||
The STK Voicer class is a relatively simple voice manager. The user can dynamically add and delete instruments to/from its "control", with the option of controlling specific instruments via unique note tags and/or grouping sets of instruments via a "channel" number. All sounding instrument outputs are summed and returned via the <TT>tick()</TT> function. The Voicer class responds to noteOn, noteOff, setFrequency, pitchBend, and controlChange messages, automatically assigning incoming messages to the voices in its control. When all voices are sounding and a new noteOn is encountered, the Voicer interrupts the oldest sounding voice. The user is responsible for creating and deleting all instrument instances.
|
||||
|
||||
In the following example, we modify the <TT>controlbee.cpp</TT> program to make use of three BeeThree instruments, all controlled using a Voicer.
|
||||
|
||||
\code
|
||||
// threebees.cpp
|
||||
\include threebees.cpp
|
||||
|
||||
#include "BeeThree.h"
|
||||
#include "RtWvOut.h"
|
||||
#include "Messager.h"
|
||||
#include "Voicer.h"
|
||||
#include "SKINI.msg"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Set the global sample rate before creating class instances.
|
||||
Stk::setSampleRate( 44100.0 );
|
||||
|
||||
int i;
|
||||
RtWvOut *output = 0;
|
||||
Messager *messager = 0;
|
||||
Voicer *voicer = 0;
|
||||
bool done = FALSE;
|
||||
Instrmnt *instrument[3];
|
||||
for ( i=0; i<3; i++ ) instrument[i] = 0;
|
||||
|
||||
try {
|
||||
// Define and load the BeeThree instruments
|
||||
for ( i=0; i<3; i++ )
|
||||
instrument[i] = new BeeThree();
|
||||
|
||||
// Define and open the default realtime output device for one-channel playback
|
||||
output = new RtWvOut(1);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
try {
|
||||
// Create a Messager instance to read from a redirected SKINI scorefile.
|
||||
messager = new Messager();
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Instantiate the voicer for a maximum of three voices.
|
||||
voicer = new Voicer( 3 );
|
||||
for ( i=0; i<3; i++ )
|
||||
voicer->addInstrument( instrument[i] );
|
||||
|
||||
// Play the instrument until the end of the scorefile.
|
||||
int nTicks, type;
|
||||
MY_FLOAT byte2, byte3;
|
||||
while (!done) {
|
||||
|
||||
// Look for new messages and return a delta time (in samples).
|
||||
type = messager->nextMessage();
|
||||
if (type < 0)
|
||||
done = TRUE;
|
||||
|
||||
nTicks = messager->getDelta();
|
||||
try {
|
||||
for ( i=0; i<nTicks; i++ )
|
||||
output->tick( voicer->tick() );
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ( type > 0 ) {
|
||||
// Process the new control message.
|
||||
byte2 = messager->getByteTwo();
|
||||
byte3 = messager->getByteThree();
|
||||
|
||||
switch(type) {
|
||||
|
||||
case __SK_NoteOn_:
|
||||
voicer->noteOn( byte2, byte3 );
|
||||
break;
|
||||
|
||||
case __SK_NoteOff_:
|
||||
voicer->noteOff( byte2, byte3 );
|
||||
break;
|
||||
|
||||
case __SK_ControlChange_:
|
||||
voicer->controlChange( (int) byte2, byte3 );
|
||||
break;
|
||||
|
||||
case __SK_AfterTouch_:
|
||||
voicer->controlChange( 128, byte2 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
for ( i=0; i<3; i++ ) delete instrument[i];
|
||||
delete output;
|
||||
delete messager;
|
||||
delete voicer;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
Assuming the program is compiled as <TT>threebees</TT>, the three-voice SKINI scorefile <A HREF="tutorial/bachfugue.ski"><TT>bachfugue.ski</TT></A> (also located in the <tt>scores</tt> directory with the examples) could be redirected to the program as:
|
||||
We have written this program to accept control messages from \c STDIN. Assuming the program is compiled as <TT>threebees</TT>, the three-voice SKINI scorefile <A HREF="tutorial/bachfugue.ski"><TT>bachfugue.ski</TT></A> (located in the <tt>scores</tt> directory with the examples) can be redirected to the program as:
|
||||
|
||||
\code
|
||||
threebees < bachfugue.ski
|
||||
threebees < scores/bachfugue.ski
|
||||
\endcode
|
||||
|
||||
For more fun, surf to <A HREF="http://kern.humdrum.net/">Kern Scores</A> for a huge assortment of other scorefiles which can be downloaded in the SKINI format.
|
||||
|
||||
Another easy extension would be to use the <TT>STK_MIDI</TT> constructor argument to the Messager class and then play the instruments via a MIDI keyboard.
|
||||
Another easy extension would be to add the \c Messager::startMidiInput() function to the program and then play the instruments via a MIDI keyboard.
|
||||
|
||||
[<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
*/
|
||||
|
||||
@@ -1,72 +1,28 @@
|
||||
/*! \page realtime Realtime Audio
|
||||
/*! \page realtime Realtime Audio (blocking)
|
||||
|
||||
In this section, we modify the <TT>sineosc.cpp</TT> program in order to send the output to the default audio playback device on your system.
|
||||
In this section, we modify the <TT>sineosc.cpp</TT> program in order to send the output to the default audio playback device on your computer system.
|
||||
|
||||
\code
|
||||
// rtsine.cpp
|
||||
\include rtsine.cpp
|
||||
|
||||
#include "WaveLoop.h"
|
||||
#include "RtWvOut.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Set the global sample rate before creating class instances.
|
||||
Stk::setSampleRate( 44100.0 );
|
||||
|
||||
WaveLoop *input = 0;
|
||||
RtWvOut *output = 0;
|
||||
|
||||
try {
|
||||
// Define and load the sine wave file
|
||||
input = new WaveLoop( "rawwaves/sinewave.raw", TRUE );
|
||||
|
||||
// Define and open the default realtime output device for one-channel playback
|
||||
output = new RtWvOut(1);
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
input->setFrequency(440.0);
|
||||
|
||||
// Play the oscillator for 40000 samples
|
||||
int i;
|
||||
for ( i=0; i<40000; i++ ) {
|
||||
try {
|
||||
output->tick(input->tick());
|
||||
}
|
||||
catch (StkError &) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
delete input;
|
||||
delete output;
|
||||
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
The class RtWvOut is a protected subclass of WvOut. A number of optional constructor arguments can be used to fine tune its performance for a given system.
|
||||
The class RtWvOut is a protected subclass of WvOut. A number of optional constructor arguments can be used to fine tune its performance for a given system. RtWvOut provides a "single-sample" interface to the RtAudio class. Note that RtWvOut (as well as the RtWvIn and RtDuplex classes described below) make use of RtAudio's blocking input/output functionality. On systems which implement an inherently callback-based audio API, this blocking functionality will be less robust. An example of audio output using a callback scheme will be discussed in a subsequent tutorial section.
|
||||
|
||||
Though not used here, an RtWvIn class exists as well which can be used to read realtime audio data from an input device. See the <TT>record.cpp</TT> example program in the <TT>examples</TT> project for more information.
|
||||
|
||||
It is possible to use an instance of RtWvOut and an instance of RtWvIn to simultaneously read and write realtime audio to and from a hardware device or devices. However, it is recommended to instead use a single instance of RtDuplex to achieve this behavior, in that it guarantees better synchronization between the input and output data. See the <TT>effects</TT> project or the <TT>io.cpp</TT> example program in the <TT>examples</TT> project for more information.
|
||||
It may be possible to use an instance of RtWvOut and an instance of RtWvIn to simultaneously read and write realtime audio to and from a hardware device or devices. However, it is recommended to instead use a single instance of RtDuplex to achieve this behavior, in that it guarantees better synchronization between the input and output data. See the <TT>effects</TT> project or the <TT>io.cpp</TT> example program in the <TT>examples</TT> project for more information.
|
||||
|
||||
When using any realtime STK class (RtAudio, RtWvOut, RtWvIn, RtDuplex, RtMidi, TcpWvIn, TcpWvOut, Socket, and Thread), it is necessary to specify an audio/MIDI API preprocessor definition and link with the appropriate libraries or frameworks. For example, the above program could be compiled on a Linux system using the GNU g++ compiler and the ALSA audio/MIDI API as follows (assuming all necessary files exist in the project directory):
|
||||
When using any realtime STK class (RtAudio, RtWvOut, RtWvIn, RtDuplex, RtMidi, TcpWvIn, TcpWvOut, Socket, and Thread), it is necessary to specify an audio/MIDI API preprocessor definition and link with the appropriate libraries or frameworks. For example, the above program could be compiled on a Linux system using the GNU g++ compiler and the ALSA audio API as follows (assuming all necessary files exist in the project directory):
|
||||
|
||||
\code
|
||||
g++ -Wall -D__LINUX_ALSA__ -D__LITTLE_ENDIAN__ -o rtsine Stk.cpp WvIn.cpp WaveLoop.cpp WvOut.cpp \
|
||||
RtWvOut.cpp RtAudio.cpp rtsine.cpp -lpthread -lasound -lstk
|
||||
RtWvOut.cpp RtAudio.cpp rtsine.cpp -lpthread -lasound
|
||||
\endcode
|
||||
|
||||
On a Macintosh OS X system, the syntax would be:
|
||||
|
||||
\code
|
||||
CC -D__MACOSX_CORE__ -o rtsine Stk.cpp WvIn.cpp WaveLoop.cpp WvOut.cpp RtWvOut.cpp RtAudio.cpp \
|
||||
rtsine.cpp -lpthread -lstdc++ -lstk -framework CoreAudio -framework CoreMIDI -framework CoreFoundation
|
||||
g++ -Wall -D__MACOSX_CORE__ -o rtsine Stk.cpp WvIn.cpp WaveLoop.cpp WvOut.cpp RtWvOut.cpp RtAudio.cpp \
|
||||
rtsine.cpp -lpthread -framework CoreAudio -framework CoreMIDI -framework CoreFoundation
|
||||
\endcode
|
||||
|
||||
[<A HREF="instruments.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
[<A HREF="crealtime.html">Next tutorial</A>] [<A HREF="tutorial.html">Main tutorial page</A>]
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ This describes the latest (version 1.1) implementation of SKINI for the Synthesi
|
||||
A SKINI haiku.
|
||||
\endcode
|
||||
|
||||
Profound thanks to Dan Trueman, Brad Garton, and Gary Scavone for input on this revision. Thanks also to MIDI, the NeXT MusicKit, ZIPI and all the creators and modifiers of these for good bases upon/from which to build and depart.
|
||||
Profound thanks to Dan trueman, Brad Garton, and Gary Scavone for input on this revision. Thanks also to MIDI, the NeXT MusicKit, ZIPI and all the creators and modifiers of these for good bases upon/from which to build and depart.
|
||||
|
||||
\section compatibility MIDI Compatibility
|
||||
|
||||
@@ -16,7 +16,7 @@ SKINI was designed to be MIDI compatible wherever possible, and extend MIDI in i
|
||||
|
||||
Differences from MIDI, and motivations, include:
|
||||
|
||||
- Text-based messages are used, with meaningful names wherever possible. This allows any language or system capable of formatted printing to generate SKINI. Similarly, any system capable of reading in a string and turning delimited fields into strings, floats, and ints can consume SKINI for control. More importantly, humans can actually read, and even write if they want, SKINI files and streams. Use an editor and search/replace or macros to change a channel or control number. Load a SKINI score into a spread sheet to apply transformations to time, control parameters, MIDI velocities, etc. Put a monkey on a special typewriter and get your next great work. Life's too short to debug bit/nybble packed variable length mumble messages. Disk space gets cheaper, available bandwidth increases, music takes up so little space and bandwidth compared to video and grapics. Live a little.
|
||||
- Text-based messages are used, with meaningful names wherever possible. This allows any language or system capable of formatted printing to generate SKINI. Similarly, any system capable of reading in a string and turning delimited fields into strings, floats, and ints can consume SKINI for control. More importantly, humans can actually read, and even write if they want, SKINI files and streams. Use an editor and search/replace or macros to change a channel or control number. Load a SKINI score into a spread sheet to apply transformations to time, control parameters, MIDI velocities, etc. Put a monkey on a special typewriter and get your next great work. Life's too short to debug bit/nybble packed variable length mumble messages. Disk space gets cheaper, available bandwidth increases, music takes up so little space and bandwidth compared to video and graphics. Live a little.
|
||||
|
||||
- Floating point numbers are used wherever possible. Note Numbers, Velocities, Controller Values, and Delta and Absolute Times are all represented and scanned as ASCII double-precision floats. MIDI byte values are preserved, so that incoming MIDI bytes from an interface can be put directly into SKINI messages. 60.0 or 60 is middle C, 127.0 or 127 is maximum velocity etc. But, unlike MIDI, 60.5 can cause a 50 cent sharp middle C to be played. As with MIDI byte values like velocity, use of the integer and SKINI-added fractional parts is up to the implementor of the algorithm being controlled by SKINI messages. But the extra precision is there to be used or ignored.
|
||||
|
||||
@@ -38,13 +38,13 @@ All fields other than type, time, and channel are optional, and the types and us
|
||||
|
||||
The other important file used by SKINI is SKINI.msg, which is a set of #defines to make C code more readable, and to allow reasonably quick re-mapping of control numbers, etc.. All of these defined symbols are assigned integer values. For Java, the #defines could be replaced by declaration and assignment statements, preserving the look and behavior of the rest of the code.
|
||||
|
||||
\section cfiles C Files Used To Implement SKINI
|
||||
\section cfiles Files Used To Implement SKINI
|
||||
|
||||
SKINI.cpp is an object which can either open a SKINI file, and successively read and parse lines of text as SKINI strings, or accept strings from another object and parse them. The latter functionality would be used by a socket, pipe, or other connection receiving SKINI messages a line at a time, usually in real time, but not restricted to real time.
|
||||
Skini.cpp is a C++ object which can either open a SKINI file and successively read and parse lines of text as SKINI strings, or accept strings from another object and parse them. The latter functionality would be used by a socket, pipe, or other connection receiving SKINI messages a line at a time, usually in real time, but not restricted to real time.
|
||||
|
||||
SKINI.msg should be included by anything wanting to use the SKINI.cpp object. This is not mandatory, but use of the __SK_blah_ symbols which are defined in the .msg file will help to ensure clarity and consistency when messages are added and changed.
|
||||
SKINI.msg should be included by anything wanting to use the Skini.cpp object. This is not mandatory, but use of the __SK_blah_ symbols which are defined in the .msg file will help to ensure clarity and consistency when messages are added and changed.
|
||||
|
||||
SKINI.tbl is used only by the SKINI parser object (SKINI.cpp). In the file SKINI.tbl, an array of structures is declared and assigned values which instruct the parser as to what the message types are, and what the fields mean for those message types. This table is compiled and linked into applications using SKINI, but could be dynamically loaded and changed in a future version of SKINI.
|
||||
SKINI.tbl is used only by the SKINI parser object (Skini.cpp). In the file SKINI.tbl, an array of structures is declared and assigned values which instruct the parser as to what the message types are, and what the fields mean for those message types. This table is compiled and linked into applications using SKINI, but could be dynamically loaded and changed in a future version of SKINI.
|
||||
|
||||
\section parser SKINI Messages and the SKINI Parser:
|
||||
|
||||
@@ -102,7 +102,7 @@ The parser isn't all that smart, but neither am I. Here are the basic rules gov
|
||||
|
||||
\section table The SKINI.tbl File and Message Parsing:
|
||||
|
||||
The SKINI.tbl file contains an array of structures which are accessed by the parser object SKINI.cpp. The struct is:
|
||||
The SKINI.tbl file contains an array of structures which are accessed by the parser object Skini.cpp. The struct is:
|
||||
|
||||
\code
|
||||
struct SKINISpec {
|
||||
@@ -164,55 +164,53 @@ The StringDamping and StringDetune messages behave the same as the Volume messag
|
||||
Here's a simple example of code which uses the SKINI object to read a SKINI file and control a single instrument.
|
||||
|
||||
\code
|
||||
Skini score;
|
||||
Skini::Message message;
|
||||
instrument = new Mandolin(50.0);
|
||||
score = new SKINI(argv[1]);
|
||||
while(score->getType() > 0) {
|
||||
tempDouble = score->getDelta();
|
||||
if (tempDouble < 0) {
|
||||
tempDouble = - tempDouble;
|
||||
tempDouble = tempDouble - output.getTime();
|
||||
if (tempDouble < 0) {
|
||||
printf("Bad News Here!!! Backward Absolute Time Required.\n");
|
||||
tempDouble = 0.0;
|
||||
}
|
||||
score.setFile( argv[1] );
|
||||
while ( score.nextMessage( message ) != 0 ) {
|
||||
tempDouble = message.time;
|
||||
if (tempDouble < 0) {
|
||||
tempDouble = - tempDouble;
|
||||
tempDouble = tempDouble - output.getTime();
|
||||
if (tempDouble < 0) {
|
||||
printf("Bad News Here!!! Backward Absolute Time Required.\n");
|
||||
tempDouble = 0.0;
|
||||
}
|
||||
tempLong = (long) (tempDouble * Stk::sampleRate());
|
||||
for (i=0;i<tempLong;i++) {
|
||||
output.tick(instrument->tick());
|
||||
}
|
||||
tempLong = (long) ( tempDouble * Stk::sampleRate() );
|
||||
for ( i=0; i<tempLong; i++ ) {
|
||||
output.tick( instrument->tick() );
|
||||
}
|
||||
|
||||
tempDouble3 = message.floatValues[1] * NORM_MIDI;
|
||||
if ( message.type == __SK_NoteOn_ ) {
|
||||
if ( tempDouble3 == 0.0 ) {
|
||||
tempDouble3 = 0.5;
|
||||
instrument->noteOff( tempDouble3 );
|
||||
}
|
||||
tempDouble3 = score->getByteThree();
|
||||
if (score->getType()== __SK_NoteOn_ ) {
|
||||
tempDouble3 *= NORM_MIDI;
|
||||
if (score->getByteThree() == 0) {
|
||||
tempDouble3 = 0.5;
|
||||
instrument->noteOff(tempDouble3);
|
||||
}
|
||||
else {
|
||||
tempLong = (int) score->getByteTwo();
|
||||
tempDouble2 = Midi2Pitch[tempLong];
|
||||
instrument->noteOn(tempDouble2,tempDouble3);
|
||||
}
|
||||
else {
|
||||
tempLong = message.intValues[0];
|
||||
tempDouble2 = Midi2Pitch[tempLong];
|
||||
instrument->noteOn( tempDouble2, tempDouble3 );
|
||||
}
|
||||
else if (score->getType() == __SK_NoteOff_) {
|
||||
tempDouble3 *= NORM_MIDI;
|
||||
instrument->noteOff(tempDouble3);
|
||||
}
|
||||
else if (score->getType() == __SK_ControlChange_) {
|
||||
tempLong = score->getByteTwoInt();
|
||||
instrument->controlChange(tempLong,temp3.0);
|
||||
}
|
||||
score->nextMessage();
|
||||
}
|
||||
else if ( message.type == __SK_NoteOff_ ) {
|
||||
instrument->noteOff( tempDouble3 );
|
||||
}
|
||||
else if ( message.type == __SK_ControlChange_ ) {
|
||||
tempLong = message.intValues[0];
|
||||
instrument->controlChange( tempLong, tempDouble3 );
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
When the score (SKINI object) object is created from the filename in argv[1], the first valid command line is read from the file and parsed.
|
||||
When a SKINI score is passed to a Skini object using the Skini::setFile() function, valid messages are read from the file and returned using the Skini::nextMessage() function.
|
||||
|
||||
The score->getType() retrieves the messageType. If this is -1, there are no more valid messages in the file and the synthesis loop terminates. Otherwise, the message type is returned.
|
||||
A Skini::Message structure contains all the information parsed from a single SKINI message. A returned message type of zero indicates either an invalid message or the end of a scorefile.
|
||||
|
||||
getDelta() retrieves the deltaTime until the current message should occur. If this is greater than 0, synthesis occurs until the deltaTime has elapsed. If deltaTime is less than zero, the time is interpreted as absolute time and the output device is queried as to what time it is now. That is used to form a deltaTime, and if it's positive we synthesize. If it's negative, we print an error and pretend this never happened and we hang around hoping to eventually catch up.
|
||||
The "time" member of a Skini::Message is the deltaTime until the current message should occur. If this is greater than 0, synthesis occurs until the deltaTime has elapsed. If deltaTime is less than zero, the time is interpreted as absolute time and the output device is queried as to what time it is now. That is used to form a deltaTime, and if it's positive we synthesize. If it's negative, we print an error, pretend this never happened and we hang around hoping to eventually catch up.
|
||||
|
||||
The rest of the code sorts out message types NoteOn, NoteOff (including NoteOn with velocity 0), and ControlChange. The code implicitly takes into account the integer type of the control number, but all other data is treated as double float.
|
||||
|
||||
The last line reads and parses the next message in the file.
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -2,23 +2,24 @@
|
||||
|
||||
<B>General:</B>
|
||||
<UL>
|
||||
<LI>A MIDI interface to use MIDI input controls. (NOTE: This may be built into the soundcard on your computer.)</LI>
|
||||
<LI>A MIDI interface to use MIDI input/output controls. (NOTE: This may be built into the soundcard on your computer.)</LI>
|
||||
<LI><A HREF="http://dev.scriptics.com">Tcl/Tk</A> version 8.0 or higher to use the simple Tcl/Tk GUIs provided with the STK distribution (available free over the WWW for all supported realtime platforms).</LI>
|
||||
</UL>
|
||||
|
||||
<B>Linux (specific):</B>
|
||||
<UL>
|
||||
<LI>A soundcard to use realtime audio input/output capabilities. In order to use the <I><B>effects</B></I> project, the soundcard and drivers must support full duplex mode.</LI>
|
||||
<LI><A HREF="http://www.opensound.com">OSS</A> or <A HREF="http://www.alsa-project.org/">ALSA</A> device drivers for realtime sound output and MIDI input.</LI>
|
||||
<LI><A HREF="http://www.alsa-project.org/">ALSA</A> device drivers and library for realtime sound and MIDI input/output. <A HREF="http://www.opensound.com">OSS</A> device drivers can be used for audio input/output, but MIDI support requires the ALSA library to compile.</LI>
|
||||
</UL>
|
||||
|
||||
<B>Macintosh OS X (specific):</B>
|
||||
<UL>
|
||||
<LI>A C++ compiler does not ship by default with OS X. It is necessary to download the Developer Kit from the Apple WWW site in order to compile STK.</LI>
|
||||
<LI><B>IMPORTANT:</B>The internal Macintosh audio hardware typically supports a sample rate of 44100 Hz only. Therefore, it is necessary to either specify this rate as a command-line option to the STK example programs or to change the default sample rate inside the Stk.h file before compilation. In addition, the RT_BUFFER_SIZE, specified in Stk.h, could be increased (to a higher power of two) for more robust performance.</LI>
|
||||
<LI>The tcl/tk interpreter does not ship by default with OS X, but must be downloaded from the internet. The latest Tcl/Tk Aqua distribution (http://www.apple.com/downloads/macosx/unix_open_source/tcltk.html) has been successfully tested on a 10.2 system. The default installation will place a link to the wish interpretor at /usr/bin/wish.
|
||||
<LI>A C++ compiler does install by default with OS X. It is necessary to download the Developer Kit from the Apple WWW site in order to compile STK or load it from the installation CD-ROM.</LI>
|
||||
<LI><B>IMPORTANT:</B>The internal Macintosh audio hardware typically supports a sample rate of 44100 Hz only. The default STK sample rate is now 44100 Hz, but there may be programs which change that value before execution. Check the program code if you have sample rate conflicts. Many of the example project programs allow the sample rate to be specified via the command line.</LI>
|
||||
<LI>If you experience frequent audio input/output "glitches", try increasing the RT_BUFFER_SIZE specified in Stk.h.</LI>
|
||||
<LI>The tcl/tk interpreter does not ship by default with OS X, but must be downloaded from the internet. The latest Tcl/Tk Aqua distribution (http://www.apple.com/downloads/macosx/unix_open_source/tcltk.html) has been successfully tested on 10.2 and 10.3 systems. The default installation will place a link to the wish interpretor at /usr/bin/wish.
|
||||
|
||||
Initial tests have shown somewhat poor response between changes made in the tcl/tk script and the resulting audio updates. It is possible to connect a tcl/tk interface to an STK program via a socket connection. However, the tcl/tk interpreter does not appear to properly close the socket connection during disconnection. It is therefore necessary to type "Exit" in the STK program terminal window to properly exit the STK program.</LI>
|
||||
It appears that socket support in Tcl/Tk uses the Nagle algorithm, which produces poor response between changes made in the tcl/tk script and the resulting audio updates. Note that this is only a problem when using a socket connection from a Tcl/Tk script.</LI>
|
||||
|
||||
</UL>
|
||||
|
||||
@@ -37,4 +38,4 @@ Initial tests have shown somewhat poor response between changes made in the tcl/
|
||||
|
||||
<P>
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
/*! \page tutorial Tutorial
|
||||
|
||||
The Synthesis ToolKit is a set of C++ classes. In order to go beyond the simple example programs we provide, it is necessary to know some basics about programming in C or C++. STK's "target audience" includes people who:
|
||||
The Synthesis ToolKit is a set of C++ classes. In order to go beyond the simple example programs we provide, it is necessary to know some basics about programming in C and C++. STK's "target audience" includes people who:
|
||||
<UL>
|
||||
<LI>want to create audio DSP and/or synthesis programs</LI>
|
||||
<LI>want to save some time by using our unit generators and input/output routines</LI>
|
||||
<LI>want to use our unit generators and input/output routines rather than code their own</LI>
|
||||
<LI>want to learn about synthesis and processing algorithms</LI>
|
||||
<LI>wish to teach real-time synthesis and processing, and wish to use some of our classes and examples</LI>
|
||||
<LI>wish to teach real-time synthesis and processing and wish to use some of our classes and examples</LI>
|
||||
</UL>
|
||||
|
||||
Most ToolKit programmers will likely end up writing a class or two for their own particular needs, but this task is typically simplified by making use of pre-existing STK classes (filters, oscillators, etc.).
|
||||
|
||||
The following tutorial chapters describe many of the fundamental ToolKit concepts and classes. All tutorial programs are included in the <TT>projects/examples</TT> directory.
|
||||
|
||||
-# \ref fundamentals
|
||||
-# \ref hello
|
||||
-# \ref compile
|
||||
-# \ref filtering
|
||||
-# \ref realtime
|
||||
-# \ref crealtime
|
||||
-# \ref instruments
|
||||
-# \ref controlin
|
||||
-# \ref multichannel
|
||||
-# \ref polyvoices
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ The top level distribution contains the following directories:
|
||||
|
||||
<LI> The <I><B>include</B></I> directory contains the header files for all the STK unit generator and algorithm classes.</LI><P>
|
||||
|
||||
<LI> The <I><B>rawwaves</B></I> directory contains various raw, monophonic, 16-bit, big-endian soundfiles used with the STK classes.</LI><P>
|
||||
<LI> The <I><B>rawwaves</B></I> directory contains various raw, monophonic, 16-bit, big-endian, 22050 Hz soundfiles used with the STK classes.</LI><P>
|
||||
|
||||
<LI> The <I><B>doc</B></I> directory contains documentation about STK.</LI><P>
|
||||
|
||||
@@ -37,13 +37,13 @@ This release of STK comes with four separate "project" directories:
|
||||
|
||||
<LI> The <I><B>ragamatic</B></I> project is just cool. Fire it up and be enlightened.<P></LI>
|
||||
|
||||
<LI> The <I><B>examples</B></I> project contains several simple programs which demonstrate audio input/output, as well as the use of the audio internet streaming classes.</LI>
|
||||
<LI> The <I><B>examples</B></I> project contains several simple programs which demonstrate audio input/output, including the audio internet streaming classes, as well as most of the tutorial programs.</LI>
|
||||
</OL>
|
||||
|
||||
\section compiling Compiling:
|
||||
|
||||
<UL>
|
||||
<LI><B>Windows95/98/2000/XP:</B> Realtime support is available using either DirectSound or ASIO audio drivers. For DirectSound support, use the <TT>__WINDOWS_DS__</TT> preprocessor definition and link with the <TT>dsound.lib</TT>, <TT>winmm.lib</TT>, and <TT>Wsock32.lib</TT> libraries. For ASIO support, use the <TT>__WINDOWS_ASIO__</TT> preprocessor definition, include all the files in the <TT>src/asio/</TT> directory (i.e. <TT>asio.h,cpp</TT>, <TT>asiodrivers.h,cpp</TT>, ...), and link with the <TT>winmm.lib</TT>, and <TT>Wsock32.lib</TT> libraries. In addition, the <TT>__LITTLE_ENDIAN__</TT> preprocessor definition is necessary for all Windows systems. A distribution of the release is available with precompiled binaries (using DirectSound) for all the projects. In order for these binaries to function properly, your system must have the DirectX 5.0 (or higher) runtime libraries installed (available from <A HREF="http://www.microsoft.com/directx/">Microsoft</A>). Further, the <I><B>effects</B></I> project requires that your soundcard and drivers provide full duplex mode capabilities. Visual C++ 6.0 project files are provided in each project directory as well should you wish to compile your own binaries. It is important to link with the non-debug libraries when compiling "release" program versions and debug libraries when compiling "debug" program versions.</LI>
|
||||
<LI><B>Windows95/98/2000/XP:</B> Realtime support is available using either DirectSound or ASIO audio drivers. For DirectSound support, use the <TT>__WINDOWS_DS__</TT> preprocessor definition and link with the <TT>dsound.lib</TT>, <TT>winmm.lib</TT>, and <TT>Wsock32.lib</TT> libraries. For ASIO support, use the <TT>__WINDOWS_ASIO__</TT> preprocessor definition, include all the files in the <TT>src/asio/</TT> directory (i.e. <TT>asio.h,cpp</TT>, <TT>asiodrivers.h,cpp</TT>, ...), and link with the <TT>winmm.lib</TT>, and <TT>Wsock32.lib</TT> libraries. In addition, the <TT>__LITTLE_ENDIAN__</TT> and <TT>__WINDOWS_MM__</TT> preprocessor definitions are necessary for all Windows systems (RtMidi uses the Windows MultiMedia MIDI API). A distribution of the release is available with precompiled binaries (using DirectSound) for all the projects. In order for these binaries to function properly, your system must have the DirectX 5.0 (or higher) runtime libraries installed (available from <A HREF="http://www.microsoft.com/directx/">Microsoft</A>). Further, the <I><B>effects</B></I> project requires that your soundcard and drivers provide full duplex mode capabilities. Visual C++ 6.0 project files are provided in each project directory as well should you wish to compile your own binaries. It is important to link with the non-debug libraries when compiling "release" program versions and debug libraries when compiling "debug" program versions.</LI>
|
||||
|
||||
<LI><B>WindowsNT:</B> DirectX support for NT is inadequate, so it is not possible to use STK under WindowsNT with realtime DirectX support. It may be possible to use STK under WindowsNT with realtime ASIO support, though this has not been tested.</LI>
|
||||
|
||||
@@ -53,11 +53,12 @@ Several options can be supplied to the <TT>configure</TT> script to customize th
|
||||
<UL>
|
||||
<LI><TT>--disable-realtime</TT> to only compile generic non-realtime classes</LI>
|
||||
<LI><TT>--enable-debug</TT> to enable various debug output</LI>
|
||||
<LI><TT>--enable-midiator</TT> to enable native MS-124W MIDI support (linux only)</LI>
|
||||
<LI><TT>--with-alsa</TT> to choose native ALSA API support (linux only)</LI>
|
||||
<LI><TT>--with-alsa</TT> to choose native ALSA API support (default, linux only)</LI>
|
||||
<LI><TT>--with-jack</TT> to choose native JACK API support (linux only)</LI>
|
||||
<LI><TT>--with-oss</TT> to choose native OSS audio API support (linux only, no native OSS MIDI support)</LI>
|
||||
</UL>
|
||||
<P>
|
||||
In addition, it is possible to specify the location of the STK rawwaves and the STK include path as follows:
|
||||
Note that it is possible to specify as many of the "--with-" options as desired to compile multi-API support. In addition, it is possible to specify the location of the STK rawwaves and the STK include path as follows:
|
||||
\code
|
||||
./configure RAWWAVE_PATH="/home/gary/rawwaves/"
|
||||
./configure INCLUDE_PATH="/home/gary/include/"
|
||||
@@ -68,13 +69,13 @@ For novice STK users, the default configuration should be adequate.
|
||||
|
||||
For those who wish to create their own system-specific <TT>Makefiles</TT>:
|
||||
<UL>
|
||||
<LI><B>Linux:</B> Realtime support is enabled with either the <TT>__LINUX_OSS__</TT> or <TT>__LINUX_ALSA__</TT> preprocessor definitions, which are used to select the underlying audio/MIDI system API. Realtime programs must also link with the <TT>pthread</TT> library. When using the ALSA API, it is also necessary to link with the <TT>asound</TT> library. In addition, the <TT>__LITTLE_ENDIAN__</TT> preprocessor definition is necessary if compiling on a little-endian system. Special support exists under Linux for the MIDIator serial MIDI device, enabled using the <TT>__MIDIATOR__</TT> preprocessor definition (together with either the <TT>__LINUX_ALSA__</TT> or <TT>__LINUX_OSS__</TT> definitions). See the README-Linux file for further system configuration information.</LI>
|
||||
<LI><B>Linux:</B> Realtime audio support is enabled with either the <TT>__LINUX_ALSA__</TT>, <TT>__LINUX_JACK__</TT>, and/or <TT>__LINUX_OSS__</TT> preprocessor definitions, which are used to select the underlying audio system API(s). 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 <TT>__LINUX_ALSASEQ__</TT> preprocessor definition must be included for MIDI support. Note that native OSS MIDI support no longer exists in RtMidi. If the <TT>__LINUX_OSS__</TT> preprocessor definition is specified, only OSS audio support will be compiled and RtMidi will still be compiled using the ALSA API (assuming the <TT>__LINUX_ALSASEQ__</TT> definition is defined). For this reason, STK now requires the <TT>asound</TT> library for realtime support. Realtime programs must also link with the <TT>pthread</TT> library. In addition, the <TT>__LITTLE_ENDIAN__</TT> preprocessor definition is necessary if compiling on a little-endian system. See the README-Linux file for further system configuration information.</LI>
|
||||
|
||||
<LI><B>Macintosh OS X:</B> Realtime support is enabled with the <TT>__MACOSX_CORE__</TT> preprocessor definitions, which incorporates the CoreAudio audio/MIDI API. Realtime programs must also link with the <TT>pthread</TT> library and the <TT>CoreAudio</TT>, <TT>CoreMIDI</TT>, and <TT>CoreFoundation</TT> frameworks. See the README-MacOSX file for further system configuration information.</LI>
|
||||
|
||||
<LI><B>SGI:</B> Realtime support is enabled with the <TT>__IRIX_AL__</TT> preprocessor definition and linkage with the <TT>audio</TT>, <TT>md</TT>, and <TT>pthread</TT> libraries. STK 4.0 (and higher) is confirmed to compile using CC version 7.30. There may be problems with old compiler versions.</LI>
|
||||
<LI><B>SGI:</B> Realtime audio and MIDI support is enabled with the <TT>__IRIX_AL__</TT> and <TT>__IRIX_MD__</TT> preprocessor definitions and linkage with the <TT>audio</TT>, <TT>md</TT>, and <TT>pthread</TT> libraries. STK 4.0 (and higher) is confirmed to compile using CC version 7.30. There may be problems with old compiler versions.</LI>
|
||||
|
||||
<LI><B>Generic (non-realtime):</B> Most STK classes are operating system <I>independent</I> and can be compiled using any current C++ compiler. STK assumes big-endian host byte order by default, so if your system is little-endian (i.e. Intel processor), you must provide the <TT>__LITTLE_ENDIAN__</TT> preprocessor definition to your compiler. The <I><B>demo</B></I> project will compile without realtime support, allowing the use of SKINI scorefiles for input control and output to a variety of soundfile formats. The following classes <I>cannot</I> be used without realtime support: RtAudio, RtWvIn, RtWvOut, RtDuplex, RtMidi, Socket, Thread, TcpWvIn, TcpWvOut. Because of this, it is not possible to compile the <I><B>effects</B></I>, <I><B>ragamatic</B></I>, and most of the <I><B>examples</B></I> projects for non-realtime use.</LI>
|
||||
<LI><B>Generic (non-realtime):</B> Most STK classes are operating system <I>independent</I> and can be compiled using any current C++ compiler. STK assumes big-endian host byte order by default, so if your system is little-endian (i.e. Intel processor), you must provide the <TT>__LITTLE_ENDIAN__</TT> preprocessor definition to your compiler. The <I><B>demo</B></I> project will compile without realtime support, allowing the use of SKINI scorefiles for input control and output to a variety of soundfile formats. The following classes <I>cannot</I> be used without realtime support: RtAudio, RtWvIn, RtWvOut, RtDuplex, RtMidi, Socket, Thread, Mutex, TcpWvIn, TcpWvOut. Because of this, it is not possible to compile the <I><B>effects</B></I>, <I><B>ragamatic</B></I>, and most of the <I><B>examples</B></I> projects for non-realtime use.</LI>
|
||||
</UL>
|
||||
|
||||
|
||||
@@ -132,16 +133,10 @@ See the information above with respect to compiling STK for non-realtime use.
|
||||
In non-realtime mode, it is assumed that input control messages are provided from a SKINI scorefile and that audio output is written to a soundfile (.snd, .wav, .aif, .mat, .raw). A number of SKINI scorefiles are provided in the <I>scores</I> directory of the <I><B>demo</B></I> project. Assuming a successful compilation of the <I><B>demo</B></I> program, typing:
|
||||
|
||||
\code
|
||||
cat scores/bookert.ski | demo BeeThree -ow myfile.wav
|
||||
demo BeeThree -ow myfile.wav -if scores/bookert.ski
|
||||
\endcode
|
||||
|
||||
or (on WindowsXX and/or Unix)
|
||||
|
||||
\code
|
||||
demo BeeThree -ow myfile.wav < scores\bookert.ski
|
||||
\endcode
|
||||
|
||||
from the <I><B>demo</B></I> directory will play the scorefile <I>bookert.ski</I> using the STK BeeThree instrument and write the resulting audio data to a WAV formatted soundfile called "myfile.wav". Typing <TT>demo</TT> without any arguments will provide a full program usage description.
|
||||
from the <I><B>demo</B></I> directory will play the scorefile <I>bookert.ski</I> using the STK BeeThree instrument and write the resulting audio data to a WAV formatted soundfile called "myfile.wav" (note that you may need to append <TT>./</TT> to the program name if your default shell setup is not set to look in the current directory). Typing <TT>demo</TT> without any arguments will provide a full program usage description.
|
||||
|
||||
|
||||
\section rt Demo: Realtime Use
|
||||
@@ -157,27 +152,22 @@ demo instrument flags
|
||||
where instruments include those described above and flags can be any or all of:
|
||||
<UL>
|
||||
<LI><I>-or</I> for realtime audio output,</LI>
|
||||
<LI><I>-ow <file name></I> for WAV soundfile output,</LI>
|
||||
<LI><I>-os <file name></I> for SND (AU) soundfile output,</LI>
|
||||
<LI><I>-om <file name></I> for MAT-file output,</LI>
|
||||
<LI><I>-ow \<file name\></I> for WAV soundfile output,</LI>
|
||||
<LI><I>-os \<file name\></I> for SND (AU) soundfile output,</LI>
|
||||
<LI><I>-om \<file name\></I> for MAT-file output,</LI>
|
||||
<LI><I>-if \<file name\></I> for a SKINI formatted control file,</LI>
|
||||
<LI><I>-ip</I> for realtime SKINI control input via piping,</LI>
|
||||
<LI><I>-is <port></I> > for realtime SKINI control input via socketing (with an optional port number),</LI>
|
||||
<LI><I>-im <file name></I> for MIDI control input</LI>
|
||||
<LI><I>-s RATE</I> to specify a sample rate</LI>
|
||||
<LI><I>-is \<port\></I> for realtime SKINI control input via socketing (with an optional port number),</LI>
|
||||
<LI><I>-im \<port\></I> for MIDI control input (with optional port, -1 = virtual port where possible),</LI>
|
||||
<LI><I>-s RATE</I> to specify a sample rate,</LI>
|
||||
<LI><I>-n NUMBER</I> to specify multivoice polyphony</LI>
|
||||
</UL>
|
||||
The <-ip> and <-is> flags must be used when piping or socketing realtime SKINI control data to an STK program. The <-im> flag must be used to read MIDI control input from your MIDI port. Note that you can use all three input types simultaneously.
|
||||
The <i>-ip</i> and <i>-is</i> flags must be used when piping or socketing realtime SKINI control data to an STK program. The <i>-im</i> flag must be used to read MIDI control input from your MIDI port. Note that you can use all three input types simultaneously.
|
||||
|
||||
Assuming a successful compilation of the <I><B>demo</B></I> program, typing:
|
||||
|
||||
\code
|
||||
cat scores/bookert.ski | demo BeeThree -or
|
||||
\endcode
|
||||
|
||||
or (on WindowsXX and/or Unix)
|
||||
|
||||
\code
|
||||
demo BeeThree -or < scores\bookert.ski
|
||||
demo BeeThree -or -if scores/bookert.ski
|
||||
\endcode
|
||||
|
||||
from the <I><B>demo</B></I> directory will play the scorefile <I>bookert.ski</I> using the STK BeeThree instrument and stream the resulting audio data in realtime to the audio output channel of your computer. Typing <TT>demo</TT> without any arguments will provide a full program usage description.
|
||||
@@ -209,6 +199,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 <TT>-im</TT> 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.
|
||||
|
||||
\section polyphony Polyphony:
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
envelope value reaches 0.0 in the
|
||||
ADSR::RELEASE state.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ADSR_H)
|
||||
#define __ADSR_H
|
||||
#ifndef STK_ADSR_H
|
||||
#define STK_ADSR_H
|
||||
|
||||
#include "Envelope.h"
|
||||
|
||||
@@ -40,49 +40,58 @@ class ADSR : public Envelope
|
||||
void keyOff(void);
|
||||
|
||||
//! Set the attack rate.
|
||||
void setAttackRate(MY_FLOAT aRate);
|
||||
void setAttackRate(StkFloat rate);
|
||||
|
||||
//! Set the decay rate.
|
||||
void setDecayRate(MY_FLOAT aRate);
|
||||
void setDecayRate(StkFloat rate);
|
||||
|
||||
//! Set the sustain level.
|
||||
void setSustainLevel(MY_FLOAT aLevel);
|
||||
void setSustainLevel(StkFloat level);
|
||||
|
||||
//! Set the release rate.
|
||||
void setReleaseRate(MY_FLOAT aRate);
|
||||
void setReleaseRate(StkFloat rate);
|
||||
|
||||
//! Set the attack rate based on a time duration.
|
||||
void setAttackTime(MY_FLOAT aTime);
|
||||
void setAttackTime(StkFloat time);
|
||||
|
||||
//! Set the decay rate based on a time duration.
|
||||
void setDecayTime(MY_FLOAT aTime);
|
||||
void setDecayTime(StkFloat time);
|
||||
|
||||
//! Set the release rate based on a time duration.
|
||||
void setReleaseTime(MY_FLOAT aTime);
|
||||
void setReleaseTime(StkFloat time);
|
||||
|
||||
//! Set sustain level and attack, decay, and release state rates based on time durations.
|
||||
void setAllTimes(MY_FLOAT aTime, MY_FLOAT dTime, MY_FLOAT sLevel, MY_FLOAT rTime);
|
||||
//! Set sustain level and attach, decay, and release time durations.
|
||||
void setAllTimes(StkFloat aTime, StkFloat dTime, StkFloat sLevel, StkFloat rTime);
|
||||
|
||||
//! Set the target value.
|
||||
void setTarget(MY_FLOAT aTarget);
|
||||
void setTarget(StkFloat target);
|
||||
|
||||
//! Return the current envelope \e state (ATTACK, DECAY, SUSTAIN, RELEASE, DONE).
|
||||
int getState(void) const;
|
||||
|
||||
//! Set to state = ADSR::SUSTAIN with current and target values of \e aValue.
|
||||
void setValue(MY_FLOAT aValue);
|
||||
void setValue(StkFloat value);
|
||||
|
||||
//! Return one envelope output value.
|
||||
MY_FLOAT tick(void);
|
||||
StkFloat tick(void);
|
||||
|
||||
//! Return \e vectorSize envelope outputs in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
//! Compute \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
MY_FLOAT attackRate;
|
||||
MY_FLOAT decayRate;
|
||||
MY_FLOAT sustainLevel;
|
||||
MY_FLOAT releaseRate;
|
||||
StkFloat attackRate_;
|
||||
StkFloat decayRate_;
|
||||
StkFloat sustainLevel_;
|
||||
StkFloat releaseRate_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
84
include/Asymp.h
Normal file
84
include/Asymp.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************/
|
||||
/*! \class Asymp
|
||||
\brief STK asymptotic curve envelope class
|
||||
|
||||
This class implements a simple envelope generator
|
||||
which asymptotically approaches a target value.
|
||||
The algorithm used is of the form:
|
||||
|
||||
x[n] = a x[n-1] + (1-a) target,
|
||||
|
||||
where a = exp(-T/tau), T is the sample period, and
|
||||
tau is a time constant. The user can set the time
|
||||
constant (default value = 0.3) and target value.
|
||||
Theoretically, this recursion never reaches its
|
||||
target, though the calculations in this class are
|
||||
stopped when the current value gets within a small
|
||||
threshold value of the target (at which time the
|
||||
current value is set to the target). It responds
|
||||
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 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#ifndef STK_ASYMP_H
|
||||
#define STK_ASYMP_H
|
||||
|
||||
#include "Envelope.h"
|
||||
|
||||
const StkFloat TARGET_THRESHOLD = 0.000001;
|
||||
|
||||
class Asymp : public Envelope
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Asymp(void);
|
||||
|
||||
//! Class destructor.
|
||||
~Asymp(void);
|
||||
|
||||
//! Set target = 1.
|
||||
void keyOn(void);
|
||||
|
||||
//! Set target = 0.
|
||||
void keyOff(void);
|
||||
|
||||
//! Set the asymptotic rate via the time factor \e tau (must be > 0).
|
||||
/*!
|
||||
The rate is computed as described above. The value of \e tau
|
||||
must be greater than zero. Values of \e tau close to zero produce
|
||||
fast approach rates, while values greater than 1.0 produce rather
|
||||
slow rates.
|
||||
*/
|
||||
void setTau(StkFloat tau);
|
||||
|
||||
//! Set the asymptotic rate based on a time duration (must be > 0).
|
||||
void setTime(StkFloat time);
|
||||
|
||||
//! Set the target value.
|
||||
void setTarget(StkFloat target);
|
||||
|
||||
//! Return one envelope output value.
|
||||
StkFloat tick(void);
|
||||
|
||||
//! Compute \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
StkFloat factor_;
|
||||
StkFloat constant_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -24,19 +24,19 @@
|
||||
- Glass Harmonica = 2
|
||||
- Tibetan Bowl = 3
|
||||
|
||||
by Georg Essl, 1999 - 2002.
|
||||
by Georg Essl, 1999 - 2004.
|
||||
Modified for Stk 4.0 by Gary Scavone.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BANDEDWG_H)
|
||||
#define __BANDEDWG_H
|
||||
#ifndef STK_BANDEDWG_H
|
||||
#define STK_BANDEDWG_H
|
||||
|
||||
#define MAX_BANDED_MODES 20
|
||||
const int MAX_BANDED_MODES = 20;
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
#include "BowTabl.h"
|
||||
#include "BowTable.h"
|
||||
#include "ADSR.h"
|
||||
#include "BiQuad.h"
|
||||
|
||||
@@ -53,59 +53,71 @@ class BandedWG : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set strike position (0.0 - 1.0).
|
||||
void setStrikePosition(MY_FLOAT position);
|
||||
void setStrikePosition(StkFloat position);
|
||||
|
||||
//! Select a preset.
|
||||
void setPreset(int preset);
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Apply bow velocity/pressure to instrument with given amplitude and rate of increase.
|
||||
void startBowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
void startBowing(StkFloat amplitude, StkFloat rate);
|
||||
|
||||
//! Decrease bow velocity/breath pressure with given rate of decrease.
|
||||
void stopBowing(MY_FLOAT rate);
|
||||
void stopBowing(StkFloat rate);
|
||||
|
||||
//! Pluck the instrument with given amplitude.
|
||||
void pluck(MY_FLOAT amp);
|
||||
void pluck(StkFloat amp);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
|
||||
bool doPluck;
|
||||
bool trackVelocity;
|
||||
int nModes;
|
||||
int presetModes;
|
||||
BowTabl *bowTabl;
|
||||
ADSR *adsr;
|
||||
BiQuad *bandpass;
|
||||
DelayL *delay;
|
||||
MY_FLOAT maxVelocity;
|
||||
MY_FLOAT modes[MAX_BANDED_MODES];
|
||||
MY_FLOAT freakency;
|
||||
MY_FLOAT baseGain;
|
||||
MY_FLOAT gains[MAX_BANDED_MODES];
|
||||
MY_FLOAT basegains[MAX_BANDED_MODES];
|
||||
MY_FLOAT excitation[MAX_BANDED_MODES];
|
||||
MY_FLOAT integrationConstant;
|
||||
MY_FLOAT velocityInput;
|
||||
MY_FLOAT bowVelocity;
|
||||
MY_FLOAT bowTarget;
|
||||
MY_FLOAT bowPosition;
|
||||
MY_FLOAT strikeAmp;
|
||||
int strikePosition;
|
||||
bool doPluck_;
|
||||
bool trackVelocity_;
|
||||
int nModes_;
|
||||
int presetModes_;
|
||||
BowTable bowTable_;
|
||||
ADSR adsr_;
|
||||
BiQuad bandpass_[MAX_BANDED_MODES];
|
||||
DelayL delay_[MAX_BANDED_MODES];
|
||||
StkFloat maxVelocity_;
|
||||
StkFloat modes_[MAX_BANDED_MODES];
|
||||
StkFloat frequency_;
|
||||
StkFloat baseGain_;
|
||||
StkFloat gains_[MAX_BANDED_MODES];
|
||||
StkFloat basegains_[MAX_BANDED_MODES];
|
||||
StkFloat excitation_[MAX_BANDED_MODES];
|
||||
StkFloat integrationConstant_;
|
||||
StkFloat velocityInput_;
|
||||
StkFloat bowVelocity_;
|
||||
StkFloat bowTarget_;
|
||||
StkFloat bowPosition_;
|
||||
StkFloat strikeAmp_;
|
||||
int strikePosition_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BEETHREE_H)
|
||||
#define __BEETHREE_H
|
||||
#ifndef STK_BEETHREE_H
|
||||
#define STK_BEETHREE_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
@@ -41,16 +41,31 @@ class BeeThree : public FM
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
BeeThree();
|
||||
|
||||
//! Class destructor.
|
||||
~BeeThree();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
frequency response while maintaining a constant
|
||||
filter gain.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BIQUAD_H)
|
||||
#define __BIQUAD_H
|
||||
#ifndef STK_BIQUAD_H
|
||||
#define STK_BIQUAD_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
@@ -31,19 +31,19 @@ public:
|
||||
void clear(void);
|
||||
|
||||
//! Set the b[0] coefficient value.
|
||||
void setB0(MY_FLOAT b0);
|
||||
void setB0(StkFloat b0);
|
||||
|
||||
//! Set the b[1] coefficient value.
|
||||
void setB1(MY_FLOAT b1);
|
||||
void setB1(StkFloat b1);
|
||||
|
||||
//! Set the b[2] coefficient value.
|
||||
void setB2(MY_FLOAT b2);
|
||||
void setB2(StkFloat b2);
|
||||
|
||||
//! Set the a[1] coefficient value.
|
||||
void setA1(MY_FLOAT a1);
|
||||
void setA1(StkFloat a1);
|
||||
|
||||
//! Set the a[2] coefficient value.
|
||||
void setA2(MY_FLOAT a2);
|
||||
void setA2(StkFloat a2);
|
||||
|
||||
//! Sets the filter coefficients for a resonance at \e frequency (in Hz).
|
||||
/*!
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
frequency. The closer the poles are to the unit-circle (\e radius
|
||||
close to one), the narrower the resulting resonance width.
|
||||
*/
|
||||
void setResonance(MY_FLOAT frequency, MY_FLOAT radius, bool normalize = FALSE);
|
||||
void setResonance(StkFloat frequency, StkFloat radius, bool normalize = false);
|
||||
|
||||
//! Set the filter coefficients for a notch at \e frequency (in Hz).
|
||||
/*!
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
and \e radius from the z-plane origin. No filter normalization
|
||||
is attempted.
|
||||
*/
|
||||
void setNotch(MY_FLOAT frequency, MY_FLOAT radius);
|
||||
void setNotch(StkFloat frequency, StkFloat radius);
|
||||
|
||||
//! Sets the filter zeroes for equal resonance gain.
|
||||
/*!
|
||||
@@ -82,19 +82,28 @@ public:
|
||||
The gain is applied at the filter input and does not affect the
|
||||
coefficient values. The default gain value is 1.0.
|
||||
*/
|
||||
void setGain(MY_FLOAT theGain);
|
||||
void setGain(StkFloat gain);
|
||||
|
||||
//! Return the current filter gain.
|
||||
MY_FLOAT getGain(void) const;
|
||||
StkFloat getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
StkFloat lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
virtual StkFloat tick(StkFloat sample);
|
||||
|
||||
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
- Vibrato Gain = 1
|
||||
- Volume = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BOTTLE_H)
|
||||
#define __BOTTLE_H
|
||||
#ifndef STK_BLOWBOTL_H
|
||||
#define STK_BLOWBOTL_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "JetTabl.h"
|
||||
#include "JetTable.h"
|
||||
#include "BiQuad.h"
|
||||
#include "PoleZero.h"
|
||||
#include "Noise.h"
|
||||
@@ -31,6 +31,9 @@ class BlowBotl : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
BlowBotl();
|
||||
|
||||
//! Class destructor.
|
||||
@@ -40,37 +43,49 @@ class BlowBotl : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Apply breath velocity to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
void startBlowing(StkFloat amplitude, StkFloat rate);
|
||||
|
||||
//! Decrease breath velocity with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
void stopBlowing(StkFloat rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
JetTabl *jetTable;
|
||||
BiQuad *resonator;
|
||||
PoleZero *dcBlock;
|
||||
Noise *noise;
|
||||
ADSR *adsr;
|
||||
WaveLoop *vibrato;
|
||||
MY_FLOAT maxPressure;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT outputGain;
|
||||
JetTable jetTable_;
|
||||
BiQuad resonator_;
|
||||
PoleZero dcBlock_;
|
||||
Noise noise_;
|
||||
ADSR adsr_;
|
||||
WaveLoop *vibrato_;
|
||||
StkFloat maxPressure_;
|
||||
StkFloat noiseGain_;
|
||||
StkFloat vibratoGain_;
|
||||
StkFloat outputGain_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -29,16 +29,16 @@
|
||||
- Register State = 1
|
||||
- Breath Pressure = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BLOWHOLE_H)
|
||||
#define __BLOWHOLE_H
|
||||
#ifndef STK_BLOWHOLE_H
|
||||
#define STK_BLOWHOLE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
#include "ReedTabl.h"
|
||||
#include "ReedTable.h"
|
||||
#include "OneZero.h"
|
||||
#include "PoleZero.h"
|
||||
#include "Envelope.h"
|
||||
@@ -49,7 +49,10 @@ class BlowHole : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
BlowHole(MY_FLOAT lowestFrequency);
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
BlowHole(StkFloat lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~BlowHole();
|
||||
@@ -58,50 +61,60 @@ class BlowHole : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Set the tonehole state (0.0 = closed, 1.0 = fully open).
|
||||
void setTonehole(MY_FLOAT newValue);
|
||||
void setTonehole(StkFloat newValue);
|
||||
|
||||
//! Set the register hole state (0.0 = closed, 1.0 = fully open).
|
||||
void setVent(MY_FLOAT newValue);
|
||||
void setVent(StkFloat newValue);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
void startBlowing(StkFloat amplitude, StkFloat rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
void stopBlowing(StkFloat rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
DelayL *delays[3];
|
||||
ReedTabl *reedTable;
|
||||
OneZero *filter;
|
||||
PoleZero *tonehole;
|
||||
PoleZero *vent;
|
||||
Envelope *envelope;
|
||||
Noise *noise;
|
||||
WaveLoop *vibrato;
|
||||
long length;
|
||||
MY_FLOAT scatter;
|
||||
MY_FLOAT th_coeff;
|
||||
MY_FLOAT r_th;
|
||||
MY_FLOAT rh_coeff;
|
||||
MY_FLOAT rh_gain;
|
||||
MY_FLOAT outputGain;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT vibratoGain;
|
||||
DelayL delays_[3];
|
||||
ReedTable reedTable_;
|
||||
OneZero filter_;
|
||||
PoleZero tonehole_;
|
||||
PoleZero vent_;
|
||||
Envelope envelope_;
|
||||
Noise noise_;
|
||||
WaveLoop *vibrato_;
|
||||
unsigned long length_;
|
||||
StkFloat scatter_;
|
||||
StkFloat thCoeff_;
|
||||
StkFloat rhGain_;
|
||||
StkFloat outputGain_;
|
||||
StkFloat noiseGain_;
|
||||
StkFloat vibratoGain_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/***************************************************/
|
||||
/*! \class BowTabl
|
||||
\brief STK bowed string table class.
|
||||
|
||||
This class implements a simple bowed string
|
||||
non-linear function, as described by Smith (1986).
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BOWTABL_H)
|
||||
#define __BOWTABL_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class BowTabl : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
BowTabl();
|
||||
|
||||
//! Class destructor.
|
||||
~BowTabl();
|
||||
|
||||
//! Set the table offset value.
|
||||
/*!
|
||||
The table offset is a bias which controls the
|
||||
symmetry of the friction. If you want the
|
||||
friction to vary with direction, use a non-zero
|
||||
value for the offset. The default value is zero.
|
||||
*/
|
||||
void setOffset(MY_FLOAT aValue);
|
||||
|
||||
//! Set the table slope value.
|
||||
/*!
|
||||
The table slope controls the width of the friction
|
||||
pulse, which is related to bow force.
|
||||
*/
|
||||
void setSlope(MY_FLOAT aValue);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
|
||||
//! Return the function value for \e input.
|
||||
/*!
|
||||
The function input represents differential
|
||||
string-to-bow velocity.
|
||||
*/
|
||||
MY_FLOAT tick(const MY_FLOAT input);
|
||||
|
||||
//! Take \e vectorSize inputs and return the corresponding function values in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
protected:
|
||||
MY_FLOAT offSet;
|
||||
MY_FLOAT slope;
|
||||
MY_FLOAT lastOutput;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
67
include/BowTable.h
Normal file
67
include/BowTable.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************/
|
||||
/*! \class BowTable
|
||||
\brief STK bowed string table class.
|
||||
|
||||
This class implements a simple bowed string
|
||||
non-linear function, as described by Smith (1986).
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#ifndef STK_BOWTABL_H
|
||||
#define STK_BOWTABL_H
|
||||
|
||||
#include "Function.h"
|
||||
|
||||
class BowTable : public Function
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
BowTable();
|
||||
|
||||
//! Class destructor.
|
||||
~BowTable();
|
||||
|
||||
//! Set the table offset value.
|
||||
/*!
|
||||
The table offset is a bias which controls the
|
||||
symmetry of the friction. If you want the
|
||||
friction to vary with direction, use a non-zero
|
||||
value for the offset. The default value is zero.
|
||||
*/
|
||||
void setOffset(StkFloat offset);
|
||||
|
||||
//! Set the table slope value.
|
||||
/*!
|
||||
The table slope controls the width of the friction
|
||||
pulse, which is related to bow force.
|
||||
*/
|
||||
void setSlope(StkFloat slope);
|
||||
|
||||
//! Return the function value for \e input.
|
||||
/*!
|
||||
The function input represents differential
|
||||
string-to-bow velocity.
|
||||
*/
|
||||
StkFloat tick( StkFloat input);
|
||||
|
||||
//! Take \e vectorSize inputs from \e vector and replace them with corresponding outputs.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
StkFloat offset_;
|
||||
StkFloat slope_;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -17,16 +17,16 @@
|
||||
- Vibrato Gain = 1
|
||||
- Volume = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BOWED_H)
|
||||
#define __BOWED_H
|
||||
#ifndef STK_BOWED_H
|
||||
#define STK_BOWED_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
#include "BowTabl.h"
|
||||
#include "BowTable.h"
|
||||
#include "OnePole.h"
|
||||
#include "BiQuad.h"
|
||||
#include "WaveLoop.h"
|
||||
@@ -36,7 +36,7 @@ class Bowed : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Bowed(MY_FLOAT lowestFrequency);
|
||||
Bowed(StkFloat lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Bowed();
|
||||
@@ -45,41 +45,53 @@ class Bowed : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Set vibrato gain.
|
||||
void setVibrato(MY_FLOAT gain);
|
||||
void setVibrato(StkFloat gain);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
void startBowing(StkFloat amplitude, StkFloat rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBowing(MY_FLOAT rate);
|
||||
void stopBowing(StkFloat rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
DelayL *neckDelay;
|
||||
DelayL *bridgeDelay;
|
||||
BowTabl *bowTable;
|
||||
OnePole *stringFilter;
|
||||
BiQuad *bodyFilter;
|
||||
WaveLoop *vibrato;
|
||||
ADSR *adsr;
|
||||
MY_FLOAT maxVelocity;
|
||||
MY_FLOAT baseDelay;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT betaRatio;
|
||||
DelayL neckDelay_;
|
||||
DelayL bridgeDelay_;
|
||||
BowTable bowTable_;
|
||||
OnePole stringFilter_;
|
||||
BiQuad bodyFilter_;
|
||||
WaveLoop *vibrato_;
|
||||
ADSR adsr_;
|
||||
StkFloat maxVelocity_;
|
||||
StkFloat baseDelay_;
|
||||
StkFloat vibratoGain_;
|
||||
StkFloat betaRatio_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
- Vibrato Gain = 1
|
||||
- Volume = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__BRASS_H)
|
||||
#define __BRASS_H
|
||||
#ifndef STK_BRASS_H
|
||||
#define STK_BRASS_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayA.h"
|
||||
@@ -34,7 +34,10 @@ class Brass: public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Brass(MY_FLOAT lowestFrequency);
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Brass(StkFloat lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Brass();
|
||||
@@ -43,40 +46,52 @@ class Brass: public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Set the lips frequency.
|
||||
void setLip(MY_FLOAT frequency);
|
||||
void setLip(StkFloat frequency);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
|
||||
void startBlowing(StkFloat amplitude, StkFloat rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
void stopBlowing(StkFloat rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
DelayA *delayLine;
|
||||
BiQuad *lipFilter;
|
||||
PoleZero *dcBlock;
|
||||
ADSR *adsr;
|
||||
WaveLoop *vibrato;
|
||||
long length;
|
||||
MY_FLOAT lipTarget;
|
||||
MY_FLOAT slideTarget;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT maxPressure;
|
||||
DelayA delayLine_;
|
||||
BiQuad lipFilter_;
|
||||
PoleZero dcBlock_;
|
||||
ADSR adsr_;
|
||||
WaveLoop *vibrato_;
|
||||
unsigned long length_;
|
||||
StkFloat lipTarget_;
|
||||
StkFloat slideTarget_;
|
||||
StkFloat vibratoGain_;
|
||||
StkFloat maxPressure_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -4,22 +4,25 @@
|
||||
|
||||
This class implements a chorus effect.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__CHORUS_H)
|
||||
#define __CHORUS_H
|
||||
#ifndef STK_CHORUS_H
|
||||
#define STK_CHORUS_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "Effect.h"
|
||||
#include "DelayL.h"
|
||||
#include "WaveLoop.h"
|
||||
|
||||
class Chorus : public Stk
|
||||
class Chorus : public Effect
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the longest desired delay length.
|
||||
Chorus(MY_FLOAT baseDelay);
|
||||
//! Class constructor, taking the median desired delay length.
|
||||
/*!
|
||||
An StkError can be thrown if the rawwave path is incorrect.
|
||||
*/
|
||||
Chorus( StkFloat baseDelay = 6000 );
|
||||
|
||||
//! Class destructor.
|
||||
~Chorus();
|
||||
@@ -28,36 +31,31 @@ class Chorus : public Stk
|
||||
void clear();
|
||||
|
||||
//! Set modulation depth.
|
||||
void setModDepth(MY_FLOAT depth);
|
||||
void setModDepth(StkFloat depth);
|
||||
|
||||
//! Set modulation frequency.
|
||||
void setModFrequency(MY_FLOAT frequency);
|
||||
|
||||
//! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only).
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
|
||||
//! Return the last left output value.
|
||||
MY_FLOAT lastOutLeft() const;
|
||||
|
||||
//! Return the last right output value.
|
||||
MY_FLOAT lastOutRight() const;
|
||||
void setModFrequency(StkFloat frequency);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
StkFloat tick(StkFloat input);
|
||||
|
||||
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
DelayL *delayLine[2];
|
||||
WaveLoop *mods[2];
|
||||
MY_FLOAT baseLength;
|
||||
MY_FLOAT modDepth;
|
||||
MY_FLOAT lastOutput[2];
|
||||
MY_FLOAT effectMix;
|
||||
DelayL delayLine_[2];
|
||||
WaveLoop *mods_[2];
|
||||
StkFloat baseLength_;
|
||||
StkFloat modDepth_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -18,16 +18,16 @@
|
||||
- Vibrato Gain = 1
|
||||
- Breath Pressure = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__CLARINET_H)
|
||||
#define __CLARINET_H
|
||||
#ifndef STK_CLARINET_H
|
||||
#define STK_CLARINET_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
#include "ReedTabl.h"
|
||||
#include "ReedTable.h"
|
||||
#include "OneZero.h"
|
||||
#include "Envelope.h"
|
||||
#include "Noise.h"
|
||||
@@ -37,7 +37,10 @@ class Clarinet : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Clarinet(MY_FLOAT lowestFrequency);
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Clarinet(StkFloat lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Clarinet();
|
||||
@@ -46,37 +49,49 @@ class Clarinet : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
void startBlowing(StkFloat amplitude, StkFloat rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
void stopBlowing(StkFloat rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
DelayL *delayLine;
|
||||
ReedTabl *reedTable;
|
||||
OneZero *filter;
|
||||
Envelope *envelope;
|
||||
Noise *noise;
|
||||
WaveLoop *vibrato;
|
||||
long length;
|
||||
MY_FLOAT outputGain;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT vibratoGain;
|
||||
DelayL delayLine_;
|
||||
ReedTable reedTable_;
|
||||
OneZero filter_;
|
||||
Envelope envelope_;
|
||||
Noise noise_;
|
||||
WaveLoop *vibrato_;
|
||||
long length_;
|
||||
StkFloat outputGain_;
|
||||
StkFloat noiseGain_;
|
||||
StkFloat vibratoGain_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
used in fixed delay-length applications, such
|
||||
as for reverberation.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__DELAY_H)
|
||||
#define __DELAY_H
|
||||
#ifndef STK_DELAY_H
|
||||
#define STK_DELAY_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
@@ -31,7 +31,12 @@ public:
|
||||
Delay();
|
||||
|
||||
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
|
||||
Delay(long theDelay, long maxDelay);
|
||||
/*!
|
||||
An StkError will be thrown if the delay parameter is less than
|
||||
zero, the maximum delay parameter is less than one, or the delay
|
||||
parameter is greater than the maxDelay value.
|
||||
*/
|
||||
Delay(unsigned long delay, unsigned long maxDelay);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Delay();
|
||||
@@ -39,17 +44,27 @@ public:
|
||||
//! Clears the internal state of the delay line.
|
||||
void clear();
|
||||
|
||||
//! Set the maximum delay-line length.
|
||||
/*!
|
||||
This method should generally only be used during initial setup
|
||||
of the delay line. If it is used between calls to the tick()
|
||||
function, without a call to clear(), a signal discontinuity will
|
||||
likely occur. If the current maximum length is greater than the
|
||||
new length, no change will be made.
|
||||
*/
|
||||
void setMaximumDelay(unsigned long delay);
|
||||
|
||||
//! Set the delay-line length.
|
||||
/*!
|
||||
The valid range for \e theDelay is from 0 to the maximum delay-line length.
|
||||
*/
|
||||
void setDelay(long theDelay);
|
||||
void setDelay(unsigned long delay);
|
||||
|
||||
//! Return the current delay-line length.
|
||||
long getDelay(void) const;
|
||||
unsigned long getDelay(void) const;
|
||||
|
||||
//! Calculate and return the signal energy in the delay-line.
|
||||
MY_FLOAT energy(void) const;
|
||||
StkFloat energy(void) const;
|
||||
|
||||
//! Return the value at \e tapDelay samples from the delay-line input.
|
||||
/*!
|
||||
@@ -57,28 +72,36 @@ public:
|
||||
relative to the last input value (i.e., a tapDelay of zero returns
|
||||
the last input value).
|
||||
*/
|
||||
MY_FLOAT contentsAt(unsigned long tapDelay) const;
|
||||
StkFloat contentsAt(unsigned long tapDelay);
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
StkFloat lastOut(void) const;
|
||||
|
||||
//! Return the value which will be output by the next call to tick().
|
||||
/*!
|
||||
This method is valid only for delay settings greater than zero!
|
||||
*/
|
||||
virtual MY_FLOAT nextOut(void) const;
|
||||
virtual StkFloat nextOut(void);
|
||||
|
||||
//! Input one sample to the delay-line and return one output.
|
||||
virtual MY_FLOAT tick(MY_FLOAT sample);
|
||||
//! Input one sample to the delayline and return one output.
|
||||
virtual StkFloat tick(StkFloat sample);
|
||||
|
||||
//! Input \e vectorSize samples to the delay-line and return an equal number of outputs in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
//! Input \e vectorSize samples to the delayline and return an equal number of outputs in \e vector.
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the delayline and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
long inPoint;
|
||||
long outPoint;
|
||||
long length;
|
||||
MY_FLOAT delay;
|
||||
unsigned long inPoint_;
|
||||
unsigned long outPoint_;
|
||||
StkFloat delay_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
response, the minimum delay possible in this
|
||||
implementation is limited to a value of 0.5.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__DelayA_h)
|
||||
#define __DelayA_h
|
||||
#ifndef STK_DELAYA_H
|
||||
#define STK_DELAYA_H
|
||||
|
||||
#include "Delay.h"
|
||||
|
||||
@@ -35,8 +35,12 @@ public:
|
||||
DelayA();
|
||||
|
||||
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
|
||||
|
||||
DelayA(MY_FLOAT theDelay, long maxDelay);
|
||||
/*!
|
||||
An StkError will be thrown if the delay parameter is less than
|
||||
zero, the maximum delay parameter is less than one, or the delay
|
||||
parameter is greater than the maxDelay value.
|
||||
*/
|
||||
DelayA(StkFloat delay, unsigned long maxDelay);
|
||||
|
||||
//! Class destructor.
|
||||
~DelayA();
|
||||
@@ -48,26 +52,38 @@ public:
|
||||
/*!
|
||||
The valid range for \e theDelay is from 0.5 to the maximum delay-line length.
|
||||
*/
|
||||
void setDelay(MY_FLOAT theDelay);
|
||||
void setDelay(StkFloat delay);
|
||||
|
||||
//! Return the current delay-line length.
|
||||
MY_FLOAT getDelay(void);
|
||||
StkFloat getDelay(void);
|
||||
|
||||
//! Return the value which will be output by the next call to tick().
|
||||
/*!
|
||||
This method is valid only for delay settings greater than zero!
|
||||
*/
|
||||
MY_FLOAT nextOut(void);
|
||||
StkFloat nextOut(void);
|
||||
|
||||
//! Input one sample to the delay-line and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
//! Input one sample to the delayline and return one output.
|
||||
StkFloat tick(StkFloat sample);
|
||||
|
||||
//! Input \e vectorSize samples to the delayline and return an equal number of outputs in \e vector.
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the delayline and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
MY_FLOAT alpha;
|
||||
MY_FLOAT coeff;
|
||||
MY_FLOAT apInput;
|
||||
MY_FLOAT nextOutput;
|
||||
bool doNextOut;
|
||||
StkFloat alpha_;
|
||||
StkFloat coeff_;
|
||||
StkFloat apInput_;
|
||||
StkFloat nextOutput_;
|
||||
bool doNextOut_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
order Lagrange interpolators can typically
|
||||
improve (minimize) this attenuation characteristic.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__DELAYL_H)
|
||||
#define __DELAYL_H
|
||||
#ifndef STK_DELAYL_H
|
||||
#define STK_DELAYL_H
|
||||
|
||||
#include "Delay.h"
|
||||
|
||||
@@ -35,8 +35,12 @@ public:
|
||||
DelayL();
|
||||
|
||||
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
|
||||
|
||||
DelayL(MY_FLOAT theDelay, long maxDelay);
|
||||
/*!
|
||||
An StkError will be thrown if the delay parameter is less than
|
||||
zero, the maximum delay parameter is less than one, or the delay
|
||||
parameter is greater than the maxDelay value.
|
||||
*/
|
||||
DelayL(StkFloat delay, unsigned long maxDelay);
|
||||
|
||||
//! Class destructor.
|
||||
~DelayL();
|
||||
@@ -45,25 +49,37 @@ public:
|
||||
/*!
|
||||
The valid range for \e theDelay is from 0 to the maximum delay-line length.
|
||||
*/
|
||||
void setDelay(MY_FLOAT theDelay);
|
||||
void setDelay(StkFloat delay);
|
||||
|
||||
//! Return the current delay-line length.
|
||||
MY_FLOAT getDelay(void) const;
|
||||
StkFloat getDelay(void) const;
|
||||
|
||||
//! Return the value which will be output by the next call to tick().
|
||||
/*!
|
||||
This method is valid only for delay settings greater than zero!
|
||||
*/
|
||||
MY_FLOAT nextOut(void);
|
||||
StkFloat nextOut(void);
|
||||
|
||||
//! Input one sample to the delay-line and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
StkFloat tick(StkFloat sample);
|
||||
|
||||
//! Input \e vectorSize samples to the delay-line and return an equal number of outputs in \e vector.
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the delayline and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
MY_FLOAT alpha;
|
||||
MY_FLOAT omAlpha;
|
||||
MY_FLOAT nextOutput;
|
||||
bool doNextOut;
|
||||
StkFloat alpha_;
|
||||
StkFloat omAlpha_;
|
||||
StkFloat nextOutput_;
|
||||
bool doNextOut_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,24 +11,27 @@
|
||||
of simultaneous voices) via a #define in the
|
||||
Drummer.h.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__DRUMMER_H)
|
||||
#define __DRUMMER_H
|
||||
#ifndef STK_DRUMMER_H
|
||||
#define STK_DRUMMER_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "WvIn.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
#define DRUM_NUMWAVES 11
|
||||
#define DRUM_POLYPHONY 4
|
||||
const int DRUM_NUMWAVES = 11;
|
||||
const int DRUM_POLYPHONY = 4;
|
||||
|
||||
class Drummer : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Drummer();
|
||||
|
||||
//! Class destructor.
|
||||
@@ -37,23 +40,35 @@ class Drummer : public Instrmnt
|
||||
//! Start a note with the given drum type and amplitude.
|
||||
/*!
|
||||
Use general MIDI drum instrument numbers, converted to
|
||||
frequency values as if MIDI note numbers, to select a
|
||||
particular instrument.
|
||||
frequency values as if MIDI note numbers, to select a particular
|
||||
instrument. An StkError will be thrown if the rawwave path is
|
||||
incorrectly set.
|
||||
*/
|
||||
void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat instrument, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
WvIn *waves[DRUM_POLYPHONY];
|
||||
OnePole *filters[DRUM_POLYPHONY];
|
||||
int sounding[DRUM_POLYPHONY];
|
||||
int nSounding;
|
||||
|
||||
WvIn *waves_[DRUM_POLYPHONY];
|
||||
OnePole *filters_[DRUM_POLYPHONY];
|
||||
int sounding_[DRUM_POLYPHONY];
|
||||
int nSounding_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,23 +2,26 @@
|
||||
/*! \class Echo
|
||||
\brief STK echo effect class.
|
||||
|
||||
This class implements a echo effect.
|
||||
This class implements an echo effect.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ECHO_H)
|
||||
#define __ECHO_H
|
||||
#ifndef STK_ECHO_H
|
||||
#define STK_ECHO_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "Effect.h"
|
||||
#include "Delay.h"
|
||||
|
||||
class Echo : public Stk
|
||||
class Echo : public Effect
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the longest desired delay length.
|
||||
Echo(MY_FLOAT longestDelay);
|
||||
//! Class constructor, taking the longest desired delay length (one second default value).
|
||||
/*!
|
||||
The default delay value is set to 1/2 the maximum delay length.
|
||||
*/
|
||||
Echo( unsigned long maximumDelay = (unsigned long) Stk::sampleRate() );
|
||||
|
||||
//! Class destructor.
|
||||
~Echo();
|
||||
@@ -26,26 +29,30 @@ class Echo : public Stk
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set the maximum delay line length in samples.
|
||||
void setMaximumDelay( unsigned long delay );
|
||||
|
||||
//! Set the delay line length in samples.
|
||||
void setDelay(MY_FLOAT delay);
|
||||
|
||||
//! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only).
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
void setDelay( unsigned long delay );
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
StkFloat tick(StkFloat input);
|
||||
|
||||
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
Delay *delayLine;
|
||||
long length;
|
||||
MY_FLOAT lastOutput;
|
||||
MY_FLOAT effectMix;
|
||||
Delay delayLine_;
|
||||
unsigned long length_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
67
include/Effect.h
Normal file
67
include/Effect.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************/
|
||||
/*! \class Effect
|
||||
\brief STK abstract effects parent class.
|
||||
|
||||
This class provides common functionality for
|
||||
STK effects subclasses.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
#ifndef STK_EFFECT_H
|
||||
#define STK_EFFECT_H
|
||||
|
||||
class Effect : public Stk
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Effect();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Effect();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
virtual void clear() = 0;
|
||||
|
||||
//! Set the mixture of input and "effected" levels in the output (0.0 = input only, 1.0 = reverb only).
|
||||
void setEffectMix(StkFloat mix);
|
||||
|
||||
//! Return the last output value.
|
||||
StkFloat lastOut() const;
|
||||
|
||||
//! Return the last left output value.
|
||||
StkFloat lastOutLeft() const;
|
||||
|
||||
//! Return the last right output value.
|
||||
StkFloat lastOutRight() const;
|
||||
|
||||
//! Abstract tick function ... must be implemented in subclasses.
|
||||
virtual StkFloat tick( StkFloat input ) = 0;
|
||||
|
||||
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
|
||||
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
|
||||
// Returns true if argument value is prime.
|
||||
bool isPrime( int number );
|
||||
|
||||
StkFloat lastOutput_[2];
|
||||
StkFloat effectMix_;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
\e keyOff messages, ramping to 1.0 on
|
||||
keyOn and to 0.0 on keyOff.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ENVELOPE_H)
|
||||
#define __ENVELOPE_H
|
||||
#ifndef STK_ENVELOPE_H
|
||||
#define STK_ENVELOPE_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "Generator.h"
|
||||
|
||||
class Envelope : public Stk
|
||||
class Envelope : public Generator
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -35,34 +35,40 @@ class Envelope : public Stk
|
||||
virtual void keyOff(void);
|
||||
|
||||
//! Set the \e rate.
|
||||
void setRate(MY_FLOAT aRate);
|
||||
void setRate(StkFloat rate);
|
||||
|
||||
//! Set the \e rate based on a time duration.
|
||||
void setTime(MY_FLOAT aTime);
|
||||
void setTime(StkFloat time);
|
||||
|
||||
//! Set the target value.
|
||||
virtual void setTarget(MY_FLOAT aTarget);
|
||||
virtual void setTarget(StkFloat target);
|
||||
|
||||
//! Set current and target values to \e aValue.
|
||||
virtual void setValue(MY_FLOAT aValue);
|
||||
virtual void setValue(StkFloat value);
|
||||
|
||||
//! Return the current envelope \e state (0 = at target, 1 otherwise).
|
||||
virtual int getState(void) const;
|
||||
|
||||
//! Return one envelope output value.
|
||||
virtual MY_FLOAT tick(void);
|
||||
virtual StkFloat tick(void);
|
||||
|
||||
//! Return \e vectorSize envelope outputs in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
//! Compute \e vectorSize outputs and return them in \e vector.
|
||||
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
MY_FLOAT value;
|
||||
MY_FLOAT target;
|
||||
MY_FLOAT rate;
|
||||
int state;
|
||||
StkFloat value_;
|
||||
StkFloat target_;
|
||||
StkFloat rate_;
|
||||
int state_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
71
include/FM.h
71
include/FM.h
@@ -19,12 +19,12 @@
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FM_H)
|
||||
#define __FM_H
|
||||
#ifndef STK_FM_H
|
||||
#define STK_FM_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
@@ -35,7 +35,10 @@ class FM : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the number of wave/envelope operators to control.
|
||||
FM( int operators = 4 );
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
FM( unsigned int operators = 4 );
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~FM();
|
||||
@@ -47,25 +50,25 @@ class FM : public Instrmnt
|
||||
void loadWaves(const char **filenames);
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
virtual void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Set the frequency ratio for the specified wave.
|
||||
void setRatio(int waveIndex, MY_FLOAT ratio);
|
||||
void setRatio(unsigned int waveIndex, StkFloat ratio);
|
||||
|
||||
//! Set the gain for the specified wave.
|
||||
void setGain(int waveIndex, MY_FLOAT gain);
|
||||
void setGain(unsigned int waveIndex, StkFloat gain);
|
||||
|
||||
//! Set the modulation speed in Hz.
|
||||
void setModulationSpeed(MY_FLOAT mSpeed);
|
||||
void setModulationSpeed(StkFloat mSpeed);
|
||||
|
||||
//! Set the modulation depth.
|
||||
void setModulationDepth(MY_FLOAT mDepth);
|
||||
void setModulationDepth(StkFloat mDepth);
|
||||
|
||||
//! Set the value of control1.
|
||||
void setControl1(MY_FLOAT cVal);
|
||||
void setControl1(StkFloat cVal);
|
||||
|
||||
//! Set the value of control1.
|
||||
void setControl2(MY_FLOAT cVal);
|
||||
void setControl2(StkFloat cVal);
|
||||
|
||||
//! Start envelopes toward "on" targets.
|
||||
void keyOn();
|
||||
@@ -74,29 +77,41 @@ class FM : public Instrmnt
|
||||
void keyOff();
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Pure virtual function ... must be defined in subclasses.
|
||||
virtual MY_FLOAT tick() = 0;
|
||||
virtual StkFloat tick() = 0;
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize) = 0;
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 ) = 0;
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
virtual void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
ADSR **adsr;
|
||||
WaveLoop **waves;
|
||||
WaveLoop *vibrato;
|
||||
TwoZero *twozero;
|
||||
int nOperators;
|
||||
MY_FLOAT baseFrequency;
|
||||
MY_FLOAT *ratios;
|
||||
MY_FLOAT *gains;
|
||||
MY_FLOAT modDepth;
|
||||
MY_FLOAT control1;
|
||||
MY_FLOAT control2;
|
||||
MY_FLOAT __FM_gains[100];
|
||||
MY_FLOAT __FM_susLevels[16];
|
||||
MY_FLOAT __FM_attTimes[32];
|
||||
std::vector<ADSR *> adsr_;
|
||||
std::vector<WaveLoop *> waves_;
|
||||
WaveLoop *vibrato_;
|
||||
TwoZero twozero_;
|
||||
unsigned int nOperators_;
|
||||
StkFloat baseFrequency_;
|
||||
std::vector<StkFloat> ratios_;
|
||||
std::vector<StkFloat> gains_;
|
||||
StkFloat modDepth_;
|
||||
StkFloat control1_;
|
||||
StkFloat control2_;
|
||||
StkFloat fmGains_[100];
|
||||
StkFloat fmSusLevels_[16];
|
||||
StkFloat fmAttTimes_[32];
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FMVOICES_H)
|
||||
#define __FMVOICES_H
|
||||
#ifndef STK_FMVOICES_H
|
||||
#define STK_FMVOICES_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
@@ -39,27 +39,42 @@ class FMVoices : public FM
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
FMVoices();
|
||||
|
||||
//! Class destructor.
|
||||
~FMVoices();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
virtual void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
virtual void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
int currentVowel;
|
||||
MY_FLOAT tilt[3];
|
||||
MY_FLOAT mods[3];
|
||||
int currentVowel_;
|
||||
StkFloat tilt_[3];
|
||||
StkFloat mods_[3];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,14 +23,16 @@
|
||||
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 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FILTER_H)
|
||||
#define __FILTER_H
|
||||
#ifndef STK_FILTER_H
|
||||
#define STK_FILTER_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include <vector>
|
||||
#include <valarray>
|
||||
|
||||
class Filter : public Stk
|
||||
{
|
||||
@@ -40,72 +42,81 @@ public:
|
||||
|
||||
//! Overloaded constructor which takes filter coefficients.
|
||||
/*!
|
||||
An StkError can be thrown if either \e nb or \e na is less than
|
||||
one, or if the a[0] coefficient is equal to zero.
|
||||
An StkError can be thrown if either of the coefficient vector
|
||||
sizes is zero, or if the a[0] coefficient is equal to zero.
|
||||
*/
|
||||
Filter(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients);
|
||||
Filter( std::vector<StkFloat> &bCoefficients, std::vector<StkFloat> &aCoefficients );
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Filter(void);
|
||||
|
||||
//! Clears all internal states of the filter.
|
||||
//! Sets all internal states of the filter to zero.
|
||||
void clear(void);
|
||||
|
||||
//! Set filter coefficients.
|
||||
/*!
|
||||
An StkError can be thrown if either \e nb or \e na is less than
|
||||
one, or if the a[0] coefficient is equal to zero. If a[0] is not
|
||||
equal to 1, the filter coeffcients are normalized by a[0].
|
||||
An StkError can be thrown if either of the coefficient vector
|
||||
sizes is zero, or if the a[0] coefficient is equal to zero. If
|
||||
a[0] is not equal to 1, the filter coeffcients are normalized by
|
||||
a[0]. The internal state of the filter is cleared.
|
||||
*/
|
||||
void setCoefficients(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients);
|
||||
void setCoefficients( std::vector<StkFloat> &bCoefficients, std::vector<StkFloat> &aCoefficients );
|
||||
|
||||
//! Set numerator coefficients.
|
||||
/*!
|
||||
An StkError can be thrown if \e nb is less than one. Any
|
||||
previously set denominator coefficients are left unaffected.
|
||||
Note that the default constructor sets the single denominator
|
||||
coefficient a[0] to 1.0.
|
||||
An StkError can be thrown if coefficient vector is empty. Any
|
||||
previously set denominator coefficients are left unaffected. Note
|
||||
that the default constructor sets the single denominator
|
||||
coefficient a[0] to 1.0. The internal state of the filter is
|
||||
cleared.
|
||||
*/
|
||||
void setNumerator(int nb, MY_FLOAT *bCoefficients);
|
||||
void setNumerator( std::vector<StkFloat> &bCoefficients );
|
||||
|
||||
//! Set denominator coefficients.
|
||||
/*!
|
||||
An StkError can be thrown if \e na is less than one or if the
|
||||
a[0] coefficient is equal to zero. Previously set numerator
|
||||
coefficients are unaffected unless a[0] is not equal to 1, in
|
||||
which case all coeffcients are normalized by a[0]. Note that the
|
||||
default constructor sets the single numerator coefficient b[0]
|
||||
to 1.0.
|
||||
An StkError can be thrown if the coefficient vector is empty or
|
||||
if the a[0] coefficient is equal to zero. Previously set
|
||||
numerator coefficients are unaffected unless a[0] is not equal to
|
||||
1, in which case all coeffcients are normalized by a[0]. Note
|
||||
that the default constructor sets the single numerator coefficient
|
||||
b[0] to 1.0. The internal state of the filter is cleared.
|
||||
*/
|
||||
void setDenominator(int na, MY_FLOAT *aCoefficients);
|
||||
void setDenominator( std::vector<StkFloat> &aCoefficients );
|
||||
|
||||
//! Set the filter gain.
|
||||
/*!
|
||||
The gain is applied at the filter input and does not affect the
|
||||
coefficient values. The default gain value is 1.0.
|
||||
*/
|
||||
virtual void setGain(MY_FLOAT theGain);
|
||||
virtual void setGain(StkFloat gain);
|
||||
|
||||
//! Return the current filter gain.
|
||||
virtual MY_FLOAT getGain(void) const;
|
||||
virtual StkFloat getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
virtual MY_FLOAT lastOut(void) const;
|
||||
virtual StkFloat lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
virtual MY_FLOAT tick(MY_FLOAT sample);
|
||||
virtual StkFloat tick(StkFloat sample);
|
||||
|
||||
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
MY_FLOAT gain;
|
||||
int nB;
|
||||
int nA;
|
||||
MY_FLOAT *b;
|
||||
MY_FLOAT *a;
|
||||
MY_FLOAT *outputs;
|
||||
MY_FLOAT *inputs;
|
||||
StkFloat gain_;
|
||||
std::vector<StkFloat> b_;
|
||||
std::vector<StkFloat> a_;
|
||||
std::vector<StkFloat> outputs_;
|
||||
std::vector<StkFloat> inputs_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
- Vibrato Gain = 1
|
||||
- Breath Pressure = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FLUTE_H)
|
||||
#define __FLUTE_H
|
||||
#ifndef STK_FLUTE_H
|
||||
#define STK_FLUTE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "JetTabl.h"
|
||||
#include "JetTable.h"
|
||||
#include "DelayL.h"
|
||||
#include "OnePole.h"
|
||||
#include "PoleZero.h"
|
||||
@@ -38,7 +38,10 @@ class Flute : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Flute(MY_FLOAT lowestFrequency);
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Flute(StkFloat lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Flute();
|
||||
@@ -47,53 +50,65 @@ class Flute : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Set the reflection coefficient for the jet delay (-1.0 - 1.0).
|
||||
void setJetReflection(MY_FLOAT coefficient);
|
||||
void setJetReflection(StkFloat coefficient);
|
||||
|
||||
//! Set the reflection coefficient for the air column delay (-1.0 - 1.0).
|
||||
void setEndReflection(MY_FLOAT coefficient);
|
||||
void setEndReflection(StkFloat coefficient);
|
||||
|
||||
//! Set the length of the jet delay in terms of a ratio of jet delay to air column delay lengths.
|
||||
void setJetDelay(MY_FLOAT aRatio);
|
||||
void setJetDelay(StkFloat aRatio);
|
||||
|
||||
//! Apply breath velocity to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
void startBlowing(StkFloat amplitude, StkFloat rate);
|
||||
|
||||
//! Decrease breath velocity with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
void stopBlowing(StkFloat rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
DelayL *jetDelay;
|
||||
DelayL *boreDelay;
|
||||
JetTabl *jetTable;
|
||||
OnePole *filter;
|
||||
PoleZero *dcBlock;
|
||||
Noise *noise;
|
||||
ADSR *adsr;
|
||||
WaveLoop *vibrato;
|
||||
long length;
|
||||
MY_FLOAT lastFrequency;
|
||||
MY_FLOAT maxPressure;
|
||||
MY_FLOAT jetReflection;
|
||||
MY_FLOAT endReflection;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT outputGain;
|
||||
MY_FLOAT jetRatio;
|
||||
DelayL jetDelay_;
|
||||
DelayL boreDelay_;
|
||||
JetTable jetTable_;
|
||||
OnePole filter_;
|
||||
PoleZero dcBlock_;
|
||||
Noise noise_;
|
||||
ADSR adsr_;
|
||||
WaveLoop *vibrato_;
|
||||
unsigned long length_;
|
||||
StkFloat lastFrequency_;
|
||||
StkFloat maxPressure_;
|
||||
StkFloat jetReflection_;
|
||||
StkFloat endReflection_;
|
||||
StkFloat noiseGain_;
|
||||
StkFloat vibratoGain_;
|
||||
StkFloat outputGain_;
|
||||
StkFloat jetRatio_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
It provides methods for controlling the sweep
|
||||
rate and target frequency.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__FORMSWEP_H)
|
||||
#define __FORMSWEP_H
|
||||
#ifndef STK_FORMSWEP_H
|
||||
#define STK_FORMSWEP_H
|
||||
|
||||
#include "BiQuad.h"
|
||||
|
||||
@@ -39,13 +39,13 @@ class FormSwep : public BiQuad
|
||||
the unit-circle (\e radius close to one), the narrower the
|
||||
resulting resonance width.
|
||||
*/
|
||||
void setResonance(MY_FLOAT aFrequency, MY_FLOAT aRadius);
|
||||
void setResonance(StkFloat frequency, StkFloat radius);
|
||||
|
||||
//! Set both the current and target resonance parameters.
|
||||
void setStates(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0);
|
||||
void setStates(StkFloat frequency, StkFloat radius, StkFloat gain = 1.0);
|
||||
|
||||
//! Set target resonance parameters.
|
||||
void setTargets(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0);
|
||||
void setTargets(StkFloat frequency, StkFloat radius, StkFloat gain = 1.0);
|
||||
|
||||
//! Set the sweep rate (between 0.0 - 1.0).
|
||||
/*!
|
||||
@@ -56,7 +56,7 @@ class FormSwep : public BiQuad
|
||||
target values. A sweep rate of 0.0 will produce no
|
||||
change in resonance parameters.
|
||||
*/
|
||||
void setSweepRate(MY_FLOAT aRate);
|
||||
void setSweepRate(StkFloat rate);
|
||||
|
||||
//! Set the sweep rate in terms of a time value in seconds.
|
||||
/*!
|
||||
@@ -64,29 +64,38 @@ class FormSwep : public BiQuad
|
||||
given time for the formant parameters to reach
|
||||
their target values.
|
||||
*/
|
||||
void setSweepTime(MY_FLOAT aTime);
|
||||
void setSweepTime(StkFloat time);
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
StkFloat tick(StkFloat sample);
|
||||
|
||||
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
bool dirty;
|
||||
MY_FLOAT frequency;
|
||||
MY_FLOAT radius;
|
||||
MY_FLOAT startFrequency;
|
||||
MY_FLOAT startRadius;
|
||||
MY_FLOAT startGain;
|
||||
MY_FLOAT targetFrequency;
|
||||
MY_FLOAT targetRadius;
|
||||
MY_FLOAT targetGain;
|
||||
MY_FLOAT deltaFrequency;
|
||||
MY_FLOAT deltaRadius;
|
||||
MY_FLOAT deltaGain;
|
||||
MY_FLOAT sweepState;
|
||||
MY_FLOAT sweepRate;
|
||||
bool dirty_;
|
||||
StkFloat frequency_;
|
||||
StkFloat radius_;
|
||||
StkFloat startFrequency_;
|
||||
StkFloat startRadius_;
|
||||
StkFloat startGain_;
|
||||
StkFloat targetFrequency_;
|
||||
StkFloat targetRadius_;
|
||||
StkFloat targetGain_;
|
||||
StkFloat deltaFrequency_;
|
||||
StkFloat deltaRadius_;
|
||||
StkFloat deltaGain_;
|
||||
StkFloat sweepState_;
|
||||
StkFloat sweepRate_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
52
include/Function.h
Normal file
52
include/Function.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************/
|
||||
/*! \class Function
|
||||
\brief STK abstract function parent class.
|
||||
|
||||
This class provides common functionality for STK classes which
|
||||
implement tables or other types of input to output function
|
||||
mappings.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
#ifndef STK_FUNCTION_H
|
||||
#define STK_FUNCTION_H
|
||||
|
||||
class Function : public Stk
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Function();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Function();
|
||||
|
||||
//! Return the last output value.
|
||||
virtual StkFloat lastOut() const { return lastOutput_; };
|
||||
|
||||
//! Abstract tick function ... must be implemented in subclasses.
|
||||
virtual StkFloat tick( StkFloat input ) = 0;
|
||||
|
||||
//! Take \e vectorSize inputs from \e vector and replace them with corresponding outputs.
|
||||
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
|
||||
StkFloat lastOutput_;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
51
include/Generator.h
Normal file
51
include/Generator.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************/
|
||||
/*! \class Generator
|
||||
\brief STK abstract unit generator parent class.
|
||||
|
||||
This class provides common functionality for
|
||||
STK unit generator source subclasses.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#ifndef STK_GENERATOR_H
|
||||
#define STK_GENERATOR_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class Generator : public Stk
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Generator();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Generator();
|
||||
|
||||
//! Return the last output value.
|
||||
virtual StkFloat lastOut() const { return lastOutput_; };
|
||||
|
||||
//! Abstract tick function ... must be implemented in subclasses.
|
||||
virtual StkFloat tick( void ) = 0;
|
||||
|
||||
//! Compute \e vectorSize outputs and return them in \e vector.
|
||||
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
|
||||
StkFloat lastOutput_;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__HEVYMETL_H)
|
||||
#define __HEVYMETL_H
|
||||
#ifndef STK_HEVYMETL_H
|
||||
#define STK_HEVYMETL_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
@@ -37,16 +37,31 @@ class HevyMetl : public FM
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
HevyMetl();
|
||||
|
||||
//! Class destructor.
|
||||
~HevyMetl();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,15 +5,14 @@
|
||||
This class provides a common interface for
|
||||
all STK instruments.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__INSTRMNT_H)
|
||||
#define __INSTRMNT_H
|
||||
#ifndef STK_INSTRMNT_H
|
||||
#define STK_INSTRMNT_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include <iostream>
|
||||
|
||||
class Instrmnt : public Stk
|
||||
{
|
||||
@@ -25,34 +24,43 @@ class Instrmnt : public Stk
|
||||
virtual ~Instrmnt();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) = 0;
|
||||
virtual void noteOn(StkFloat frequency, StkFloat amplitude) = 0;
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude) = 0;
|
||||
virtual void noteOff(StkFloat amplitude) = 0;
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
virtual void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
StkFloat lastOut() const;
|
||||
|
||||
//! Return the last left output value.
|
||||
MY_FLOAT lastOutLeft() const;
|
||||
StkFloat lastOutLeft() const;
|
||||
|
||||
//! Return the last right output value.
|
||||
MY_FLOAT lastOutRight() const;
|
||||
StkFloat lastOutRight() const;
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick() = 0;
|
||||
virtual StkFloat tick() = 0;
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
virtual void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
MY_FLOAT lastOutput;
|
||||
StkFloat lastOutput_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,21 +10,21 @@
|
||||
filters, and two decorrelation delay lines in
|
||||
parallel at the output.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__JCREV_H)
|
||||
#define __JCREV_H
|
||||
#ifndef STK_JCREV_H
|
||||
#define STK_JCREV_H
|
||||
|
||||
#include "Reverb.h"
|
||||
#include "Effect.h"
|
||||
#include "Delay.h"
|
||||
|
||||
class JCRev : public Reverb
|
||||
class JCRev : public Effect
|
||||
{
|
||||
public:
|
||||
//! Class constructor taking a T60 decay time argument.
|
||||
JCRev(MY_FLOAT T60);
|
||||
//! Class constructor taking a T60 decay time argument (one second default value).
|
||||
JCRev( StkFloat T60 = 1.0 );
|
||||
|
||||
//! Class destructor.
|
||||
~JCRev();
|
||||
@@ -32,16 +32,31 @@ class JCRev : public Reverb
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set the reverberation T60 decay time.
|
||||
void setT60( StkFloat T60 );
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
StkFloat tick(StkFloat input);
|
||||
|
||||
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
Delay *allpassDelays[3];
|
||||
Delay *combDelays[4];
|
||||
Delay *outLeftDelay;
|
||||
Delay *outRightDelay;
|
||||
MY_FLOAT allpassCoefficient;
|
||||
MY_FLOAT combCoefficient[4];
|
||||
Delay allpassDelays_[3];
|
||||
Delay combDelays_[4];
|
||||
Delay outLeftDelay_;
|
||||
Delay outRightDelay_;
|
||||
StkFloat allpassCoefficient_;
|
||||
StkFloat combCoefficient_[4];
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/***************************************************/
|
||||
/*! \class JetTabl
|
||||
\brief STK jet table class.
|
||||
|
||||
This class implements a flue jet non-linear
|
||||
function, computed by a polynomial calculation.
|
||||
Contrary to the name, this is not a "table".
|
||||
|
||||
Consult Fletcher and Rossing, Karjalainen,
|
||||
Cook, and others for more information.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__JETTABL_H)
|
||||
#define __JETTABL_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class JetTabl : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
JetTabl();
|
||||
|
||||
//! Class destructor.
|
||||
~JetTabl();
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
|
||||
//! Return the function value for \e input.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
|
||||
//! Take \e vectorSize inputs and return the corresponding function values in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
protected:
|
||||
MY_FLOAT lastOutput;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
49
include/JetTable.h
Normal file
49
include/JetTable.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/***************************************************/
|
||||
/*! \class JetTable
|
||||
\brief STK jet table class.
|
||||
|
||||
This class implements a flue jet non-linear
|
||||
function, computed by a polynomial calculation.
|
||||
Contrary to the name, this is not a "table".
|
||||
|
||||
Consult Fletcher and Rossing, Karjalainen,
|
||||
Cook, and others for more information.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#ifndef STK_JETTABL_H
|
||||
#define STK_JETTABL_H
|
||||
|
||||
#include "Function.h"
|
||||
|
||||
class JetTable : public Function
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
JetTable();
|
||||
|
||||
//! Class destructor.
|
||||
~JetTable();
|
||||
|
||||
//! Return the function value for \e input.
|
||||
StkFloat tick(StkFloat input);
|
||||
|
||||
//! Take \e vectorSize inputs from \e vector and replace them with corresponding outputs.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -23,12 +23,12 @@
|
||||
- String Detuning = 1
|
||||
- Microphone Position = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MANDOLIN_H)
|
||||
#define __MANDOLIN_H
|
||||
#ifndef STK_MANDOLIN_H
|
||||
#define STK_MANDOLIN_H
|
||||
|
||||
#include "PluckTwo.h"
|
||||
#include "WvIn.h"
|
||||
@@ -37,35 +37,46 @@ class Mandolin : public PluckTwo
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Mandolin(MY_FLOAT lowestFrequency);
|
||||
Mandolin(StkFloat lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Mandolin();
|
||||
~Mandolin();
|
||||
|
||||
//! Pluck the strings with the given amplitude (0.0 - 1.0) using the current frequency.
|
||||
void pluck(MY_FLOAT amplitude);
|
||||
void pluck(StkFloat amplitude);
|
||||
|
||||
//! Pluck the strings with the given amplitude (0.0 - 1.0) and position (0.0 - 1.0).
|
||||
void pluck(MY_FLOAT amplitude,MY_FLOAT position);
|
||||
void pluck(StkFloat amplitude,StkFloat position);
|
||||
|
||||
//! Start a note with the given frequency and amplitude (0.0 - 1.0).
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Set the body size (a value of 1.0 produces the "default" size).
|
||||
void setBodySize(MY_FLOAT size);
|
||||
void setBodySize(StkFloat size);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
WvIn *soundfile[12];
|
||||
MY_FLOAT directBody;
|
||||
int mic;
|
||||
long dampTime;
|
||||
bool waveDone;
|
||||
WvIn *soundfile_[12];
|
||||
int mic_;
|
||||
long dampTime_;
|
||||
bool waveDone_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MESH2D_H)
|
||||
#define __MESH2D_H
|
||||
#ifndef STK_MESH2D_H
|
||||
#define STK_MESH2D_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
#define NXMAX ((short)(12))
|
||||
#define NYMAX ((short)(12))
|
||||
const short NXMAX = 12;
|
||||
const short NYMAX = 12;
|
||||
|
||||
class Mesh2D : public Instrmnt
|
||||
{
|
||||
@@ -52,54 +52,64 @@ class Mesh2D : public Instrmnt
|
||||
void setNY(short lenY);
|
||||
|
||||
//! Set the x, y input position on a 0.0 - 1.0 scale.
|
||||
void setInputPosition(MY_FLOAT xFactor, MY_FLOAT yFactor);
|
||||
void setInputPosition(StkFloat xFactor, StkFloat yFactor);
|
||||
|
||||
//! Set the loss filters gains (0.0 - 1.0).
|
||||
void setDecay(MY_FLOAT decayFactor);
|
||||
void setDecay(StkFloat decayFactor);
|
||||
|
||||
//! Impulse the mesh with the given amplitude (frequency ignored).
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay) ... currently ignored.
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Calculate and return the signal energy stored in the mesh.
|
||||
MY_FLOAT energy();
|
||||
StkFloat energy();
|
||||
|
||||
//! Compute one output sample, without adding energy to the mesh.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Input a sample to the mesh and compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
StkFloat tick(StkFloat input);
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
|
||||
MY_FLOAT tick0();
|
||||
MY_FLOAT tick1();
|
||||
StkFloat tick0();
|
||||
StkFloat tick1();
|
||||
void clearMesh();
|
||||
|
||||
short NX, NY;
|
||||
short xInput, yInput;
|
||||
OnePole *filterX[NXMAX];
|
||||
OnePole *filterY[NYMAX];
|
||||
MY_FLOAT v[NXMAX-1][NYMAX-1]; // junction velocities
|
||||
MY_FLOAT vxp[NXMAX][NYMAX]; // positive-x velocity wave
|
||||
MY_FLOAT vxm[NXMAX][NYMAX]; // negative-x velocity wave
|
||||
MY_FLOAT vyp[NXMAX][NYMAX]; // positive-y velocity wave
|
||||
MY_FLOAT vym[NXMAX][NYMAX]; // negative-y velocity wave
|
||||
short NX_, NY_;
|
||||
short xInput_, yInput_;
|
||||
OnePole filterX_[NXMAX];
|
||||
OnePole filterY_[NYMAX];
|
||||
StkFloat v_[NXMAX-1][NYMAX-1]; // junction velocities
|
||||
StkFloat vxp_[NXMAX][NYMAX]; // positive-x velocity wave
|
||||
StkFloat vxm_[NXMAX][NYMAX]; // negative-x velocity wave
|
||||
StkFloat vyp_[NXMAX][NYMAX]; // positive-y velocity wave
|
||||
StkFloat vym_[NXMAX][NYMAX]; // negative-y velocity wave
|
||||
|
||||
// Alternate buffers
|
||||
MY_FLOAT vxp1[NXMAX][NYMAX]; // positive-x velocity wave
|
||||
MY_FLOAT vxm1[NXMAX][NYMAX]; // negative-x velocity wave
|
||||
MY_FLOAT vyp1[NXMAX][NYMAX]; // positive-y velocity wave
|
||||
MY_FLOAT vym1[NXMAX][NYMAX]; // negative-y velocity wave
|
||||
|
||||
int counter; // time in samples
|
||||
|
||||
StkFloat vxp1_[NXMAX][NYMAX]; // positive-x velocity wave
|
||||
StkFloat vxm1_[NXMAX][NYMAX]; // negative-x velocity wave
|
||||
StkFloat vyp1_[NXMAX][NYMAX]; // positive-y velocity wave
|
||||
StkFloat vym1_[NXMAX][NYMAX]; // negative-y velocity wave
|
||||
|
||||
int counter_; // time in samples
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,146 +2,165 @@
|
||||
/*! \class Messager
|
||||
\brief STK input control message parser.
|
||||
|
||||
This class reads and parses control messages
|
||||
from a variety of sources, such as a MIDI
|
||||
port, scorefile, socket connection, or pipe.
|
||||
MIDI messages are retrieved using the RtMidi
|
||||
class. All other input sources (scorefile,
|
||||
socket, or pipe) are assumed to provide SKINI
|
||||
formatted messages.
|
||||
This class reads and parses control messages from a variety of
|
||||
sources, such as a scorefile, MIDI port, socket connection, or
|
||||
stdin. MIDI messages are retrieved using the RtMidi class. All
|
||||
other input sources (scorefile, socket, or stdin) are assumed to
|
||||
provide SKINI formatted messages. This class can be compiled with
|
||||
generic, non-realtime support, in which case only scorefile
|
||||
reading is possible.
|
||||
|
||||
For each call to nextMessage(), the active
|
||||
input sources are queried to see if a new
|
||||
control message is available.
|
||||
The various \e realtime message acquisition mechanisms (from MIDI,
|
||||
socket, or stdin) take place asynchronously, filling the message
|
||||
queue. A call to popMessage() will pop the next available control
|
||||
message from the queue and return it via the referenced Message
|
||||
structure. When a \e non-realtime scorefile is set, it is not
|
||||
possible to start reading realtime input messages (from MIDI,
|
||||
socket, or stdin). Likewise, it is not possible to read from a
|
||||
scorefile when a realtime input mechanism is running.
|
||||
|
||||
This class is primarily for use in STK main()
|
||||
event loops.
|
||||
When MIDI input is started, input is also automatically read from
|
||||
stdin. This allows for program termination via the terminal
|
||||
window. An __SK_Exit_ message is pushed onto the stack whenever
|
||||
an "exit" or "Exit" message is received from stdin or when all
|
||||
socket connections close and no stdin thread is running.
|
||||
|
||||
One of the original goals in creating this
|
||||
class was to simplify the message acquisition
|
||||
process by removing all threads. If the
|
||||
windoze select() function behaved just like
|
||||
the unix one, that would have been possible.
|
||||
Since it does not (it can't be used to poll
|
||||
STDIN), I am using a thread to acquire
|
||||
messages from STDIN, which sends these
|
||||
messages via a socket connection to the
|
||||
message socket server. Perhaps in the future,
|
||||
it will be possible to simplify things.
|
||||
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 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MESSAGER_H)
|
||||
#define __MESSSAGER_H
|
||||
#ifndef STK_MESSAGER_H
|
||||
#define STK_MESSAGER_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "SKINI.h"
|
||||
#include "Skini.h"
|
||||
#include <queue>
|
||||
|
||||
#define MESSAGE_LENGTH 128
|
||||
#define MAX_MESSAGES 25
|
||||
#define STK_MIDI 0x0001
|
||||
#define STK_PIPE 0x0002
|
||||
#define STK_SOCKET 0x0004
|
||||
const int DEFAULT_QUEUE_LIMIT = 200;
|
||||
|
||||
#if defined(__STK_REALTIME__)
|
||||
|
||||
#include "Mutex.h"
|
||||
#include "Thread.h"
|
||||
#include "Socket.h"
|
||||
#include "RtMidi.h"
|
||||
|
||||
extern "C" THREAD_RETURN THREAD_TYPE stdinHandler(void * ptr);
|
||||
|
||||
#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
extern "C" THREAD_RETURN THREAD_TYPE socketHandler(void * ptr);
|
||||
|
||||
#endif // __STK_REALTIME__
|
||||
|
||||
class Messager : public Stk
|
||||
{
|
||||
public:
|
||||
//! Constructor performs initialization based on an input mask and an optional socket port.
|
||||
/*!
|
||||
The default constructor is set to read input from a SKINI
|
||||
scorefile. The flags STK_MIDI, STK_PIPE, and STK_SOCKET can be
|
||||
OR'ed together in any combination for multiple "realtime" input
|
||||
source parsing. An optional socket port number can be specified
|
||||
for use when the STK_SOCKET flag is set. For realtime input
|
||||
types, an StkError can be thrown during instantiation.
|
||||
*/
|
||||
Messager(int inputMask = 0, int port = 2001);
|
||||
|
||||
// This structure is used to share data among the various realtime
|
||||
// messager threads. It must be public.
|
||||
struct MessagerData {
|
||||
Skini skini;
|
||||
std::queue<Skini::Message> queue;
|
||||
unsigned int queueLimit;
|
||||
int sources;
|
||||
|
||||
#if defined(__STK_REALTIME__)
|
||||
Mutex mutex;
|
||||
RtMidiIn *midi;
|
||||
Socket *socket;
|
||||
std::vector<int> fd;
|
||||
fd_set mask;
|
||||
#endif
|
||||
|
||||
// Default constructor.
|
||||
MessagerData()
|
||||
:queueLimit(0), sources(0) {}
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
Messager();
|
||||
|
||||
//! Class destructor.
|
||||
~Messager();
|
||||
|
||||
//! Check for a new input message and return the message type.
|
||||
//! Pop the next message from the queue and write it to the referenced message structure.
|
||||
/*!
|
||||
Return type values greater than zero represent valid messages.
|
||||
If an input scorefile has been completely read or all realtime
|
||||
input sources have closed, a negative value is returned. If the
|
||||
return type is zero, no valid messages are present.
|
||||
Invalid messages (or an empty queue) are indicated by type
|
||||
values of zero, in which case all other message structure values
|
||||
are undefined. The user MUST verify the returned message type is
|
||||
valid before reading other message values.
|
||||
*/
|
||||
long nextMessage(void);
|
||||
void popMessage( Skini::Message& message );
|
||||
|
||||
//! Set the delta time (in samples) returned between valid realtime messages. This setting has no affect for scorefile messages.
|
||||
void setRtDelta(long nSamples);
|
||||
//! Push the referenced message onto the message stack.
|
||||
void pushMessage( Skini::Message& message );
|
||||
|
||||
//! Return the current message "delta time" in samples.
|
||||
long getDelta(void) const;
|
||||
//! Specify a SKINI formatted scorefile from which messages should be read.
|
||||
/*!
|
||||
A return value of \c true indicates the call was successful. A
|
||||
return value of \c false can occur if the file is not found,
|
||||
cannot be opened, another file is currently still open, or if a
|
||||
realtime input mechanism is running. Scorefile input is
|
||||
considered to be a non-realtime control mechanism that cannot run
|
||||
concurrently with realtime input.
|
||||
*/
|
||||
bool setScoreFile( const char* filename );
|
||||
|
||||
//! Return the current message type.
|
||||
long getType() const;
|
||||
#if defined(__STK_REALTIME__)
|
||||
//! Initiate the "realtime" retreival from stdin of control messages into the queue.
|
||||
/*!
|
||||
This function initiates a thread for asynchronous retrieval of
|
||||
SKINI formatted messages from stdin. A return value of \c true
|
||||
indicates the call was successful. A return value of \c false can
|
||||
occur if a scorefile is being read, a stdin thread is already
|
||||
running, or a thread error occurs during startup. Stdin input is
|
||||
considered to be a realtime control mechanism that cannot run
|
||||
concurrently with non-realtime scorefile input.
|
||||
*/
|
||||
bool startStdInput();
|
||||
|
||||
//! Return the byte two value for the current message.
|
||||
MY_FLOAT getByteTwo() const;
|
||||
//! Start a socket server, accept connections, and read "realtime" control messages into the message queue.
|
||||
/*!
|
||||
This function creates a socket server on the optional port
|
||||
(default = 2001) and starts a thread for asynchronous retrieval of
|
||||
SKINI formatted messages from socket connections. A return value
|
||||
of \c true indicates the call was successful. A return value of
|
||||
\c false can occur if a scorefile is being read, a socket thread
|
||||
is already running, or an error occurs during the socket server
|
||||
or thread initialization stages. Socket input is considered to be
|
||||
a realtime control mechanism that cannot run concurrently with
|
||||
non-realtime scorefile input.
|
||||
*/
|
||||
bool startSocketInput( int port=2001 );
|
||||
|
||||
//! Return the byte three value for the current message.
|
||||
MY_FLOAT getByteThree() const;
|
||||
//! Start MIDI input, with optional device and port identifiers.
|
||||
/*!
|
||||
This function creates an RtMidiIn instance for MIDI input. The
|
||||
RtMidiIn class invokes a local callback function to read incoming
|
||||
messages into the queue. If \c port = -1, RtMidiIn will open a
|
||||
virtual port to which other software applications can connect (OS
|
||||
X and Linux only). A return value of \c true indicates the call
|
||||
was successful. A return value of \c false can occur if a
|
||||
scorefile is being read, MIDI input is already running, or an
|
||||
error occurs during RtMidiIn construction. Midi input is
|
||||
considered to be a realtime control mechanism that cannot run
|
||||
concurrently with non-realtime scorefile input.
|
||||
*/
|
||||
bool startMidiInput( int port=0 );
|
||||
|
||||
//! Return the channel number for the current message.
|
||||
long getChannel() const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
SKINI *skini;
|
||||
long type;
|
||||
long channel;
|
||||
MY_FLOAT byte2;
|
||||
MY_FLOAT byte3;
|
||||
int sources;
|
||||
long delta;
|
||||
long rtDelta;
|
||||
char message[MAX_MESSAGES][MESSAGE_LENGTH];
|
||||
unsigned int messageIndex;
|
||||
int nMessages;
|
||||
MessagerData data_;
|
||||
|
||||
#if defined(__STK_REALTIME__)
|
||||
|
||||
// Check MIDI source for new messages.
|
||||
bool midiMessage(void);
|
||||
|
||||
// Check socket sources for new messages.
|
||||
bool socketMessage(void);
|
||||
|
||||
// Receive and parse socket data.
|
||||
bool readSocket(int fd);
|
||||
|
||||
RtMidi *midi;
|
||||
Thread *thread;
|
||||
Socket *soket;
|
||||
|
||||
unsigned int nSockets;
|
||||
fd_set mask;
|
||||
int maxfd;
|
||||
int pipefd;
|
||||
int fd[16];
|
||||
char error[256];
|
||||
|
||||
#endif // __STK_REALTIME__
|
||||
Thread stdinThread_;
|
||||
Thread socketThread_;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // defined(__MESSAGER_H)
|
||||
#endif
|
||||
|
||||
131
include/MidiFileIn.h
Normal file
131
include/MidiFileIn.h
Normal file
@@ -0,0 +1,131 @@
|
||||
/**********************************************************************/
|
||||
/*! \class MidiFileIn
|
||||
\brief A standard MIDI file reading/parsing class.
|
||||
|
||||
This class can be used to read events from a standard MIDI file.
|
||||
Event bytes are copied to a C++ vector and must be subsequently
|
||||
interpreted by the user. The function getNextMidiEvent() skips
|
||||
meta and sysex events, returning only MIDI channel messages.
|
||||
Event delta-times are returned in the form of "ticks" and a
|
||||
function is provided to determine the current "seconds per tick".
|
||||
Tempo changes are internally tracked by the class and reflected in
|
||||
the values returned by the function getTickSeconds().
|
||||
|
||||
by Gary P. Scavone, 2003.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
|
||||
#ifndef STK_MIDIFILEIN_H
|
||||
#define STK_MIDIFILEIN_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
class MidiFileIn : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
/*!
|
||||
If an error occurs while opening or parsing the file header, an
|
||||
StkError exception will be thrown.
|
||||
*/
|
||||
MidiFileIn( std::string fileName );
|
||||
|
||||
//! Class destructor.
|
||||
~MidiFileIn();
|
||||
|
||||
//! Return the MIDI file format (0, 1, or 2).
|
||||
int getFileFormat() const;
|
||||
|
||||
//! Return the number of tracks in the MIDI file.
|
||||
unsigned int getNumberOfTracks() const;
|
||||
|
||||
//! Return the MIDI file division value from the file header.
|
||||
/*!
|
||||
Note that this value must be "parsed" in accordance with the
|
||||
MIDI File Specification. In particular, if the MSB is set, the
|
||||
file uses time-code representations for delta-time values.
|
||||
*/
|
||||
int getDivision() const;
|
||||
|
||||
//! Move the specified track event reader to the beginning of its track.
|
||||
/*!
|
||||
The relevant track tempo value is reset as well. If an invalid
|
||||
track number is specified, an StkError exception will be thrown.
|
||||
*/
|
||||
void rewindTrack( unsigned int track = 0 );
|
||||
|
||||
//! Get the current value, in seconds, of delta-time ticks for the specified track.
|
||||
/*!
|
||||
This value can change as events are read (via "Set Tempo"
|
||||
Meta-Events). Therefore, one should call this function after
|
||||
every call to getNextEvent() or getNextMidiEvent(). If an
|
||||
invalid track number is specified, an StkError exception will be
|
||||
thrown.
|
||||
*/
|
||||
double getTickSeconds( unsigned int track = 0 );
|
||||
|
||||
//! Fill the user-provided vector with the next event in the specified track and return the event delta-time in ticks.
|
||||
/*!
|
||||
MIDI File events consist of a delta time and a sequence of event
|
||||
bytes. This function returns the delta-time value and writes
|
||||
the subsequent event bytes directly to the event vector. The
|
||||
user must parse the event bytes in accordance with the MIDI File
|
||||
Specification. All returned MIDI channel events are complete
|
||||
... a status byte is provided even when running status is used
|
||||
in the file. If the track has reached its end, no bytes will be
|
||||
written and the event vector size will be zero. If an invalid
|
||||
track number is specified or an error occurs while reading the
|
||||
file, an StkError exception will be thrown.
|
||||
*/
|
||||
unsigned long getNextEvent( std::vector<unsigned char> *event, unsigned int track = 0 );
|
||||
|
||||
//! Fill the user-provided vector with the next MIDI channel event in the specified track and return the event delta time in ticks.
|
||||
/*!
|
||||
All returned MIDI events are complete ... a status byte is
|
||||
provided even when running status is used in the file. Meta and
|
||||
sysex events in the track are skipped though "Set Tempo" events
|
||||
are properly parsed for use by the getTickSeconds() function.
|
||||
If the track has reached its end, no bytes will be written and
|
||||
the event vector size will be zero. If an invalid track number
|
||||
is specified or an error occurs while reading the file, an
|
||||
StkError exception will be thrown.
|
||||
*/
|
||||
unsigned long getNextMidiEvent( std::vector<unsigned char> *midiEvent, unsigned int track = 0 );
|
||||
|
||||
protected:
|
||||
|
||||
// This protected class function is used for reading variable-length
|
||||
// MIDI file values. It is assumed that this function is called with
|
||||
// the file read pointer positioned at the start of a
|
||||
// variable-length value. The function returns true if the value is
|
||||
// successfully parsed. Otherwise, it returns false.
|
||||
bool readVariableLength( unsigned long *value );
|
||||
|
||||
std::ifstream file_;
|
||||
unsigned int nTracks_;
|
||||
int format_;
|
||||
int division_;
|
||||
bool usingTimeCode_;
|
||||
std::vector<double> tickSeconds_;
|
||||
std::vector<long> trackPointers_;
|
||||
std::vector<long> trackOffsets_;
|
||||
std::vector<long> trackLengths_;
|
||||
std::vector<char> trackStatus_;
|
||||
|
||||
// This structure and the following variables are used to save and
|
||||
// keep track of a format 1 tempo map (and the initial tickSeconds
|
||||
// parameter for formats 0 and 2).
|
||||
struct TempoChange {
|
||||
unsigned long count;
|
||||
double tickSeconds;
|
||||
};
|
||||
std::vector<TempoChange> tempoEvents_;
|
||||
std::vector<unsigned long> trackCounters_;
|
||||
std::vector<unsigned int> trackTempoIndex_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -7,12 +7,12 @@
|
||||
(non-sweeping BiQuad filters), where N is set
|
||||
during instantiation.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MODAL_H)
|
||||
#define __MODAL_H
|
||||
#ifndef STK_MODAL_H
|
||||
#define STK_MODAL_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "Envelope.h"
|
||||
@@ -24,7 +24,10 @@ class Modal : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the desired number of modes to create.
|
||||
Modal( int modes = 4 );
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Modal( unsigned int modes = 4 );
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Modal();
|
||||
@@ -33,54 +36,67 @@ public:
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
virtual void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Set the ratio and radius for a specified mode filter.
|
||||
void setRatioAndRadius(int modeIndex, MY_FLOAT ratio, MY_FLOAT radius);
|
||||
void setRatioAndRadius(unsigned int modeIndex, StkFloat ratio, StkFloat radius);
|
||||
|
||||
//! Set the master gain.
|
||||
void setMasterGain(MY_FLOAT aGain);
|
||||
void setMasterGain(StkFloat aGain);
|
||||
|
||||
//! Set the direct gain.
|
||||
void setDirectGain(MY_FLOAT aGain);
|
||||
void setDirectGain(StkFloat aGain);
|
||||
|
||||
//! Set the gain for a specified mode filter.
|
||||
void setModeGain(int modeIndex, MY_FLOAT gain);
|
||||
void setModeGain(unsigned int modeIndex, StkFloat gain);
|
||||
|
||||
//! Initiate a strike with the given amplitude (0.0 - 1.0).
|
||||
virtual void strike(MY_FLOAT amplitude);
|
||||
virtual void strike(StkFloat amplitude);
|
||||
|
||||
//! Damp modes with a given decay factor (0.0 - 1.0).
|
||||
void damp(MY_FLOAT amplitude);
|
||||
void damp(StkFloat amplitude);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
virtual StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value) = 0;
|
||||
virtual void controlChange(int number, StkFloat value) = 0;
|
||||
|
||||
protected:
|
||||
Envelope *envelope;
|
||||
WvIn *wave;
|
||||
BiQuad **filters;
|
||||
OnePole *onepole;
|
||||
WaveLoop *vibrato;
|
||||
int nModes;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT masterGain;
|
||||
MY_FLOAT directGain;
|
||||
MY_FLOAT stickHardness;
|
||||
MY_FLOAT strikePosition;
|
||||
MY_FLOAT baseFrequency;
|
||||
MY_FLOAT *ratios;
|
||||
MY_FLOAT *radii;
|
||||
Envelope envelope_;
|
||||
WvIn *wave_;
|
||||
BiQuad **filters_;
|
||||
OnePole onepole_;
|
||||
WaveLoop *vibrato_;
|
||||
|
||||
unsigned int nModes_;
|
||||
std::vector<StkFloat> ratios_;
|
||||
std::vector<StkFloat> radii_;
|
||||
|
||||
StkFloat vibratoGain_;
|
||||
StkFloat masterGain_;
|
||||
StkFloat directGain_;
|
||||
StkFloat stickHardness_;
|
||||
StkFloat strikePosition_;
|
||||
StkFloat baseFrequency_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
Control Change Numbers:
|
||||
- Stick Hardness = 2
|
||||
- Stick Position = 4
|
||||
- Vibrato Gain = 11
|
||||
- Vibrato Frequency = 7
|
||||
- Vibrato Gain = 1
|
||||
- Vibrato Frequency = 11
|
||||
- Direct Stick Mix = 8
|
||||
- Volume = 128
|
||||
- Modal Presets = 16
|
||||
- Marimba = 0
|
||||
@@ -23,12 +24,12 @@
|
||||
- Two Fixed = 7
|
||||
- Clump = 8
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MODALBAR_H)
|
||||
#define __MODALBAR_H
|
||||
#ifndef STK_MODALBAR_H
|
||||
#define STK_MODALBAR_H
|
||||
|
||||
#include "Modal.h"
|
||||
|
||||
@@ -42,19 +43,19 @@ public:
|
||||
~ModalBar();
|
||||
|
||||
//! Set stick hardness (0.0 - 1.0).
|
||||
void setStickHardness(MY_FLOAT hardness);
|
||||
void setStickHardness(StkFloat hardness);
|
||||
|
||||
//! Set stick position (0.0 - 1.0).
|
||||
void setStrikePosition(MY_FLOAT position);
|
||||
void setStrikePosition(StkFloat position);
|
||||
|
||||
//! Select a bar preset (currently modulo 9).
|
||||
void setPreset(int preset);
|
||||
|
||||
//! Set the modulation (vibrato) depth.
|
||||
void setModulationDepth(MY_FLOAT mDepth);
|
||||
void setModulationDepth(StkFloat mDepth);
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,22 +6,25 @@
|
||||
modulations to give a nice, natural human
|
||||
modulation function.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MODULATE_H)
|
||||
#define __MODULATE_H
|
||||
#ifndef STK_MODULATE_H
|
||||
#define STK_MODULATE_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "Generator.h"
|
||||
#include "WaveLoop.h"
|
||||
#include "SubNoise.h"
|
||||
#include "OnePole.h"
|
||||
|
||||
class Modulate : public Stk
|
||||
class Modulate : public Generator
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError can be thrown if the rawwave path is incorrect.
|
||||
*/
|
||||
Modulate();
|
||||
|
||||
//! Class destructor.
|
||||
@@ -31,30 +34,35 @@ class Modulate : public Stk
|
||||
void reset();
|
||||
|
||||
//! Set the periodic (vibrato) rate or frequency in Hz.
|
||||
void setVibratoRate(MY_FLOAT aRate);
|
||||
void setVibratoRate(StkFloat rate);
|
||||
|
||||
//! Set the periodic (vibrato) gain.
|
||||
void setVibratoGain(MY_FLOAT aGain);
|
||||
void setVibratoGain(StkFloat gain);
|
||||
|
||||
//! Set the random modulation gain.
|
||||
void setRandomGain(MY_FLOAT aGain);
|
||||
void setRandomGain(StkFloat gain);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Return \e vectorSize outputs in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
//! Compute \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
WaveLoop *vibrato;
|
||||
SubNoise *noise;
|
||||
OnePole *filter;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT randomGain;
|
||||
MY_FLOAT lastOutput;
|
||||
WaveLoop *vibrato_;
|
||||
SubNoise noise_;
|
||||
OnePole filter_;
|
||||
StkFloat vibratoGain_;
|
||||
StkFloat randomGain_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
- Vibrato Gain = 1
|
||||
- Gain = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__MOOG_H)
|
||||
#define __MOOG_H
|
||||
#ifndef STK_MOOG_H
|
||||
#define STK_MOOG_H
|
||||
|
||||
#include "Sampler.h"
|
||||
#include "FormSwep.h"
|
||||
@@ -28,34 +28,49 @@ class Moog : public Sampler
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Moog();
|
||||
|
||||
//! Class destructor.
|
||||
~Moog();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Set the modulation (vibrato) speed in Hz.
|
||||
void setModulationSpeed(MY_FLOAT mSpeed);
|
||||
void setModulationSpeed(StkFloat mSpeed);
|
||||
|
||||
//! Set the modulation (vibrato) depth.
|
||||
void setModulationDepth(MY_FLOAT mDepth);
|
||||
void setModulationDepth(StkFloat mDepth);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
FormSwep *filters[2];
|
||||
MY_FLOAT modDepth;
|
||||
MY_FLOAT filterQ;
|
||||
MY_FLOAT filterRate;
|
||||
FormSwep filters_[2];
|
||||
StkFloat modDepth_;
|
||||
StkFloat filterQ_;
|
||||
StkFloat filterRate_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
70
include/Mutex.h
Normal file
70
include/Mutex.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************/
|
||||
/*! \class Mutex
|
||||
\brief STK mutex class.
|
||||
|
||||
This class provides a uniform interface for
|
||||
cross-platform mutex use. On Linux and IRIX
|
||||
systems, the pthread library is used. Under
|
||||
Windows, critical sections are used.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#ifndef STK_MUTEX_H
|
||||
#define STK_MUTEX_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
#if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__))
|
||||
|
||||
#include <pthread.h>
|
||||
typedef pthread_mutex_t MUTEX;
|
||||
typedef pthread_cond_t CONDITION;
|
||||
|
||||
#elif defined(__OS_WINDOWS__)
|
||||
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
typedef CRITICAL_SECTION MUTEX;
|
||||
typedef HANDLE CONDITION;
|
||||
|
||||
#endif
|
||||
|
||||
class Mutex : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
Mutex();
|
||||
|
||||
//! Class destructor.
|
||||
~Mutex();
|
||||
|
||||
//! Lock the mutex.
|
||||
void lock(void);
|
||||
|
||||
//! Unlock the mutex.
|
||||
void unlock(void);
|
||||
|
||||
//! Wait indefinitely on the mutex condition variable.
|
||||
/*!
|
||||
The mutex must be locked before calling this function, and then
|
||||
subsequently unlocked after this function returns.
|
||||
*/
|
||||
void wait(void);
|
||||
|
||||
//! Signal the condition variable.
|
||||
/*!
|
||||
The mutex must be locked before calling this function, and then
|
||||
subsequently unlocked after this function returns.
|
||||
*/
|
||||
void signal(void);
|
||||
|
||||
protected:
|
||||
|
||||
MUTEX mutex_;
|
||||
CONDITION condition_;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -12,21 +12,21 @@
|
||||
filters in parallel with corresponding right
|
||||
and left outputs.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__NREV_H)
|
||||
#define __NREV_H
|
||||
#ifndef STK_NREV_H
|
||||
#define STK_NREV_H
|
||||
|
||||
#include "Reverb.h"
|
||||
#include "Effect.h"
|
||||
#include "Delay.h"
|
||||
|
||||
class NRev : public Reverb
|
||||
class NRev : public Effect
|
||||
{
|
||||
public:
|
||||
//! Class constructor taking a T60 decay time argument.
|
||||
NRev(MY_FLOAT T60);
|
||||
//! Class constructor taking a T60 decay time argument (one second default value).
|
||||
NRev( StkFloat T60 = 1.0 );
|
||||
|
||||
//! Class destructor.
|
||||
~NRev();
|
||||
@@ -34,15 +34,30 @@ class NRev : public Reverb
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set the reverberation T60 decay time.
|
||||
void setT60( StkFloat T60 );
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
StkFloat tick(StkFloat input);
|
||||
|
||||
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
Delay *allpassDelays[8];
|
||||
Delay *combDelays[6];
|
||||
MY_FLOAT allpassCoefficient;
|
||||
MY_FLOAT combCoefficient[6];
|
||||
MY_FLOAT lowpassState;
|
||||
Delay allpassDelays_[8];
|
||||
Delay combDelays_[6];
|
||||
StkFloat allpassCoefficient_;
|
||||
StkFloat combCoefficient_[6];
|
||||
StkFloat lowpassState_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
C rand() function. The quality of the rand()
|
||||
function varies from one OS to another.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__NOISE_H)
|
||||
#define __NOISE_H
|
||||
#ifndef STK_NOISE_H
|
||||
#define STK_NOISE_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "Generator.h"
|
||||
|
||||
class Noise : public Stk
|
||||
class Noise : public Generator
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -40,17 +40,21 @@ public:
|
||||
void setSeed( unsigned int seed = 0 );
|
||||
|
||||
//! Return a random number between -1.0 and 1.0 using rand().
|
||||
virtual MY_FLOAT tick();
|
||||
virtual StkFloat tick();
|
||||
|
||||
//! Return \e vectorSize random numbers between -1.0 and 1.0 in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
//! Compute \e vectorSize outputs and return them in \e vector.
|
||||
virtual StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Return the last computed value.
|
||||
MY_FLOAT lastOut() const;
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
|
||||
MY_FLOAT lastOutput;
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
the real axis of the z-plane while maintaining
|
||||
a constant peak filter gain.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ONEPOLE_H)
|
||||
#define __ONEPOLE_H
|
||||
#ifndef STK_ONEPOLE_H
|
||||
#define STK_ONEPOLE_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
OnePole();
|
||||
|
||||
//! Overloaded constructor which sets the pole position during instantiation.
|
||||
OnePole(MY_FLOAT thePole);
|
||||
OnePole(StkFloat thePole);
|
||||
|
||||
//! Class destructor.
|
||||
~OnePole();
|
||||
@@ -34,10 +34,10 @@ public:
|
||||
void clear(void);
|
||||
|
||||
//! Set the b[0] coefficient value.
|
||||
void setB0(MY_FLOAT b0);
|
||||
void setB0(StkFloat b0);
|
||||
|
||||
//! Set the a[1] coefficient value.
|
||||
void setA1(MY_FLOAT a1);
|
||||
void setA1(StkFloat a1);
|
||||
|
||||
//! Set the pole position in the z-plane.
|
||||
/*!
|
||||
@@ -47,26 +47,36 @@ public:
|
||||
pole value produces a high-pass filter. This method does not
|
||||
affect the filter \e gain value.
|
||||
*/
|
||||
void setPole(MY_FLOAT thePole);
|
||||
void setPole(StkFloat thePole);
|
||||
|
||||
//! Set the filter gain.
|
||||
/*!
|
||||
The gain is applied at the filter input and does not affect the
|
||||
coefficient values. The default gain value is 1.0.
|
||||
*/
|
||||
void setGain(MY_FLOAT theGain);
|
||||
void setGain(StkFloat gain);
|
||||
|
||||
//! Return the current filter gain.
|
||||
MY_FLOAT getGain(void) const;
|
||||
StkFloat getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
StkFloat lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
StkFloat tick(StkFloat sample);
|
||||
|
||||
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
along the real axis of the z-plane while
|
||||
maintaining a constant filter gain.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__ONEZERO_H)
|
||||
#define __ONEZERO_H
|
||||
#ifndef STK_ONEZERO_H
|
||||
#define STK_ONEZERO_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
@@ -25,7 +25,7 @@ class OneZero : protected Filter
|
||||
OneZero();
|
||||
|
||||
//! Overloaded constructor which sets the zero position during instantiation.
|
||||
OneZero(MY_FLOAT theZero);
|
||||
OneZero(StkFloat theZero);
|
||||
|
||||
//! Class destructor.
|
||||
~OneZero();
|
||||
@@ -34,10 +34,10 @@ class OneZero : protected Filter
|
||||
void clear(void);
|
||||
|
||||
//! Set the b[0] coefficient value.
|
||||
void setB0(MY_FLOAT b0);
|
||||
void setB0(StkFloat b0);
|
||||
|
||||
//! Set the b[1] coefficient value.
|
||||
void setB1(MY_FLOAT b1);
|
||||
void setB1(StkFloat b1);
|
||||
|
||||
//! Set the zero position in the z-plane.
|
||||
/*!
|
||||
@@ -47,26 +47,36 @@ class OneZero : protected Filter
|
||||
negative zero value produces a low-pass filter. This method does
|
||||
not affect the filter \e gain value.
|
||||
*/
|
||||
void setZero(MY_FLOAT theZero);
|
||||
void setZero(StkFloat theZero);
|
||||
|
||||
//! Set the filter gain.
|
||||
/*!
|
||||
The gain is applied at the filter input and does not affect the
|
||||
coefficient values. The default gain value is 1.0.
|
||||
*/
|
||||
void setGain(MY_FLOAT theGain);
|
||||
void setGain(StkFloat gain);
|
||||
|
||||
//! Return the current filter gain.
|
||||
MY_FLOAT getGain(void) const;
|
||||
StkFloat getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
StkFloat lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
StkFloat tick(StkFloat sample);
|
||||
|
||||
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,21 +10,21 @@
|
||||
two series allpass units and two parallel comb
|
||||
filters.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PRCREV_H)
|
||||
#define __PRCREV_H
|
||||
#ifndef STK_PRCREV_H
|
||||
#define STK_PRCREV_H
|
||||
|
||||
#include "Reverb.h"
|
||||
#include "Effect.h"
|
||||
#include "Delay.h"
|
||||
|
||||
class PRCRev : public Reverb
|
||||
class PRCRev : public Effect
|
||||
{
|
||||
public:
|
||||
//! Class constructor taking a T60 decay time argument.
|
||||
PRCRev(MY_FLOAT T60);
|
||||
//! Class constructor taking a T60 decay time argument (one second default value).
|
||||
PRCRev( StkFloat T60 = 1.0 );
|
||||
|
||||
//! Class destructor.
|
||||
~PRCRev();
|
||||
@@ -32,14 +32,29 @@ public:
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
|
||||
//! Set the reverberation T60 decay time.
|
||||
void setT60( StkFloat T60 );
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
StkFloat tick(StkFloat input);
|
||||
|
||||
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
Delay *allpassDelays[2];
|
||||
Delay *combDelays[2];
|
||||
MY_FLOAT allpassCoefficient;
|
||||
MY_FLOAT combCoefficient[2];
|
||||
Delay allpassDelays_[2];
|
||||
Delay combDelays_[2];
|
||||
StkFloat allpassCoefficient_;
|
||||
StkFloat combCoefficient_[2];
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PERCFLUT_H)
|
||||
#define __PERCFLUT_H
|
||||
#ifndef STK_PERCFLUT_H
|
||||
#define STK_PERCFLUT_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
@@ -35,19 +35,34 @@ class PercFlut : public FM
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
PercFlut();
|
||||
|
||||
//! Class destructor.
|
||||
~PercFlut();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
set of 32 static phoneme formant parameters
|
||||
and provide access to those values.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PHONEMES_H)
|
||||
#define __PHONEMES_H
|
||||
#ifndef STK_PHONEMES_H
|
||||
#define STK_PHONEMES_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class Phonemes
|
||||
class Phonemes : public Stk
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -26,26 +26,25 @@ public:
|
||||
static const char *name( unsigned int index );
|
||||
|
||||
//! Returns the voiced component gain for the given phoneme index (0-31).
|
||||
static MY_FLOAT voiceGain( unsigned int index );
|
||||
static StkFloat voiceGain( unsigned int index );
|
||||
|
||||
//! Returns the unvoiced component gain for the given phoneme index (0-31).
|
||||
static MY_FLOAT noiseGain( unsigned int index );
|
||||
static StkFloat noiseGain( unsigned int index );
|
||||
|
||||
//! Returns the formant frequency for the given phoneme index (0-31) and partial (0-3).
|
||||
static MY_FLOAT formantFrequency( unsigned int index, unsigned int partial );
|
||||
static StkFloat formantFrequency( unsigned int index, unsigned int partial );
|
||||
|
||||
//! Returns the formant radius for the given phoneme index (0-31) and partial (0-3).
|
||||
static MY_FLOAT formantRadius( unsigned int index, unsigned int partial );
|
||||
static StkFloat formantRadius( unsigned int index, unsigned int partial );
|
||||
|
||||
//! Returns the formant gain for the given phoneme index (0-31) and partial (0-3).
|
||||
static MY_FLOAT formantGain( unsigned int index, unsigned int partial );
|
||||
static StkFloat formantGain( unsigned int index, unsigned int partial );
|
||||
|
||||
private:
|
||||
|
||||
static const char phonemeNames[][4];
|
||||
static const MY_FLOAT phonemeGains[][2];
|
||||
static const MY_FLOAT phonemeParameters[][4][3];
|
||||
|
||||
static const StkFloat phonemeGains[][2];
|
||||
static const StkFloat phonemeParameters[][4][3];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
This class implements a simple pitch shifter
|
||||
using delay lines.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PITSHIFT_H)
|
||||
#define __PITSHIFT_H
|
||||
#ifndef STK_PITSHIFT_H
|
||||
#define STK_PITSHIFT_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "Effect.h"
|
||||
#include "DelayL.h"
|
||||
|
||||
class PitShift : public Stk
|
||||
class PitShift : public Effect
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
@@ -28,27 +28,30 @@ class PitShift : public Stk
|
||||
void clear();
|
||||
|
||||
//! Set the pitch shift factor (1.0 produces no shift).
|
||||
void setShift(MY_FLOAT shift);
|
||||
|
||||
//! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only).
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
void setShift(StkFloat shift);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
StkFloat tick(StkFloat input);
|
||||
|
||||
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
DelayL *delayLine[2];
|
||||
MY_FLOAT lastOutput;
|
||||
MY_FLOAT delay[2];
|
||||
MY_FLOAT env[2];
|
||||
MY_FLOAT effectMix;
|
||||
MY_FLOAT rate;
|
||||
DelayL delayLine_[2];
|
||||
StkFloat delay_[2];
|
||||
StkFloat env_[2];
|
||||
StkFloat rate_;
|
||||
unsigned long delayLength;
|
||||
unsigned long halfLength;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
use possibly subject to patents held by
|
||||
Stanford University, Yamaha, and others.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PLUCKTWO_H)
|
||||
#define __PLUCKTWO_H
|
||||
#ifndef STK_PLUCKTWO_H
|
||||
#define STK_PLUCKTWO_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
@@ -30,7 +30,7 @@ class PluckTwo : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
PluckTwo(MY_FLOAT lowestFrequency);
|
||||
PluckTwo(StkFloat lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~PluckTwo();
|
||||
@@ -39,16 +39,16 @@ class PluckTwo : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
virtual void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Detune the two strings by the given factor. A value of 1.0 produces unison strings.
|
||||
void setDetune(MY_FLOAT detune);
|
||||
void setDetune(StkFloat detune);
|
||||
|
||||
//! Efficient combined setting of frequency and detuning.
|
||||
void setFreqAndDetune(MY_FLOAT frequency, MY_FLOAT detune);
|
||||
void setFreqAndDetune(StkFloat frequency, StkFloat detune);
|
||||
|
||||
//! Set the pluck or "excitation" position along the string (0.0 - 1.0).
|
||||
void setPluckPosition(MY_FLOAT position);
|
||||
void setPluckPosition(StkFloat position);
|
||||
|
||||
//! Set the base loop gain.
|
||||
/*!
|
||||
@@ -56,28 +56,41 @@ class PluckTwo : public Instrmnt
|
||||
Because of high-frequency loop filter roll-off, higher
|
||||
frequency settings have greater loop gains.
|
||||
*/
|
||||
void setBaseLoopGain(MY_FLOAT aGain);
|
||||
void setBaseLoopGain(StkFloat aGain);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
virtual void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Virtual (abstract) tick function is implemented by subclasses.
|
||||
virtual MY_FLOAT tick() = 0;
|
||||
virtual StkFloat tick() = 0;
|
||||
|
||||
protected:
|
||||
DelayA *delayLine;
|
||||
DelayA *delayLine2;
|
||||
DelayL *combDelay;
|
||||
OneZero *filter;
|
||||
OneZero *filter2;
|
||||
long length;
|
||||
MY_FLOAT loopGain;
|
||||
MY_FLOAT baseLoopGain;
|
||||
MY_FLOAT lastFrequency;
|
||||
MY_FLOAT lastLength;
|
||||
MY_FLOAT detuning;
|
||||
MY_FLOAT pluckAmplitude;
|
||||
MY_FLOAT pluckPosition;
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize) = 0;
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 ) = 0;
|
||||
|
||||
protected:
|
||||
DelayA delayLine_;
|
||||
DelayA delayLine2_;
|
||||
DelayL combDelay_;
|
||||
OneZero filter_;
|
||||
OneZero filter2_;
|
||||
|
||||
unsigned long length_;
|
||||
StkFloat loopGain_;
|
||||
StkFloat baseLoopGain_;
|
||||
StkFloat lastFrequency_;
|
||||
StkFloat lastLength_;
|
||||
StkFloat detuning_;
|
||||
StkFloat pluckAmplitude_;
|
||||
StkFloat pluckPosition_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
Stanford, bearing the names of Karplus and/or
|
||||
Strong.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__PLUCKED_H)
|
||||
#define __PLUCKED_H
|
||||
#ifndef STK_PLUCKED_H
|
||||
#define STK_PLUCKED_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayA.h"
|
||||
@@ -30,7 +30,7 @@ class Plucked : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Plucked(MY_FLOAT lowestFrequency);
|
||||
Plucked(StkFloat lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Plucked();
|
||||
@@ -39,27 +39,39 @@ class Plucked : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
virtual void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Pluck the string with the given amplitude using the current frequency.
|
||||
void pluck(MY_FLOAT amplitude);
|
||||
void pluck(StkFloat amplitude);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
virtual void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
virtual void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
virtual StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
protected:
|
||||
DelayA *delayLine;
|
||||
OneZero *loopFilter;
|
||||
OnePole *pickFilter;
|
||||
Noise *noise;
|
||||
long length;
|
||||
MY_FLOAT loopGain;
|
||||
DelayA delayLine_;
|
||||
OneZero loopFilter_;
|
||||
OnePole pickFilter_;
|
||||
Noise noise_;
|
||||
StkFloat loopGain_;
|
||||
unsigned long length_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
filter with a given coefficient. Another
|
||||
method is provided to create a DC blocking filter.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__POLEZERO_H)
|
||||
#define __POLEZERO_H
|
||||
#ifndef STK_POLEZERO_H
|
||||
#define STK_POLEZERO_H
|
||||
|
||||
#include "Filter.h"
|
||||
|
||||
@@ -31,13 +31,13 @@ class PoleZero : protected Filter
|
||||
void clear(void);
|
||||
|
||||
//! Set the b[0] coefficient value.
|
||||
void setB0(MY_FLOAT b0);
|
||||
void setB0(StkFloat b0);
|
||||
|
||||
//! Set the b[1] coefficient value.
|
||||
void setB1(MY_FLOAT b1);
|
||||
void setB1(StkFloat b1);
|
||||
|
||||
//! Set the a[1] coefficient value.
|
||||
void setA1(MY_FLOAT a1);
|
||||
void setA1(StkFloat a1);
|
||||
|
||||
//! Set the filter for allpass behavior using \e coefficient.
|
||||
/*!
|
||||
@@ -45,7 +45,7 @@ class PoleZero : protected Filter
|
||||
which has unity gain at all frequencies. Note that the \e
|
||||
coefficient magnitude must be less than one to maintain stability.
|
||||
*/
|
||||
void setAllpass(MY_FLOAT coefficient);
|
||||
void setAllpass(StkFloat coefficient);
|
||||
|
||||
//! Create a DC blocking filter with the given pole position in the z-plane.
|
||||
/*!
|
||||
@@ -54,26 +54,36 @@ class PoleZero : protected Filter
|
||||
close to one to minimize low-frequency attenuation.
|
||||
|
||||
*/
|
||||
void setBlockZero(MY_FLOAT thePole = 0.99);
|
||||
void setBlockZero(StkFloat thePole = 0.99);
|
||||
|
||||
//! Set the filter gain.
|
||||
/*!
|
||||
The gain is applied at the filter input and does not affect the
|
||||
coefficient values. The default gain value is 1.0.
|
||||
*/
|
||||
void setGain(MY_FLOAT theGain);
|
||||
void setGain(StkFloat gain);
|
||||
|
||||
//! Return the current filter gain.
|
||||
MY_FLOAT getGain(void) const;
|
||||
StkFloat getGain(void) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
StkFloat lastOut(void) const;
|
||||
|
||||
//! Input one sample to the filter and return one output.
|
||||
MY_FLOAT tick(MY_FLOAT sample);
|
||||
StkFloat tick(StkFloat sample);
|
||||
|
||||
//! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************/
|
||||
/*! \class ReedTabl
|
||||
/*! \class ReedTable
|
||||
\brief STK reed table class.
|
||||
|
||||
This class implements a simple one breakpoint,
|
||||
@@ -13,23 +13,23 @@
|
||||
Smith (1986), Hirschman, Cook, Scavone, and
|
||||
others for more information.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__REEDTABL_H)
|
||||
#define __REEDTABL_H
|
||||
#ifndef STK_REEDTABLE_H
|
||||
#define STK_REEDTABLE_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "Function.h"
|
||||
|
||||
class ReedTabl : public Stk
|
||||
class ReedTable : public Function
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
ReedTabl();
|
||||
ReedTable();
|
||||
|
||||
//! Class destructor.
|
||||
~ReedTabl();
|
||||
~ReedTable();
|
||||
|
||||
//! Set the table offset value.
|
||||
/*!
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
of the initial reed tip opening (a greater offset
|
||||
represents a smaller opening).
|
||||
*/
|
||||
void setOffset(MY_FLOAT aValue);
|
||||
void setOffset(StkFloat offset);
|
||||
|
||||
//! Set the table slope value.
|
||||
/*!
|
||||
@@ -45,25 +45,30 @@ public:
|
||||
stiffness (a greater slope represents a harder
|
||||
reed).
|
||||
*/
|
||||
void setSlope(MY_FLOAT aValue);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
void setSlope(StkFloat slope);
|
||||
|
||||
//! Return the function value for \e input.
|
||||
/*!
|
||||
The function input represents the differential
|
||||
pressure across the reeds.
|
||||
*/
|
||||
MY_FLOAT tick(MY_FLOAT input);
|
||||
StkFloat tick(StkFloat input);
|
||||
|
||||
//! Take \e vectorSize inputs and return the corresponding function values in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
//! Take \e vectorSize inputs from \e vector and replace them with corresponding outputs.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
MY_FLOAT offSet;
|
||||
MY_FLOAT slope;
|
||||
MY_FLOAT lastOutput;
|
||||
StkFloat offset_;
|
||||
StkFloat slope_;
|
||||
|
||||
};
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
- Zero Radii = 1
|
||||
- Envelope Gain = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RESONATE_H)
|
||||
#define __RESONATE_H
|
||||
#ifndef STK_RESONATE_H
|
||||
#define STK_RESONATE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
@@ -38,10 +38,10 @@ class Resonate : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set the filter for a resonance at the given frequency (Hz) and radius.
|
||||
void setResonance(MY_FLOAT frequency, MY_FLOAT radius);
|
||||
void setResonance(StkFloat frequency, StkFloat radius);
|
||||
|
||||
//! Set the filter for a notch at the given frequency (Hz) and radius.
|
||||
void setNotch(MY_FLOAT frequency, MY_FLOAT radius);
|
||||
void setNotch(StkFloat frequency, StkFloat radius);
|
||||
|
||||
//! Set the filter zero coefficients for contant resonance gain.
|
||||
void setEqualGainZeroes();
|
||||
@@ -53,25 +53,37 @@ class Resonate : public Instrmnt
|
||||
void keyOff();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
ADSR *adsr;
|
||||
BiQuad *filter;
|
||||
Noise *noise;
|
||||
MY_FLOAT poleFrequency;
|
||||
MY_FLOAT poleRadius;
|
||||
MY_FLOAT zeroFrequency;
|
||||
MY_FLOAT zeroRadius;
|
||||
ADSR adsr_;
|
||||
BiQuad filter_;
|
||||
Noise noise_;
|
||||
StkFloat poleFrequency_;
|
||||
StkFloat poleRadius_;
|
||||
StkFloat zeroFrequency_;
|
||||
StkFloat zeroRadius_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/***************************************************/
|
||||
/*! \class Reverb
|
||||
\brief STK abstract reverberator parent class.
|
||||
|
||||
This class provides common functionality for
|
||||
STK reverberator subclasses.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
#if !defined(__REVERB_H)
|
||||
#define __REVERB_H
|
||||
|
||||
class Reverb : public Stk
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
Reverb();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Reverb();
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
virtual void clear() = 0;
|
||||
|
||||
//! Set the mixture of input and "reverberated" levels in the output (0.0 = input only, 1.0 = reverb only).
|
||||
void setEffectMix(MY_FLOAT mix);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
|
||||
//! Return the last left output value.
|
||||
MY_FLOAT lastOutLeft() const;
|
||||
|
||||
//! Return the last right output value.
|
||||
MY_FLOAT lastOutRight() const;
|
||||
|
||||
//! Abstract tick function ... must be implemented in subclasses.
|
||||
virtual MY_FLOAT tick(MY_FLOAT input) = 0;
|
||||
|
||||
//! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector.
|
||||
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
protected:
|
||||
|
||||
// Returns true if argument value is prime.
|
||||
bool isPrime(int number);
|
||||
|
||||
MY_FLOAT lastOutput[2];
|
||||
MY_FLOAT effectMix;
|
||||
|
||||
};
|
||||
|
||||
#endif // defined(__REVERB_H)
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
type who should worry about this (making
|
||||
money) worry away.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RHODEY_H)
|
||||
#define __RHODEY_H
|
||||
#ifndef STK_RHODEY_H
|
||||
#define STK_RHODEY_H
|
||||
|
||||
#include "FM.h"
|
||||
|
||||
@@ -39,19 +39,34 @@ class Rhodey : public FM
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Rhodey();
|
||||
|
||||
//! Class destructor.
|
||||
~Rhodey();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
RtAudio WWW site: http://music.mcgill.ca/~gary/rtaudio/
|
||||
|
||||
RtAudio: a realtime audio i/o C++ class
|
||||
RtAudio: realtime audio i/o C++ classes
|
||||
Copyright (c) 2001-2004 Gary P. Scavone
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
@@ -37,7 +37,7 @@
|
||||
*/
|
||||
/************************************************************************/
|
||||
|
||||
// RtAudio: Version 3.0.1, 22 March 2004
|
||||
// RtAudio: Version 3.0.2, pre-release for STK 4.2.0
|
||||
|
||||
#ifndef __RTAUDIO_H
|
||||
#define __RTAUDIO_H
|
||||
@@ -127,17 +127,27 @@ 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;
|
||||
@@ -158,9 +168,13 @@ protected:
|
||||
UNINITIALIZED = -75
|
||||
};
|
||||
|
||||
enum StreamState {
|
||||
STREAM_STOPPED,
|
||||
STREAM_RUNNING
|
||||
// A protected structure used for buffer conversion.
|
||||
struct ConvertInfo {
|
||||
int channels;
|
||||
int inJump, outJump;
|
||||
RtAudioFormat inFormat, outFormat;
|
||||
std::vector<int> inOffset;
|
||||
std::vector<int> outOffset;
|
||||
};
|
||||
|
||||
// A protected structure for audio streams.
|
||||
@@ -183,10 +197,10 @@ protected:
|
||||
RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
|
||||
StreamMutex mutex;
|
||||
CallbackInfo callbackInfo;
|
||||
ConvertInfo convertInfo[2];
|
||||
|
||||
RtApiStream()
|
||||
:apiHandle(0), userBuffer(0), deviceBuffer(0) {}
|
||||
// mode(UNINITIALIZED), state(STREAM_STOPPED),
|
||||
};
|
||||
|
||||
// A protected device structure for audio devices.
|
||||
@@ -217,7 +231,7 @@ protected:
|
||||
typedef float Float32;
|
||||
typedef double Float64;
|
||||
|
||||
char message_[256];
|
||||
char message_[1024];
|
||||
int nDevices_;
|
||||
std::vector<RtApiDevice> devices_;
|
||||
RtApiStream stream_;
|
||||
@@ -281,7 +295,7 @@ protected:
|
||||
Protected method used to perform format, channel number, and/or interleaving
|
||||
conversions between the user and device buffers.
|
||||
*/
|
||||
void convertStreamBuffer( StreamMode mode );
|
||||
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 );
|
||||
@@ -350,6 +364,20 @@ public:
|
||||
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
|
||||
@@ -389,6 +417,20 @@ public:
|
||||
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
|
||||
|
||||
@@ -1,28 +1,35 @@
|
||||
/***************************************************/
|
||||
/*! \class RtDuplex
|
||||
\brief STK realtime audio input/output class.
|
||||
\brief STK realtime audio (blocking) input/output class.
|
||||
|
||||
This class provides a simplified interface to
|
||||
RtAudio for realtime audio input/output. It
|
||||
is also possible to achieve duplex operation
|
||||
using separate RtWvIn and RtWvOut classes, but
|
||||
this class ensures better input/output
|
||||
syncronization.
|
||||
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.
|
||||
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 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RTDUPLEX_H)
|
||||
#define __RTDUPLEX_H
|
||||
#ifndef STK_RTDUPLEX_H
|
||||
#define STK_RTDUPLEX_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "RtAudio.h"
|
||||
@@ -42,7 +49,7 @@ public:
|
||||
is defined in Stk.h. An StkError will be thrown if an error
|
||||
occurs duing instantiation.
|
||||
*/
|
||||
RtDuplex(int nChannels = 1, MY_FLOAT sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
|
||||
RtDuplex(int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
|
||||
|
||||
//! Class destructor.
|
||||
~RtDuplex();
|
||||
@@ -60,34 +67,53 @@ public:
|
||||
void stop(void);
|
||||
|
||||
//! Return the average across the last output sample frame.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
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.
|
||||
*/
|
||||
MY_FLOAT tick(const MY_FLOAT sample);
|
||||
StkFloat tick(const StkFloat sample);
|
||||
|
||||
//! Output each sample in \vector to all channels per frame and return averaged input sample frames of new data in \e vector.
|
||||
//! 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.
|
||||
*/
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
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 MY_FLOAT *lastFrame(void) const;
|
||||
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.
|
||||
*/
|
||||
MY_FLOAT *tickFrame(MY_FLOAT *frameVector, unsigned int frames = 1);
|
||||
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_;
|
||||
MY_FLOAT *data_;
|
||||
MY_FLOAT *lastOutput_;
|
||||
StkFloat *data_;
|
||||
StkFloat *lastOutput_;
|
||||
int bufferSize_;
|
||||
bool stopped_;
|
||||
long counter_;
|
||||
|
||||
@@ -39,7 +39,7 @@ protected:
|
||||
|
||||
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) : message_(message), type_(type) {}
|
||||
|
||||
//! The destructor.
|
||||
virtual ~RtError(void) {};
|
||||
|
||||
310
include/RtMidi.h
310
include/RtMidi.h
@@ -1,80 +1,282 @@
|
||||
/***************************************************/
|
||||
/**********************************************************************/
|
||||
/*! \class RtMidi
|
||||
\brief STK realtime MIDI class.
|
||||
\brief An abstract base class for realtime MIDI input/output.
|
||||
|
||||
At the moment, this object only handles MIDI
|
||||
input, though MIDI output code can go here
|
||||
when someone decides they need it (and writes
|
||||
it).
|
||||
This class implements some common functionality for the realtime
|
||||
MIDI input/output subclasses RtMidiIn and RtMidiOut.
|
||||
|
||||
This object opens a MIDI input device and
|
||||
parses MIDI messages into a MIDI buffer. Time
|
||||
stamp info is converted to a delta-time
|
||||
value. MIDI data is stored as MY_FLOAT to
|
||||
conform with SKINI. System exclusive messages
|
||||
are currently ignored.
|
||||
RtMidi WWW site: http://music.mcgill.ca/~gary/rtmidi/
|
||||
|
||||
An optional argument to the constructor can be
|
||||
used to specify a device or card. When no
|
||||
argument is given, a default device is opened.
|
||||
If a device argument fails, a list of available
|
||||
devices is printed to allow selection by the user.
|
||||
RtMidi: realtime MIDI i/o C++ classes
|
||||
Copyright (c) 2003-2004 Gary P. Scavone
|
||||
|
||||
This code is based in part on work of Perry
|
||||
Cook (SGI), Paul Leonard (Linux), the
|
||||
RoseGarden team (Linux), and Bill Putnam
|
||||
(Windows).
|
||||
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:
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
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
|
||||
requested to send the modifications to the original developer so that
|
||||
they can be incorporated into the canonical version.
|
||||
|
||||
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.
|
||||
*/
|
||||
/***************************************************/
|
||||
/**********************************************************************/
|
||||
|
||||
#if !defined(__RTMIDI_H)
|
||||
#define __RTMIDI_H
|
||||
// RtMidi: Version 1.0.2, 21 September 2004
|
||||
|
||||
#include "Stk.h"
|
||||
#ifndef RTMIDI_H
|
||||
#define RTMIDI_H
|
||||
|
||||
class RtMidi : public Stk
|
||||
#include "RtError.h"
|
||||
#include <string>
|
||||
|
||||
class RtMidi
|
||||
{
|
||||
protected:
|
||||
|
||||
RtMidi();
|
||||
|
||||
virtual ~RtMidi() {};
|
||||
|
||||
// A basic error reporting function for internal use in the RtMidi
|
||||
// subclasses. The behavior of this function can be modified to
|
||||
// suit specific needs.
|
||||
void error( RtError::Type type );
|
||||
|
||||
virtual void openPort( unsigned int portNumber = 0 ) = 0;
|
||||
|
||||
void *apiData_;
|
||||
bool connected_;
|
||||
std::string errorString_;
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
/*! \class RtMidiIn
|
||||
\brief A realtime MIDI input class.
|
||||
|
||||
This class provides a common, platform-independent API for
|
||||
realtime MIDI input. It allows access to a single MIDI input
|
||||
port. Incoming MIDI messages are either saved to a queue for
|
||||
retrieval using the getMessage() function or immediately passed to
|
||||
a user-specified callback function. Create multiple instances of
|
||||
this class to connect to more than one MIDI device at the same
|
||||
time. With the OS-X and Linux ALSA MIDI APIs, it is also possible
|
||||
to open a virtual input port to which other MIDI software clients
|
||||
can connect.
|
||||
|
||||
by Gary P. Scavone, 2003-2004.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
||||
class RtMidiIn : public RtMidi
|
||||
{
|
||||
public:
|
||||
//! Default constructor with optional device argument.
|
||||
RtMidi(int device = 0);
|
||||
|
||||
//! Class destructor.
|
||||
~RtMidi();
|
||||
//! User callback function type definition.
|
||||
typedef void (*RtMidiCallback)( double timeStamp, std::vector<unsigned char> *message, void *userData);
|
||||
|
||||
//! Print out the current message values.
|
||||
void printMessage(void) const;
|
||||
|
||||
//! Check for and parse a new MIDI message in the queue, returning its type.
|
||||
//! Default constructor.
|
||||
/*!
|
||||
If a new message is found, the return value is greater than zero.
|
||||
An exception will be thrown if a MIDI system initialization error occurs.
|
||||
*/
|
||||
int nextMessage(void);
|
||||
RtMidiIn();
|
||||
|
||||
//! Return the current message type.
|
||||
int getType() const;
|
||||
//! If a MIDI connection is still open, it will be closed by the destructor.
|
||||
~RtMidiIn();
|
||||
|
||||
//! Return the current message channel value.
|
||||
int getChannel() const;
|
||||
//! Open a MIDI input connection.
|
||||
/*!
|
||||
An optional port number greater than 0 can be specified.
|
||||
Otherwise, the default or first port found is opened.
|
||||
*/
|
||||
void openPort( unsigned int portNumber = 0 );
|
||||
|
||||
//! Return the current message byte two value.
|
||||
MY_FLOAT getByteTwo() const;
|
||||
//! Create a virtual input port to allow software connections (OS X and ALSA only).
|
||||
/*!
|
||||
This function creates a virtual MIDI input port to which other
|
||||
software applications can connect. This type of functionality
|
||||
is currently only supported by the Macintosh OS-X and Linux ALSA
|
||||
APIs (the function does nothing for the other APIs).
|
||||
*/
|
||||
void openVirtualPort();
|
||||
|
||||
//! Return the current message byte three value.
|
||||
MY_FLOAT getByteThree() const;
|
||||
//! Set a callback function to be invoked for incoming MIDI messages.
|
||||
/*!
|
||||
The callback function will be called whenever an incoming MIDI
|
||||
message is received. While not absolutely necessary, it is best
|
||||
to set the callback function before opening a MIDI port to avoid
|
||||
leaving some messages in the queue.
|
||||
*/
|
||||
void setCallback( RtMidiCallback callback, void *userData = 0 );
|
||||
|
||||
//! Return the current message delta time value in seconds.
|
||||
MY_FLOAT getDeltaTime() const;
|
||||
//! Cancel use of the current callback function (if one exists).
|
||||
/*!
|
||||
Subsequent incoming MIDI messages will be written to the queue
|
||||
and can be retrieved with the \e getMessage function.
|
||||
*/
|
||||
void cancelCallback();
|
||||
|
||||
protected:
|
||||
int messageType;
|
||||
int channel;
|
||||
float byteTwo;
|
||||
float byteThree;
|
||||
MY_FLOAT deltaTime;
|
||||
int readIndex;
|
||||
//! Close an open MIDI connection (if one exists).
|
||||
void closePort( void );
|
||||
|
||||
//! Return the number of available MIDI input ports.
|
||||
unsigned int getPortCount();
|
||||
|
||||
//! Return a string identifier for the specified MIDI input port number.
|
||||
/*!
|
||||
An exception is thrown if an invalid port specifier is provided.
|
||||
*/
|
||||
std::string getPortName( unsigned int portNumber = 0 );
|
||||
|
||||
//! Set the maximum number of MIDI messages to be saved in the queue.
|
||||
/*!
|
||||
If the queue size limit is reached, incoming messages will be
|
||||
ignored. The default limit is 1024.
|
||||
*/
|
||||
void setQueueSizeLimit( unsigned int queueSize );
|
||||
|
||||
//! Specify whether certain MIDI message types should be queued or ignored during input.
|
||||
/*!
|
||||
By default, MIDI timing and active sensing messages are ignored
|
||||
during message input because of their relative high data rates.
|
||||
MIDI sysex messages are ignored by default as well. Variable
|
||||
values of "true" imply that the respective message type will be
|
||||
ignored.
|
||||
*/
|
||||
void ignoreTypes( bool midiSysex = true, bool midiTime = true, bool midiSense = true );
|
||||
|
||||
//! Fill the user-provided vector with the data bytes for the next available MIDI message in the input queue and return the event delta-time in seconds.
|
||||
/*!
|
||||
This function returns immediately whether a new message is
|
||||
available or not. A valid message is indicated by a non-zero
|
||||
vector size. An exception is thrown if an error occurs during
|
||||
message retrieval or an input connection was not previously
|
||||
established.
|
||||
*/
|
||||
double getMessage( std::vector<unsigned char> *message );
|
||||
|
||||
// A MIDI structure used internally by the class to store incoming
|
||||
// messages. Each message represents one and only one MIDI message.
|
||||
struct MidiMessage {
|
||||
std::vector<unsigned char> bytes;
|
||||
double timeStamp;
|
||||
|
||||
// Default constructor.
|
||||
MidiMessage()
|
||||
:bytes(3), timeStamp(0.0) {}
|
||||
};
|
||||
|
||||
// The RtMidiInData structure is used to pass private class data to
|
||||
// the MIDI input handling function or thread.
|
||||
struct RtMidiInData {
|
||||
std::queue<MidiMessage> queue;
|
||||
unsigned int queueLimit;
|
||||
unsigned char ignoreFlags;
|
||||
bool doInput;
|
||||
bool firstMessage;
|
||||
void *apiData;
|
||||
bool usingCallback;
|
||||
void *userCallback;
|
||||
void *userData;
|
||||
|
||||
// Default constructor.
|
||||
RtMidiInData()
|
||||
: queueLimit(1024), ignoreFlags(7), doInput(false), firstMessage(true),
|
||||
apiData(0), usingCallback(false), userCallback(0), userData(0) {}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
void initialize( void );
|
||||
RtMidiInData inputData_;
|
||||
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
/*! \class RtMidiOut
|
||||
\brief A realtime MIDI output class.
|
||||
|
||||
This class provides a common, platform-independent API for MIDI
|
||||
output. It allows one to probe available MIDI output ports, to
|
||||
connect to one such port, and to send MIDI bytes immediately over
|
||||
the connection. Create multiple instances of this class to
|
||||
connect to more than one MIDI device at the same time.
|
||||
|
||||
by Gary P. Scavone, 2003-2004.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
|
||||
class RtMidiOut : public RtMidi
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
/*!
|
||||
An exception will be thrown if a MIDI system initialization error occurs.
|
||||
*/
|
||||
RtMidiOut();
|
||||
|
||||
//! The destructor closes any open MIDI connections.
|
||||
~RtMidiOut();
|
||||
|
||||
//! Open a MIDI output connection.
|
||||
/*!
|
||||
An optional port number greater than 0 can be specified.
|
||||
Otherwise, the default or first port found is opened. An
|
||||
exception is thrown if an error occurs while attempting to make
|
||||
the port connection.
|
||||
*/
|
||||
void openPort( unsigned int portNumber = 0 );
|
||||
|
||||
//! Close an open MIDI connection (if one exists).
|
||||
void closePort();
|
||||
|
||||
//! Create a virtual output port to allow software connections (OS X and ALSA only).
|
||||
/*!
|
||||
This function creates a virtual MIDI output port to which other
|
||||
software applications can connect. This type of functionality
|
||||
is currently only supported by the Macintosh OS-X and Linux ALSA
|
||||
APIs (the function does nothing with the other APIs). An
|
||||
exception is thrown if an error occurs while attempting to create
|
||||
the virtual port.
|
||||
*/
|
||||
void openVirtualPort();
|
||||
|
||||
//! Return the number of available MIDI output ports.
|
||||
unsigned int getPortCount();
|
||||
|
||||
//! Return a string identifier for the specified MIDI port type and number.
|
||||
/*!
|
||||
An exception is thrown if an invalid port specifier is provided.
|
||||
*/
|
||||
std::string getPortName( unsigned int portNumber );
|
||||
|
||||
//! Immediately send a single message out an open MIDI output port.
|
||||
/*!
|
||||
An exception is thrown if an error occurs during output or an
|
||||
output connection was not previously established.
|
||||
*/
|
||||
void sendMessage( std::vector<unsigned char> *message );
|
||||
|
||||
private:
|
||||
|
||||
void initialize( void );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
/***************************************************/
|
||||
/*! \class RtWvIn
|
||||
\brief STK realtime audio input class.
|
||||
\brief STK realtime audio (blocking) input class.
|
||||
|
||||
This class provides a simplified interface to
|
||||
RtAudio for realtime audio input. It is a
|
||||
protected subclass of WvIn.
|
||||
protected 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).
|
||||
|
||||
RtWvIn supports multi-channel data in
|
||||
interleaved format. It is important to
|
||||
@@ -15,14 +19,13 @@
|
||||
For single-channel data, these methods return
|
||||
equivalent values.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RTWVIN_H)
|
||||
#define __RTWVIN_H
|
||||
#ifndef STK_RTWVIN_H
|
||||
#define STK_RTWVIN_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include "WvIn.h"
|
||||
#include "RtAudio.h"
|
||||
|
||||
@@ -41,7 +44,7 @@ public:
|
||||
is defined in Stk.h. An StkError will be thrown if an error
|
||||
occurs duing instantiation.
|
||||
*/
|
||||
RtWvIn(int nChannels = 1, MY_FLOAT sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
|
||||
RtWvIn(int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
|
||||
|
||||
//! Class destructor.
|
||||
~RtWvIn();
|
||||
@@ -59,34 +62,51 @@ public:
|
||||
void stop(void);
|
||||
|
||||
//! Return the average across the last output sample frame.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
StkFloat lastOut(void) const;
|
||||
|
||||
//! Read out the average across one sample frame of data.
|
||||
/*!
|
||||
An StkError will be thrown if an error occurs during input.
|
||||
*/
|
||||
MY_FLOAT tick(void);
|
||||
StkFloat tick(void);
|
||||
|
||||
//! Read out vectorSize averaged sample frames of data in \e vector.
|
||||
/*!
|
||||
An StkError will be thrown if an error occurs during input.
|
||||
*/
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with averaged sample frames.
|
||||
/*!
|
||||
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 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 MY_FLOAT *lastFrame(void) const;
|
||||
const StkFloat *lastFrame(void) const;
|
||||
|
||||
//! Return a pointer to the next sample frame of data.
|
||||
/*!
|
||||
An StkError will be thrown if an error occurs during input.
|
||||
*/
|
||||
const MY_FLOAT *tickFrame(void);
|
||||
const StkFloat *tickFrame(void);
|
||||
|
||||
//! Read out sample \e frames of data to \e frameVector.
|
||||
/*!
|
||||
An StkError will be thrown if an error occurs during input.
|
||||
*/
|
||||
MY_FLOAT *tickFrame(MY_FLOAT *frameVector, unsigned int frames);
|
||||
StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames);
|
||||
|
||||
//! Fill the StkFrames object with sample frames of data and return the same reference.
|
||||
/*!
|
||||
An StkError will be thrown if an error occurs during input or
|
||||
there is an incompatability between the number of channels in the
|
||||
RtWvIn object and that in the StkFrames object.
|
||||
*/
|
||||
StkFrames& tickFrame( StkFrames& frames );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
/***************************************************/
|
||||
/*! \class RtWvOut
|
||||
\brief STK realtime audio output class.
|
||||
\brief STK realtime audio (blocking) output class.
|
||||
|
||||
This class provides a simplified interface to
|
||||
RtAudio for realtime audio output. It is a
|
||||
protected subclass of WvOut.
|
||||
protected 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).
|
||||
|
||||
RtWvOut supports multi-channel data in
|
||||
interleaved format. It is important to
|
||||
@@ -14,16 +18,15 @@
|
||||
takes a pointer to multi-channel sample
|
||||
frame data.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RTWVOUT_H)
|
||||
#define __RTWVOUT_H
|
||||
#ifndef STK_RTWVOUT_H
|
||||
#define STK_RTWVOUT_H
|
||||
|
||||
#include "WvOut.h"
|
||||
#include "RtAudio.h"
|
||||
#include "Thread.h"
|
||||
|
||||
class RtWvOut : protected WvOut
|
||||
{
|
||||
@@ -41,7 +44,7 @@ class RtWvOut : protected WvOut
|
||||
is defined in Stk.h. An StkError will be thrown if an error
|
||||
occurs duing instantiation.
|
||||
*/
|
||||
RtWvOut(unsigned int nChannels = 1, MY_FLOAT sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 4 );
|
||||
RtWvOut(unsigned int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 4 );
|
||||
|
||||
//! Class destructor.
|
||||
~RtWvOut();
|
||||
@@ -62,32 +65,50 @@ class RtWvOut : protected WvOut
|
||||
unsigned long getFrames( void ) const;
|
||||
|
||||
//! Return the number of seconds of data output.
|
||||
MY_FLOAT getTime( void ) const;
|
||||
StkFloat getTime( void ) const;
|
||||
|
||||
//! Output a single sample to all channels in a sample frame.
|
||||
/*!
|
||||
An StkError will be thrown if an error occurs during output.
|
||||
*/
|
||||
void tick(const MY_FLOAT sample);
|
||||
void tick( const StkFloat sample );
|
||||
|
||||
//! Output each sample in \e vector to all channels in \e vectorSize sample frames.
|
||||
/*!
|
||||
An StkError will be thrown if an error occurs during output.
|
||||
*/
|
||||
void tick(const MY_FLOAT *vector, unsigned int vectorSize);
|
||||
void tick( const StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Output a channel of the StkFrames object to all channels of the RtWvOut object.
|
||||
/*!
|
||||
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 output or the \c channel argument is zero or
|
||||
it is greater than the number of channels in the StkFrames object.
|
||||
*/
|
||||
void tick( const StkFrames& frames, unsigned int channel = 1 );
|
||||
|
||||
//! Output the \e frameVector of sample frames of the given length.
|
||||
/*!
|
||||
An StkError will be thrown if an error occurs during output.
|
||||
*/
|
||||
void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1);
|
||||
void tickFrame( const StkFloat *frameVector, unsigned int frames = 1 );
|
||||
|
||||
//! Output the StkFrames data to the RtWvOut object.
|
||||
/*!
|
||||
An StkError will be thrown if an error occurs during output or
|
||||
if there is an incompatability between the number of channels in
|
||||
the WvOut object and that in the StkFrames object.
|
||||
*/
|
||||
void tickFrame( const StkFrames& frames );
|
||||
|
||||
protected:
|
||||
|
||||
RtAudio *audio_;
|
||||
RtAudio *audio_;
|
||||
StkFloat *dataPtr_;
|
||||
bool stopped_;
|
||||
int bufferSize_;
|
||||
|
||||
};
|
||||
|
||||
#endif // defined(__RTWVOUT_H)
|
||||
#endif
|
||||
|
||||
127
include/SKINI.h
127
include/SKINI.h
@@ -1,127 +0,0 @@
|
||||
/***************************************************/
|
||||
/*! \class SKINI
|
||||
\brief STK SKINI parsing class
|
||||
|
||||
This class parses SKINI formatted text
|
||||
messages. It can be used to parse individual
|
||||
messages or it can be passed an entire file.
|
||||
The file specification is Perry's and his
|
||||
alone, but it's all text so it shouldn't be to
|
||||
hard to figure out.
|
||||
|
||||
SKINI (Synthesis toolKit Instrument Network
|
||||
Interface) is like MIDI, but allows for
|
||||
floating-point control changes, note numbers,
|
||||
etc. The following example causes a sharp
|
||||
middle C to be played with a velocity of 111.132:
|
||||
|
||||
\code
|
||||
noteOn 60.01 111.13
|
||||
\endcode
|
||||
|
||||
\sa \ref skini
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SKINI_H)
|
||||
#define __SKINI_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include <stdio.h>
|
||||
|
||||
class SKINI : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor used for parsing messages received externally.
|
||||
SKINI();
|
||||
|
||||
//! Overloaded constructor taking a SKINI formatted scorefile.
|
||||
SKINI(char *fileName);
|
||||
|
||||
//! Class destructor
|
||||
~SKINI();
|
||||
|
||||
//! Attempt to parse the given string, returning the message type.
|
||||
/*!
|
||||
A type value equal to zero indicates an invalid message.
|
||||
*/
|
||||
long parseThis(char* aString);
|
||||
|
||||
//! Parse the next message (if a file is loaded) and return the message type.
|
||||
/*!
|
||||
A negative value is returned when the file end is reached.
|
||||
*/
|
||||
long nextMessage();
|
||||
|
||||
//! Return the current message type.
|
||||
long getType() const;
|
||||
|
||||
//! Return the current message channel value.
|
||||
long getChannel() const;
|
||||
|
||||
//! Return the current message delta time value (in seconds).
|
||||
MY_FLOAT getDelta() const;
|
||||
|
||||
//! Return the current message byte two value.
|
||||
MY_FLOAT getByteTwo() const;
|
||||
|
||||
//! Return the current message byte three value.
|
||||
MY_FLOAT getByteThree() const;
|
||||
|
||||
//! Return the current message byte two value (integer).
|
||||
long getByteTwoInt() const;
|
||||
|
||||
//! Return the current message byte three value (integer).
|
||||
long getByteThreeInt() const;
|
||||
|
||||
//! Return remainder string after parsing.
|
||||
const char* getRemainderString();
|
||||
|
||||
//! Return the message type as a string.
|
||||
const char* getMessageTypeString();
|
||||
|
||||
//! Return the SKINI type string for the given type value.
|
||||
const char* whatsThisType(long type);
|
||||
|
||||
//! Return the SKINI controller string for the given controller number.
|
||||
const char* whatsThisController(long number);
|
||||
|
||||
protected:
|
||||
|
||||
FILE *myFile;
|
||||
long messageType;
|
||||
char msgTypeString[64];
|
||||
long channel;
|
||||
MY_FLOAT deltaTime;
|
||||
MY_FLOAT byteTwo;
|
||||
MY_FLOAT byteThree;
|
||||
long byteTwoInt;
|
||||
long byteThreeInt;
|
||||
char remainderString[1024];
|
||||
char whatString[1024];
|
||||
};
|
||||
|
||||
static const double Midi2Pitch[129] = {
|
||||
8.18,8.66,9.18,9.72,10.30,10.91,11.56,12.25,
|
||||
12.98,13.75,14.57,15.43,16.35,17.32,18.35,19.45,
|
||||
20.60,21.83,23.12,24.50,25.96,27.50,29.14,30.87,
|
||||
32.70,34.65,36.71,38.89,41.20,43.65,46.25,49.00,
|
||||
51.91,55.00,58.27,61.74,65.41,69.30,73.42,77.78,
|
||||
82.41,87.31,92.50,98.00,103.83,110.00,116.54,123.47,
|
||||
130.81,138.59,146.83,155.56,164.81,174.61,185.00,196.00,
|
||||
207.65,220.00,233.08,246.94,261.63,277.18,293.66,311.13,
|
||||
329.63,349.23,369.99,392.00,415.30,440.00,466.16,493.88,
|
||||
523.25,554.37,587.33,622.25,659.26,698.46,739.99,783.99,
|
||||
830.61,880.00,932.33,987.77,1046.50,1108.73,1174.66,1244.51,
|
||||
1318.51,1396.91,1479.98,1567.98,1661.22,1760.00,1864.66,1975.53,
|
||||
2093.00,2217.46,2349.32,2489.02,2637.02,2793.83,2959.96,3135.96,
|
||||
3322.44,3520.00,3729.31,3951.07,4186.01,4434.92,4698.64,4978.03,
|
||||
5274.04,5587.65,5919.91,6271.93,6644.88,7040.00,7458.62,7902.13,
|
||||
8372.02,8869.84,9397.27,9956.06,10548.08,11175.30,11839.82,12543.85,
|
||||
13289.75};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,22 +3,25 @@
|
||||
Definition of SKINI Message Types and Special Symbols
|
||||
Synthesis toolKit Instrument Network Interface
|
||||
|
||||
These symbols should have the form __SK_<name>_
|
||||
These symbols should have the form:
|
||||
|
||||
Where <name> is the string used in the SKINI stream.
|
||||
\c __SK_<name>_
|
||||
|
||||
by Perry R. Cook, 1995 - 2002.
|
||||
where <name> is the string used in the SKINI stream.
|
||||
|
||||
by Perry R. Cook, 1995 - 2004.
|
||||
*/
|
||||
/*********************************************************/
|
||||
|
||||
/***** MIDI COMPATIBLE MESSAGES *****/
|
||||
/***** Status Bytes Have Channel=0 **/
|
||||
#define NOPE -32767
|
||||
#define YEP 1
|
||||
#define SK_DBL -32766
|
||||
#define SK_INT -32765
|
||||
#define SK_STR -32764
|
||||
#define __SK_Exit_ 999
|
||||
|
||||
#define NOPE -32767
|
||||
#define YEP 1
|
||||
#define SK_DBL -32766
|
||||
#define SK_INT -32765
|
||||
#define SK_STR -32764
|
||||
/***** MIDI COMPATIBLE MESSAGES *****/
|
||||
/*** (Status bytes for channel=0) ***/
|
||||
|
||||
#define __SK_NoteOff_ 128
|
||||
#define __SK_NoteOn_ 144
|
||||
|
||||
@@ -1,128 +1,128 @@
|
||||
|
||||
#include "SKINI.msg"
|
||||
|
||||
#define __SK_MaxMsgTypes_ 128
|
||||
#define __SK_MaxMsgTypes_ 80
|
||||
|
||||
struct SKINISpec { char messageString[32];
|
||||
struct SkiniSpec { char messageString[32];
|
||||
long type;
|
||||
long data2;
|
||||
long data3;
|
||||
};
|
||||
|
||||
/* SEE COMMENT BLOCK AT BOTTOM FOR FIELDS AND USES */
|
||||
/* MessageString ,type, ch?, data2 , data3 */
|
||||
/* SEE COMMENT BLOCK AT BOTTOM FOR FIELDS AND USES */
|
||||
/* MessageString , type, data2, data3 */
|
||||
|
||||
struct SKINISpec skini_msgs[__SK_MaxMsgTypes_] =
|
||||
struct SkiniSpec skini_msgs[__SK_MaxMsgTypes_] =
|
||||
{
|
||||
{"NoteOff" , __SK_NoteOff_, SK_DBL, SK_DBL},
|
||||
{"NoteOn" , __SK_NoteOn_, SK_DBL, SK_DBL},
|
||||
{"PolyPressure" , __SK_PolyPressure_, SK_DBL, SK_DBL},
|
||||
{"ControlChange" , __SK_ControlChange_, SK_INT, SK_DBL},
|
||||
{"ProgramChange" , __SK_ProgramChange_, SK_DBL, SK_DBL},
|
||||
{"AfterTouch" , __SK_AfterTouch_, SK_DBL, NOPE},
|
||||
{"ChannelPressure" ,__SK_ChannelPressure_, SK_DBL, NOPE},
|
||||
{"PitchWheel" , __SK_PitchWheel_, SK_DBL, NOPE},
|
||||
{"PitchBend" , __SK_PitchBend_, SK_DBL, NOPE},
|
||||
{"PitchChange" , __SK_PitchChange_, SK_DBL, NOPE},
|
||||
|
||||
{"Clock" , __SK_Clock_, NOPE, NOPE},
|
||||
{"Undefined" , 249, NOPE, NOPE},
|
||||
{"SongStart" , __SK_SongStart_, NOPE, NOPE},
|
||||
{"Continue" , __SK_Continue_, NOPE, NOPE},
|
||||
{"SongStop" , __SK_SongStop_, NOPE, NOPE},
|
||||
{"Undefined" , 253, NOPE, NOPE},
|
||||
{"ActiveSensing" , __SK_ActiveSensing_, NOPE, NOPE},
|
||||
{"SystemReset" , __SK_SystemReset_, NOPE, NOPE},
|
||||
|
||||
{"Volume" , __SK_ControlChange_, __SK_Volume_ , SK_DBL},
|
||||
{"ModWheel" , __SK_ControlChange_, __SK_ModWheel_ , SK_DBL},
|
||||
{"Modulation" , __SK_ControlChange_, __SK_Modulation_ , SK_DBL},
|
||||
{"Breath" , __SK_ControlChange_, __SK_Breath_ , SK_DBL},
|
||||
{"FootControl" , __SK_ControlChange_, __SK_FootControl_ , SK_DBL},
|
||||
{"Portamento" , __SK_ControlChange_, __SK_Portamento_ , SK_DBL},
|
||||
{"Balance" , __SK_ControlChange_, __SK_Balance_ , SK_DBL},
|
||||
{"Pan" , __SK_ControlChange_, __SK_Pan_ , SK_DBL},
|
||||
{"Sustain" , __SK_ControlChange_, __SK_Sustain_ , SK_DBL},
|
||||
{"Damper" , __SK_ControlChange_, __SK_Damper_ , SK_DBL},
|
||||
{"Expression" , __SK_ControlChange_, __SK_Expression_ , SK_DBL},
|
||||
|
||||
{"NoiseLevel" , __SK_ControlChange_, __SK_NoiseLevel_ , SK_DBL},
|
||||
{"PickPosition" , __SK_ControlChange_, __SK_PickPosition_ , SK_DBL},
|
||||
{"StringDamping" , __SK_ControlChange_, __SK_StringDamping_ , SK_DBL},
|
||||
{"StringDetune" , __SK_ControlChange_, __SK_StringDetune_ , SK_DBL},
|
||||
{"BodySize" , __SK_ControlChange_, __SK_BodySize_ , SK_DBL},
|
||||
{"BowPressure" , __SK_ControlChange_, __SK_BowPressure_ , SK_DBL},
|
||||
{"BowPosition" , __SK_ControlChange_, __SK_BowPosition_ , SK_DBL},
|
||||
{"BowBeta" , __SK_ControlChange_, __SK_BowBeta_ , SK_DBL},
|
||||
{"NoteOff" , __SK_NoteOff_, SK_DBL, SK_DBL},
|
||||
{"NoteOn" , __SK_NoteOn_, SK_DBL, SK_DBL},
|
||||
{"PolyPressure" , __SK_PolyPressure_, SK_DBL, SK_DBL},
|
||||
{"ControlChange" , __SK_ControlChange_, SK_INT, SK_DBL},
|
||||
{"ProgramChange" , __SK_ProgramChange_, SK_DBL, NOPE},
|
||||
{"AfterTouch" , __SK_AfterTouch_, SK_DBL, NOPE},
|
||||
{"ChannelPressure" ,__SK_ChannelPressure_, SK_DBL, NOPE},
|
||||
{"PitchWheel" , __SK_PitchWheel_, SK_DBL, NOPE},
|
||||
{"PitchBend" , __SK_PitchBend_, SK_DBL, NOPE},
|
||||
{"PitchChange" , __SK_PitchChange_, SK_DBL, NOPE},
|
||||
|
||||
{"Clock" , __SK_Clock_, NOPE, NOPE},
|
||||
{"Undefined" , 249, NOPE, NOPE},
|
||||
{"SongStart" , __SK_SongStart_, NOPE, NOPE},
|
||||
{"Continue" , __SK_Continue_, NOPE, NOPE},
|
||||
{"SongStop" , __SK_SongStop_, NOPE, NOPE},
|
||||
{"Undefined" , 253, NOPE, NOPE},
|
||||
{"ActiveSensing" , __SK_ActiveSensing_, NOPE, NOPE},
|
||||
{"SystemReset" , __SK_SystemReset_, NOPE, NOPE},
|
||||
|
||||
{"Volume" , __SK_ControlChange_, __SK_Volume_ , SK_DBL},
|
||||
{"ModWheel" , __SK_ControlChange_, __SK_ModWheel_ , SK_DBL},
|
||||
{"Modulation" , __SK_ControlChange_, __SK_Modulation_ , SK_DBL},
|
||||
{"Breath" , __SK_ControlChange_, __SK_Breath_ , SK_DBL},
|
||||
{"FootControl" , __SK_ControlChange_, __SK_FootControl_ , SK_DBL},
|
||||
{"Portamento" , __SK_ControlChange_, __SK_Portamento_ , SK_DBL},
|
||||
{"Balance" , __SK_ControlChange_, __SK_Balance_ , SK_DBL},
|
||||
{"Pan" , __SK_ControlChange_, __SK_Pan_ , SK_DBL},
|
||||
{"Sustain" , __SK_ControlChange_, __SK_Sustain_ , SK_DBL},
|
||||
{"Damper" , __SK_ControlChange_, __SK_Damper_ , SK_DBL},
|
||||
{"Expression" , __SK_ControlChange_, __SK_Expression_ , SK_DBL},
|
||||
|
||||
{"NoiseLevel" , __SK_ControlChange_, __SK_NoiseLevel_ , SK_DBL},
|
||||
{"PickPosition" , __SK_ControlChange_, __SK_PickPosition_ , SK_DBL},
|
||||
{"StringDamping" , __SK_ControlChange_, __SK_StringDamping_ , SK_DBL},
|
||||
{"StringDetune" , __SK_ControlChange_, __SK_StringDetune_ , SK_DBL},
|
||||
{"BodySize" , __SK_ControlChange_, __SK_BodySize_ , SK_DBL},
|
||||
{"BowPressure" , __SK_ControlChange_, __SK_BowPressure_ , SK_DBL},
|
||||
{"BowPosition" , __SK_ControlChange_, __SK_BowPosition_ , SK_DBL},
|
||||
{"BowBeta" , __SK_ControlChange_, __SK_BowBeta_ , SK_DBL},
|
||||
|
||||
{"ReedStiffness" , __SK_ControlChange_, __SK_ReedStiffness_ , SK_DBL},
|
||||
{"ReedRestPos" , __SK_ControlChange_, __SK_ReedRestPos_ , SK_DBL},
|
||||
{"FluteEmbouchure" , __SK_ControlChange_, __SK_FluteEmbouchure_, SK_DBL},
|
||||
{"LipTension" , __SK_ControlChange_, __SK_LipTension_ , SK_DBL},
|
||||
{"StrikePosition" , __SK_ControlChange_, __SK_StrikePosition_, SK_DBL},
|
||||
{"StickHardness" , __SK_ControlChange_, __SK_StickHardness_ , SK_DBL},
|
||||
{"ReedStiffness" , __SK_ControlChange_, __SK_ReedStiffness_ , SK_DBL},
|
||||
{"ReedRestPos" , __SK_ControlChange_, __SK_ReedRestPos_ , SK_DBL},
|
||||
{"FluteEmbouchure" , __SK_ControlChange_, __SK_FluteEmbouchure_ , SK_DBL},
|
||||
{"LipTension" , __SK_ControlChange_, __SK_LipTension_ , SK_DBL},
|
||||
{"StrikePosition" , __SK_ControlChange_, __SK_StrikePosition_ , SK_DBL},
|
||||
{"StickHardness" , __SK_ControlChange_, __SK_StickHardness_ , SK_DBL},
|
||||
|
||||
{"TrillDepth" , __SK_ControlChange_, __SK_TrillDepth_ , SK_DBL},
|
||||
{"TrillSpeed" , __SK_ControlChange_, __SK_TrillSpeed_ , SK_DBL},
|
||||
{"TrillDepth" , __SK_ControlChange_, __SK_TrillDepth_ , SK_DBL},
|
||||
{"TrillSpeed" , __SK_ControlChange_, __SK_TrillSpeed_ , SK_DBL},
|
||||
|
||||
{"Strumming" , __SK_ControlChange_, __SK_Strumming_ , 127 },
|
||||
{"NotStrumming" , __SK_ControlChange_, __SK_Strumming_ , 0 },
|
||||
{"Strumming" , __SK_ControlChange_, __SK_Strumming_ , 127 },
|
||||
{"NotStrumming" , __SK_ControlChange_, __SK_Strumming_ , 0 },
|
||||
|
||||
{"PlayerSkill" , __SK_ControlChange_, __SK_PlayerSkill_ , SK_DBL},
|
||||
{"PlayerSkill" , __SK_ControlChange_, __SK_PlayerSkill_ , SK_DBL},
|
||||
|
||||
{"Chord" , __SK_Chord_ , SK_DBL , SK_STR },
|
||||
{"ChordOff" , __SK_ChordOff_ , SK_DBL , NOPE },
|
||||
{"Chord" , __SK_Chord_ , SK_DBL, SK_STR},
|
||||
{"ChordOff" , __SK_ChordOff_ , SK_DBL, NOPE},
|
||||
|
||||
{"ShakerInst" , __SK_ControlChange_, __SK_ShakerInst_ , SK_DBL},
|
||||
{"Maraca" , __SK_ControlChange_, __SK_ShakerInst_ , 0 },
|
||||
{"Sekere" , __SK_ControlChange_, __SK_ShakerInst_ , 1 },
|
||||
{"Cabasa" , __SK_ControlChange_, __SK_ShakerInst_ , 2 },
|
||||
{"Bamboo" , __SK_ControlChange_, __SK_ShakerInst_ , 3 },
|
||||
{"Waterdrp" , __SK_ControlChange_, __SK_ShakerInst_ , 4 },
|
||||
{"Tambourn" , __SK_ControlChange_, __SK_ShakerInst_ , 5 },
|
||||
{"Sleighbl" , __SK_ControlChange_, __SK_ShakerInst_ , 6 },
|
||||
{"Guiro" , __SK_ControlChange_, __SK_ShakerInst_ , 7 },
|
||||
{"ShakerInst" , __SK_ControlChange_, __SK_ShakerInst_ , SK_DBL},
|
||||
{"Maraca" , __SK_ControlChange_, __SK_ShakerInst_ , 0 },
|
||||
{"Sekere" , __SK_ControlChange_, __SK_ShakerInst_ , 1 },
|
||||
{"Cabasa" , __SK_ControlChange_, __SK_ShakerInst_ , 2 },
|
||||
{"Bamboo" , __SK_ControlChange_, __SK_ShakerInst_ , 3 },
|
||||
{"Waterdrp" , __SK_ControlChange_, __SK_ShakerInst_ , 4 },
|
||||
{"Tambourn" , __SK_ControlChange_, __SK_ShakerInst_ , 5 },
|
||||
{"Sleighbl" , __SK_ControlChange_, __SK_ShakerInst_ , 6 },
|
||||
{"Guiro" , __SK_ControlChange_, __SK_ShakerInst_ , 7 },
|
||||
|
||||
{"OpenFile" , 256, SK_STR , NOPE},
|
||||
{"SetPath" , 257, SK_STR , NOPE},
|
||||
{"OpenFile" , 256, SK_STR, NOPE},
|
||||
{"SetPath" , 257, SK_STR, NOPE},
|
||||
|
||||
{"FilePath" , __SK_SINGER_FilePath_, SK_STR , NOPE},
|
||||
{"Frequency" , __SK_SINGER_Frequency_, SK_STR , NOPE},
|
||||
{"NoteName" , __SK_SINGER_NoteName_, SK_STR , NOPE},
|
||||
{"VocalShape" , __SK_SINGER_Shape_ , SK_STR , NOPE},
|
||||
{"Glottis" , __SK_SINGER_Glot_ , SK_STR , NOPE},
|
||||
{"VoicedUnVoiced" , __SK_SINGER_VoicedUnVoiced_, SK_DBL , SK_STR},
|
||||
{"Synthesize" , __SK_SINGER_Synthesize_, SK_STR , NOPE},
|
||||
{"Silence" , __SK_SINGER_Silence_, SK_STR , NOPE},
|
||||
{"VibratoAmt" , __SK_ControlChange_ ,__SK_SINGER_VibratoAmt_,SK_DBL},
|
||||
{"RndVibAmt" , __SK_SINGER_RndVibAmt_ ,SK_STR, NOPE},
|
||||
{"VibFreq" , __SK_ControlChange_ ,__SK_SINGER_VibFreq_ ,SK_DBL}
|
||||
{"FilePath" , __SK_SINGER_FilePath_ , SK_STR, NOPE},
|
||||
{"Frequency" , __SK_SINGER_Frequency_ , SK_STR, NOPE},
|
||||
{"NoteName" , __SK_SINGER_NoteName_ , SK_STR, NOPE},
|
||||
{"VocalShape" , __SK_SINGER_Shape_ , SK_STR, NOPE},
|
||||
{"Glottis" , __SK_SINGER_Glot_ , SK_STR, NOPE},
|
||||
{"VoicedUnVoiced" , __SK_SINGER_VoicedUnVoiced_, SK_DBL, SK_STR},
|
||||
{"Synthesize" , __SK_SINGER_Synthesize_ , SK_STR, NOPE},
|
||||
{"Silence" , __SK_SINGER_Silence_ , SK_STR, NOPE},
|
||||
{"RndVibAmt" , __SK_SINGER_RndVibAmt_ , SK_STR, NOPE},
|
||||
{"VibratoAmt" , __SK_ControlChange_ ,__SK_SINGER_VibratoAmt_,SK_DBL},
|
||||
{"VibFreq" , __SK_ControlChange_ ,__SK_SINGER_VibFreq_ ,SK_DBL}
|
||||
};
|
||||
|
||||
|
||||
/** FORMAT: *************************************************************/
|
||||
/* */
|
||||
/* MessageStr$ ,type, data2, data3, */
|
||||
/* MessageStr$ , type, data2, data3, */
|
||||
/* */
|
||||
/* type is the message type sent back from the SKINI line parser. */
|
||||
/* data<n> is either */
|
||||
/* NOPE : field not used, specifically, there aren't going */
|
||||
/* to be any more fields on this line. So if there */
|
||||
/* is is NOPE in data2, data3 won't even be checked */
|
||||
/* is NOPE in data2, data3 won't even be checked */
|
||||
/* SK_INT : byte (actually scanned as 32 bit signed integer) */
|
||||
/* If it's a MIDI data field which is required to */
|
||||
/* be an integer, like a controller number, it's */
|
||||
/* 0-127. Otherwise) get creative with SK_INTs */
|
||||
/* If it's a MIDI data field which is required to */
|
||||
/* be an integer, like a controller number, it's */
|
||||
/* 0-127. Otherwise, get creative with SK_INTs. */
|
||||
/* SK_DBL : double precision floating point. SKINI uses these */
|
||||
/* in the MIDI context for note numbers with micro */
|
||||
/* tuning, velocities, controller values, etc. */
|
||||
/* SK_STR : only valid in final field. This allows (nearly) */
|
||||
/* arbitrary message types to be supported by simply */
|
||||
/* scanning the string to EndOfLine and then passing */
|
||||
/* it to a more intellegent handler. For example, */
|
||||
/* it to a more intelligent handler. For example, */
|
||||
/* MIDI SYSEX (system exclusive) messages of up to */
|
||||
/* 256bytes can be read as space-delimited integers */
|
||||
/* into the 1K SK_STR buffer. Longer bulk dumps, */
|
||||
/* 256 bytes can be read as space-delimited integers */
|
||||
/* into the SK_STR buffer. Longer bulk dumps, */
|
||||
/* soundfiles, etc. should be handled as a new */
|
||||
/* message type pointing to a FileName stored in the */
|
||||
/* SK_STR field, or as a new type of multi-line */
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
/*! \class Sampler
|
||||
\brief STK sampling synthesis abstract base class.
|
||||
|
||||
This instrument contains up to 5 attack waves,
|
||||
5 looped waves, and an ADSR envelope.
|
||||
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 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SAMPLER_H)
|
||||
#define __SAMPLER_H
|
||||
#ifndef STK_SAMPLER_H
|
||||
#define STK_SAMPLER_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
@@ -31,7 +31,7 @@ class Sampler : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency) = 0;
|
||||
virtual void setFrequency(StkFloat frequency) = 0;
|
||||
|
||||
//! Initiate the envelopes with a key-on event and reset the attack waves.
|
||||
void keyOn();
|
||||
@@ -40,25 +40,36 @@ class Sampler : public Instrmnt
|
||||
void keyOff();
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
virtual void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
virtual StkFloat tick() = 0;
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize) = 0;
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if the \c
|
||||
channel argument is zero or it is greater than the number of
|
||||
channels in the StkFrames object.
|
||||
*/
|
||||
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 ) = 0;
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value) = 0;
|
||||
virtual void controlChange(int number, StkFloat value) = 0;
|
||||
|
||||
protected:
|
||||
ADSR *adsr;
|
||||
WvIn *attacks[5];
|
||||
WaveLoop *loops[5];
|
||||
OnePole *filter;
|
||||
MY_FLOAT baseFrequency;
|
||||
MY_FLOAT attackRatios[5];
|
||||
MY_FLOAT loopRatios[5];
|
||||
MY_FLOAT attackGain;
|
||||
MY_FLOAT loopGain;
|
||||
int whichOne;
|
||||
ADSR adsr_;
|
||||
std::vector<WvIn *> attacks_;
|
||||
std::vector<WaveLoop *> loops_;
|
||||
OnePole filter_;
|
||||
StkFloat baseFrequency_;
|
||||
std::vector<StkFloat> attackRatios_;
|
||||
std::vector<StkFloat> loopRatios_;
|
||||
StkFloat attackGain_;
|
||||
StkFloat loopGain_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -31,16 +31,16 @@
|
||||
- Vibrato Gain = 1
|
||||
- Breath Pressure = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SAXOFONY_H)
|
||||
#define __SAXOFONY_H
|
||||
#ifndef STK_SAXOFONY_H
|
||||
#define STK_SAXOFONY_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayL.h"
|
||||
#include "ReedTabl.h"
|
||||
#include "ReedTable.h"
|
||||
#include "OneZero.h"
|
||||
#include "Envelope.h"
|
||||
#include "Noise.h"
|
||||
@@ -50,7 +50,10 @@ class Saxofony : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor, taking the lowest desired playing frequency.
|
||||
Saxofony(MY_FLOAT lowestFrequency);
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Saxofony(StkFloat lowestFrequency);
|
||||
|
||||
//! Class destructor.
|
||||
~Saxofony();
|
||||
@@ -59,41 +62,53 @@ class Saxofony : public Instrmnt
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Set the "blowing" position between the air column terminations (0.0 - 1.0).
|
||||
void setBlowPosition(MY_FLOAT aPosition);
|
||||
void setBlowPosition(StkFloat aPosition);
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
|
||||
void startBlowing(StkFloat amplitude, StkFloat rate);
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBlowing(MY_FLOAT rate);
|
||||
void stopBlowing(StkFloat rate);
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
DelayL *delays[2];
|
||||
ReedTabl *reedTable;
|
||||
OneZero *filter;
|
||||
Envelope *envelope;
|
||||
Noise *noise;
|
||||
WaveLoop *vibrato;
|
||||
long length;
|
||||
MY_FLOAT outputGain;
|
||||
MY_FLOAT noiseGain;
|
||||
MY_FLOAT vibratoGain;
|
||||
MY_FLOAT position;
|
||||
DelayL delays_[2];
|
||||
ReedTable reedTable_;
|
||||
OneZero filter_;
|
||||
Envelope envelope_;
|
||||
Noise noise_;
|
||||
WaveLoop *vibrato_;
|
||||
unsigned long length_;
|
||||
StkFloat outputGain_;
|
||||
StkFloat noiseGain_;
|
||||
StkFloat vibratoGain_;
|
||||
StkFloat position_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -48,17 +48,17 @@
|
||||
- Little Rocks = 21
|
||||
- Tuned Bamboo Chimes = 22
|
||||
|
||||
by Perry R. Cook, 1996 - 1999.
|
||||
by Perry R. Cook, 1996 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SHAKERS_H)
|
||||
#define __SHAKERS_H
|
||||
#ifndef STK_SHAKERS_H
|
||||
#define STK_SHAKERS_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
|
||||
#define MAX_FREQS 8
|
||||
#define NUM_INSTR 24
|
||||
const int MAX_FREQS = 8;
|
||||
const int NUM_INSTR = 24;
|
||||
|
||||
class Shakers : public Instrmnt
|
||||
{
|
||||
@@ -74,54 +74,65 @@ class Shakers : public Instrmnt
|
||||
Use the instrument numbers above, converted to frequency values
|
||||
as if MIDI note numbers, to select a particular instrument.
|
||||
*/
|
||||
virtual void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat instrument, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
|
||||
int setupName(char* instr);
|
||||
int setupNum(int inst);
|
||||
int setFreqAndReson(int which, MY_FLOAT freq, MY_FLOAT reson);
|
||||
void setDecays(MY_FLOAT sndDecay, MY_FLOAT sysDecay);
|
||||
void setFinalZs(MY_FLOAT z0, MY_FLOAT z1, MY_FLOAT z2);
|
||||
MY_FLOAT wuter_tick();
|
||||
MY_FLOAT tbamb_tick();
|
||||
MY_FLOAT ratchet_tick();
|
||||
int setFreqAndReson(int which, StkFloat freq, StkFloat reson);
|
||||
void setDecays(StkFloat sndDecay, StkFloat sysDecay);
|
||||
void setFinalZs(StkFloat z0, StkFloat z1, StkFloat z2);
|
||||
StkFloat wuter_tick();
|
||||
StkFloat tbamb_tick();
|
||||
StkFloat ratchet_tick();
|
||||
|
||||
int instType;
|
||||
int ratchetPos, lastRatchetPos;
|
||||
MY_FLOAT shakeEnergy;
|
||||
MY_FLOAT inputs[MAX_FREQS];
|
||||
MY_FLOAT outputs[MAX_FREQS][2];
|
||||
MY_FLOAT coeffs[MAX_FREQS][2];
|
||||
MY_FLOAT sndLevel;
|
||||
MY_FLOAT baseGain;
|
||||
MY_FLOAT gains[MAX_FREQS];
|
||||
int nFreqs;
|
||||
MY_FLOAT t_center_freqs[MAX_FREQS];
|
||||
MY_FLOAT center_freqs[MAX_FREQS];
|
||||
MY_FLOAT resons[MAX_FREQS];
|
||||
MY_FLOAT freq_rand[MAX_FREQS];
|
||||
int freqalloc[MAX_FREQS];
|
||||
MY_FLOAT soundDecay;
|
||||
MY_FLOAT systemDecay;
|
||||
MY_FLOAT nObjects;
|
||||
MY_FLOAT collLikely;
|
||||
MY_FLOAT totalEnergy;
|
||||
MY_FLOAT ratchet,ratchetDelta;
|
||||
MY_FLOAT finalZ[3];
|
||||
MY_FLOAT finalZCoeffs[3];
|
||||
MY_FLOAT defObjs[NUM_INSTR];
|
||||
MY_FLOAT defDecays[NUM_INSTR];
|
||||
MY_FLOAT decayScale[NUM_INSTR];
|
||||
int instType_;
|
||||
int ratchetPos_, lastRatchetPos_;
|
||||
StkFloat shakeEnergy_;
|
||||
StkFloat inputs_[MAX_FREQS];
|
||||
StkFloat outputs_[MAX_FREQS][2];
|
||||
StkFloat coeffs_[MAX_FREQS][2];
|
||||
StkFloat sndLevel_;
|
||||
StkFloat baseGain_;
|
||||
StkFloat gains_[MAX_FREQS];
|
||||
int nFreqs_;
|
||||
StkFloat t_center_freqs_[MAX_FREQS];
|
||||
StkFloat center_freqs_[MAX_FREQS];
|
||||
StkFloat resons_[MAX_FREQS];
|
||||
StkFloat freq_rand_[MAX_FREQS];
|
||||
int freqalloc_[MAX_FREQS];
|
||||
StkFloat soundDecay_;
|
||||
StkFloat systemDecay_;
|
||||
StkFloat nObjects_;
|
||||
StkFloat totalEnergy_;
|
||||
StkFloat ratchet_, ratchetDelta_;
|
||||
StkFloat finalZ_[3];
|
||||
StkFloat finalZCoeffs_[3];
|
||||
StkFloat defObjs_[NUM_INSTR];
|
||||
StkFloat defDecays_[NUM_INSTR];
|
||||
StkFloat decayScale_[NUM_INSTR];
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
- Envelope Rate = 11
|
||||
- Gain = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SIMPLE_H)
|
||||
#define __SIMPLE_H
|
||||
#ifndef STK_SIMPLE_H
|
||||
#define STK_SIMPLE_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "ADSR.h"
|
||||
@@ -31,16 +31,19 @@ class Simple : public Instrmnt
|
||||
{
|
||||
public:
|
||||
//! Class constructor.
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Simple();
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Simple();
|
||||
~Simple();
|
||||
|
||||
//! Clear internal states.
|
||||
void clear();
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
virtual void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Start envelope toward "on" target.
|
||||
void keyOn();
|
||||
@@ -49,25 +52,37 @@ class Simple : public Instrmnt
|
||||
void keyOff();
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
virtual void noteOff(MY_FLOAT amplitude);
|
||||
void noteOff(StkFloat amplitude);
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Computer \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
virtual void controlChange(int number, MY_FLOAT value);
|
||||
void controlChange(int number, StkFloat value);
|
||||
|
||||
protected:
|
||||
ADSR *adsr;
|
||||
WaveLoop *loop;
|
||||
OnePole *filter;
|
||||
BiQuad *biquad;
|
||||
Noise *noise;
|
||||
MY_FLOAT baseFrequency;
|
||||
MY_FLOAT loopGain;
|
||||
ADSR adsr_;
|
||||
WaveLoop *loop_;
|
||||
OnePole filter_;
|
||||
BiQuad biquad_;
|
||||
Noise noise_;
|
||||
StkFloat baseFrequency_;
|
||||
StkFloat loopGain_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -9,26 +9,26 @@
|
||||
from pitch shifting. It will be used as an
|
||||
excitation source for other instruments.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__SINGWAVE_H)
|
||||
#define __SINGWAVE_H
|
||||
#ifndef STK_SINGWAVE_H
|
||||
#define STK_SINGWAVE_H
|
||||
|
||||
#include "WaveLoop.h"
|
||||
#include "Modulate.h"
|
||||
#include "Envelope.h"
|
||||
|
||||
class SingWave : public Stk
|
||||
class SingWave : public Generator
|
||||
{
|
||||
public:
|
||||
//! Class constructor taking filename argument.
|
||||
/*!
|
||||
An StkError will be thrown if the file is not found, its format is
|
||||
unknown, or a read error occurs.
|
||||
unknown, a read error occurs, or the rawwave path is incorrectly set.
|
||||
*/
|
||||
SingWave(const char *fileName, bool raw=FALSE);
|
||||
SingWave( std::string fileName, bool raw=false);
|
||||
|
||||
//! Class destructor.
|
||||
~SingWave();
|
||||
@@ -40,28 +40,28 @@ class SingWave : public Stk
|
||||
void normalize();
|
||||
|
||||
//! Normalize the file to a maximum of \e +- peak.
|
||||
void normalize(MY_FLOAT peak);
|
||||
void normalize(StkFloat peak);
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(MY_FLOAT frequency);
|
||||
void setFrequency(StkFloat frequency);
|
||||
|
||||
//! Set the vibrato frequency in Hz.
|
||||
void setVibratoRate(MY_FLOAT aRate);
|
||||
void setVibratoRate(StkFloat rate);
|
||||
|
||||
//! Set the vibrato gain.
|
||||
void setVibratoGain(MY_FLOAT gain);
|
||||
void setVibratoGain(StkFloat gain);
|
||||
|
||||
//! Set the random-ness amount.
|
||||
void setRandomGain(MY_FLOAT gain);
|
||||
void setRandomGain(StkFloat gain);
|
||||
|
||||
//! Set the sweep rate.
|
||||
void setSweepRate(MY_FLOAT aRate);
|
||||
void setSweepRate(StkFloat rate);
|
||||
|
||||
//! Set the gain rate.
|
||||
void setGainRate(MY_FLOAT aRate);
|
||||
void setGainRate(StkFloat rate);
|
||||
|
||||
//! Set the gain target value.
|
||||
void setGainTarget(MY_FLOAT target);
|
||||
void setGainTarget(StkFloat target);
|
||||
|
||||
//! Start a note.
|
||||
void noteOn();
|
||||
@@ -69,21 +69,29 @@ class SingWave : public Stk
|
||||
//! Stop a note.
|
||||
void noteOff();
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut();
|
||||
|
||||
//! Compute one output sample.
|
||||
MY_FLOAT tick();
|
||||
StkFloat tick();
|
||||
|
||||
//! Compute \e vectorSize outputs and return them in \e vector.
|
||||
StkFloat *tick( StkFloat *vector, unsigned int vectorSize );
|
||||
|
||||
//! Fill a channel of the StkFrames object with computed outputs.
|
||||
/*!
|
||||
The \c channel argument should be one or greater (the first
|
||||
channel is specified by 1). An StkError will be thrown if 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 );
|
||||
|
||||
protected:
|
||||
|
||||
WaveLoop *wave;
|
||||
Modulate *modulator;
|
||||
Envelope *envelope;
|
||||
Envelope *pitchEnvelope;
|
||||
MY_FLOAT rate;
|
||||
MY_FLOAT sweepRate;
|
||||
MY_FLOAT lastOutput;
|
||||
WaveLoop *wave_;
|
||||
Modulate *modulator_;
|
||||
Envelope envelope_;
|
||||
Envelope pitchEnvelope_;
|
||||
StkFloat rate_;
|
||||
StkFloat sweepRate_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user