Version 4.0

This commit is contained in:
Gary Scavone
2013-09-25 14:50:19 +02:00
committed by Stephen Sinclair
parent 3f126af4e5
commit 81475b04c5
473 changed files with 36355 additions and 28396 deletions

115
README Normal file
View File

@@ -0,0 +1,115 @@
The Synthesis ToolKit in C++ (STK)
By Perry R. Cook and Gary P. Scavone, 1995-2002.
This distribution of the Synthesis ToolKit in C++ (STK) contains the following:
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
Please read the Legal and Ethical notes near the bottom of this document.
OVERVIEW:
The Synthesis ToolKit in C++ (STK) is a set of audio signal processing and synthesis classes and algorithms written in C++. You can use these classes to create programs that make sounds with a variety of synthesis techniques. This is not a terribly novel concept, except that the Synthesis ToolKit is extremely portable (it's mostly platform-independent C and C++ code), and it's completely user-extensible (no libraries, no hidden drivers, and all source code is included). 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, 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).
The Synthesis Toolkit is not one particular program. Rather, it is a set of C++ classes that you can use to create your own programs. A few example applications are provided to demonstrate some of the ways to use the classes. If you have specific needs, you will probably have to either modify the example programs or write a new program altogether. Further, the example programs don't have a fancy GUI wrapper. If you feel the need to have a "drag and drop" graphical patching GUI, you probably don't want to use the ToolKit. Spending hundreds of hours making platform-dependent graphics code would go against one of the fundamental design goals of the ToolKit - platform independence.
For those instances where a simple GUI with sliders and buttons is helpful, we use <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).
SYSTEM REQUIREMENTS:
See the individual README's (eg. README-linux) for platform specific information and system requirements. In general, you will use either the provided Makefiles (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:
STK has undergone several key revisions, changes, and additions since its last release. 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.
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!
As mentioned above, it is possible to record the audio ouput of an STK program to .snd, .wav, .raw, .aif, and .mat (Matlab MAT-file) output file types. Though somewhat obsolete, the program Md2Skini can be used to write SKINI scorefiles from realtime MIDI input. Finally, STK should compile with non-realtime functionality on any platform with a generic C++ compiler.
For those who wish to make a library from the core STK classes, there is a Makefile in the src directory that will accomplish that (Linux and SGI only).
DISCLAIMER:
You probably already guessed this, but just to be sure, we don't guarantee anything works. :-) It's free ... what do you expect? If you find a bug, please let us know and we'll try to correct it. You can also make suggestions, but again, no guarantees. Send email to prc@cs.princeton.edu and gary@ccrma.stanford.edu.
LEGAL AND ETHICAL:
This software was designed and created to be made publicly available for free, primarily for academic purposes, so if you use it, pass it on with this documentation, and for free.
If you make a million dollars with it, give us some. If you make compositions with it, put us in the program notes.
Some of the concepts are covered by various patents, some known to us and likely others which are unknown. Many of the ones known to us are administered by the Stanford Office of Technology and Licensing.
The good news is that large hunks of the techniques used here are public domain. To avoid subtle legal issues, we'll not state what's freely useable here, but we'll try to note within the various classes where certain things are likely to be protected by patents.
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.
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.
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.
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:
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.
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.
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 . . .

View File

@@ -1,156 +1,155 @@
STK: A ToolKit of Audio Synthesis Classes and Instruments in C++
Version 3.2
By Perry R. Cook, 1995-2000
and Gary P. Scavone, 1997-2000.
By Perry R. Cook and Gary P. Scavone, 1995-2002.
STK Classes, Version 3.2
Please read README.txt for more information.
STK Classes - See the HTML documentation in the html directory for complete information.
<--------Building Blocks---------->|<----------------Instruments------------------>
.- Envelope - ADSR
|
|- Noise - SubNoise
|
|- Table
|
|- WvIn - (WaveLoop, RtWvIn, TcpWvIn)
|
|- WvOut - (RtWvOut, TcpWvOut)
|
|- Filter - (OnePole, OneZero, Delay, TwoPole, TwoZero, PoleZero, Biquad)
| | |
| DelayL FormSwep
| DelayA
|
|- Echo, Chorus, PitShift
|
|- RtAudio, RtMidi, Socket, Thread
Stk -|
|- Reverb - (PRCRev, JCRev, NRev)
|
|- Modulate
|
|- Messager
|
|- SKINI
|
|- ReedTabl, JetTabl, BowTabl
|
| .- FM - (HevyMetl, PercFlut, Rhodey, Wurley, TubeBell, BeeThree, FMVoices)
| |
| |- Modal - ModalBar
| |
| |- Sampler - Moog
| |
| |- Resonate
| |
| |- PluckedTwo - Mandolin
.- Instrmnt -|
|- Drummer
|
|- Clarinet, BlowHole, Saxofony, Flute, Brass, BlowBotl, Bowed, Plucked, StifKarp, Sitar
|
|- Shakers
|
|- BandedWG
|
.- Mesh2D
SourcSink Filters Reverb Non-Lin Modal & FM Physical Sampling PhISM
Formant
Object-----------------------------------Instrmnt----------.
| | | | | | |
Envelope| Filter Reverb BowTabl | .----------------------------------------.
| | | | JetTabl | | | | | | | | |
ADSR | OneZero PRCRev ReedTabl| Modal4 | FM4Op---.| | | | Shakers
| OnePole JCRev | | | | || | | |
._____| TwoZero NRev .____| ModalBar| FM4Alg3 || Plucked Sampler |
| | TwoPole | | | || Clarinet | |
Noise | DCBlock LipFilt | HeavyMtl|| Brass SamplFlt|
| | BiQuad | || Flute | |
SubNoise| DlineL .____| .____|| Bowed Moog1 |
| DLineA | | || BowedBar |
| DLineN VoicForm FM4Alg4 || BlowHole |
| FormSwep | ||____. |
| PoleZero PercFlut| | |
.____| FIR | Plucked2 |
| | .____| | .____|
TablLook| | | Mandolin |
| FM4Alg5 | DrumSynt
|____. | |
| | Rhodey |
| WvIn Wurley |
._____| | TubeBell |
| | WavWvIn .____|
Modulatr| SndWvIn | |
| RawWvIn FM4Alg6 |
._____| MatWvIn | |
| | AifWvIn FMVoices|
SingWave| StrmWvIn |
| .____|
._____|_____. |
| | | FM4Alg8
VoicMang| WvOut |
| | BeeThree
| WavWvOut
._____| SndWvOut
| | RawWvOut
RtMidi | MatWvOut
| AifWvOut
._____| RtWvOut
| StrmWvOut
RtAudio
*********** UNIT GENERATORS **************
********** INSTRUMENTS AND ALGORITHMS **************
Master Class: Stk.cpp Sample rate, byte-swapping, error handling functionality
Each Class will be listed either with all UGs it uses,
or the <<Algorithm>> of which it is a flavor.
All inherit from Instrmnt, which inherits from Object.
Plucked.cpp Basic Plucked String DLineA,OneZero,OnePole,Noise
Plucked2.cpp Not So Basic Pluck DLineL,DlineA,OneZero
Mandolin.cpp My Own Mandolin <<flavor of Plucked2>>
Bowed.cpp Not Hideous Bowed String DlineL,BowTabl,OnePole,BiQuad,RawWave,ADSR
Brass.cpp Not So Bad Brass Inst. DLineA,LipFilt,DCBlock,ADSR,RawWvIn
Clarinet.cpp Pretty Good Clarinet DLineL,ReedTabl,OneZero,Envelope,Noise,RawWvIn
BlowHole.cpp Clarinet w/ tone/reghole DLineL,ReedTabl,OneZero,Envelope,Noise,RawWvIn,PoleZero
Flute.cpp Pretty Good Flute JetTabl,DLineL,OnePole,DCBlock,Noise,ADSR,RawWvIn
BowedBar.cpp Pretty Good Bowed Bar DLineN,BowTabl,ADSR,BiQuad
Modal4.cpp 4 Resonances Envelope,RawWvIn,RawWvIn,BiQuad,OnePole
ModalBar.cpp Various presets <<flavor of MODAL4>>
FM4Op.cpp 4 Operator FM Master ADSR,RawWvIn,TwoZero
FM4Alg3.cpp 3 Cascade w/ FB Mod. <<flavor of FM4OP>>
FM4Alg4.cpp Like Alg3 but diff. <<flavor of FM4OP>>
FM4Alg5.cpp 2 Parallel Simple FMs <<flavor of FM4OP>>
FM4Alg6.cpp 3 Carr. with 1 Mod. <<flavor of FM4OP>>
FM4Alg8.cpp 4 Osc. Additive <<flavor of FM4OP>>
HeavyMtl.cpp Distorted Synth <<flavor of FM4Alg3>>
PercFlut.cpp Perc. Flute <<flavor of FM4Alg4>>
Rhodey.cpp Rhodes-Like Elec. Piano <<flavor of FM4Alg5>>
Wurley.cpp Wurlitz. Elec. Piano <<flavor of FM4Alg5>>
TubeBell.cpp Classic FM Bell <<flavor of FM4Alg5>>
FMVoices.cpp 3-Formant Voice Synth. <<flavor of FM4Alg6>>
BeeThree.cpp Cheezy Organ for Paul <<flavor of FM4Alg8>>
Sampler.cpp Sampling Synth. 4 each ADSR, RawWvIn (att), RawWvIn (loop), OnePole
SamplFlt.cpp Sampler with Swept Filter <<flavor of Sampler>>
Moog1.cpp Swept filter flavor of <<flavor of SamplFlt>>
VoicForm.cpp Source/Filter Voice Envelope,Noise,SingWave,FormSwep,OnePole,OneZero
DrumSynt.cpp Drum Synthesizer bunch of RawWvIn, and OnePole
Shakers.cpp Stochastic Event Models
*********** BASIC UNIT GENERATORS **************
Master Object: Object.cpp For compatibility with Objective C
Source&Sink: Envelope.cpp Linearly Goes to Target by Rate, + noteOn/Off
Sources: Envelope.cpp Linearly Goes to Target by Rate
ADSR.cpp ADSR Flavor of Envelope
Noise.cpp Random Number Generator
SubNoise.cpp Random Numbers each N samples
Table.cpp Lookup Table (assumes given data in big-endian format)
WvIn.cpp Data Input Class (interpolating) for RAW, WAV, SND (AU), AIFF, MAT-file files
WaveLoop.cpp Wavetable looping (subclass of WvIn)
RtWvIn.cpp Realtime Audio Input Class (subclass of WvIn)
TcpWvIn.cpp Audio Streaming (socket server) Input Class (subclass of WvIn)
Inputs: TablLook.cpp Lookup Table (assumes given data in big-endian format)
WvIn.cpp Input Master Class (Looping, One-Shot,
Interpolating, Non-Interpolating)
RawWvIn.cpp STK Raw-file Input
SndWvIn.cpp .snd Input Class
WavWvIn.cpp .wav Input Class
MatWvIn.cpp Matlab MAT-file Input Class
AifWvIn.cpp AIFF Input Class
RtWvIn.cpp Realtime Input Class
StrmWvIn.cpp Audio Streaming (socket server) Input Class
Sinks: WvOut.cpp Output Master Class for RAW, WAV, SND (AU), AIFF, MAT-file files
RtWvOut.cpp Realtime Output Class (subclass of WvOut)
TcpWvOut.cpp Audio Streaming (socket client) Output Class (subclass of WvOut)
Outputs: WvOut.cpp Output Master Class
RawWvOut.cpp STK Raw-file Output Class
SndWvOut.cpp .snd Output Class
WavWvOut.cpp .wav Output Class
MatWvOut.cpp Matlab MaT-file Output Class
AifWvOut.cpp AIFF Output Class
RtWvOut.cpp Realtime Output Class
StrmWvOut.cpp Audio Streaming (socket client) Output Class
Duplex: RtDuplex.cpp Realtime Input/Output Class
MIDI: RtMidi.cpp MIDI I/O Class
Audio I/O: RtAudio.cpp Multi-OS Audio I/O Routines
Duplex: RtDuplex.cpp Synchronous Realtime Audio Input/Output Class
Filters: Filter.cpp Filter Master Class
OneZero.cpp One Zero Filter
OnePole.cpp One Pole Filter
PoleZero.cpp One Pole/One Zero Filter
DCBlock.cpp DC Blocking 1Pole/1Zero Filter
TwoZero.cpp Two Zero Filter
TwoPole.cpp Two Pole Filter
BiQuad.cpp 2Pole/2Zero Filter
FormSwep.cpp Sweepable 2Pole filter, go to target by rate
DLineL.cpp Linearly Interpolating Delay Line
DLineA.cpp AllPass Interpolating Delay Line
DLineN.cpp Non Interpolating Delay Line
BiQuad.cpp Two Pole/Two Zero Filter
FormSwep.cpp Sweepable BiQuad Filter (goes to target by rate)
Delay.cpp Non-Interpolating Delay Line Class
DelayL.cpp Linearly Interpolating Delay Line (subclass of Delay)
DelayA.cpp Allpass Interpolating Delay Line (subclass of Delay)
Reverb: Reverb.cpp Reverb Master Class
PRCRev.cpp 2 series allpass units, 2 parallel comb filters
JCRev.cpp 3 series allpass units, 4 parallel comb filters
NRev.cpp 6 parallel comb filters, 3 series allpass units, ...
Non-Linear: JetTabl.cpp Cubic Jet Non-Linearity
BowTabl.cpp x^(-3) Bow Non-Linearity
ReedTabl.cpp One Breakpoint Saturating Reed Non-Linearity
NonLin&Lookup: JetTabl.cpp Cubic Jet NonLinearity
BowTabl.cpp 1/x^3-like Bow NonLinearity
ReedTabl.cpp 1 break point Reed NonLinearity
LipFilt.cpp Pressure Controlled BiQuad with NonLin
Derived: Modulate.cpp Periodic and Random Vibrato: RawWvIn, SubNoise, OnePole
********** INSTRUMENTS AND ALGORITHMS **************
Each Class will be listed either with all the unit generators it uses,
or the <<Algorithm>> of which it is a flavor. All inherit from Instrmnt,
which inherits from Stk.
Simple.cpp Simple Instrument Pulse oscillator + resonant filtered noise
Plucked.cpp Basic Plucked String DelayA, OneZero, OnePole, Noise
StifKarp.cpp Plucked String with Stiffness DelayA, DelayL, OneZero, BiQuad, Noise
PluckTwo.cpp Not So Basic Pluck DelayL, DlineA, OneZero
Mandolin.cpp Commuted Mandolin <<flavor of PluckTwo>>
Bowed.cpp So So Bowed String DelayL, BowTabl, OnePole, BiQuad, WaveLoop, ADSR
Brass.cpp Not So Bad Brass Instrument DelayA, BiQuad, PoleZero, ADSR, WaveLoop
Clarinet.cpp Pretty Good Clarinet DelayL, ReedTabl, OneZero, Envelope, Noise, WaveLoop
BlowHole.cpp Clarinet w/ Tone & Vent Holes DelayL, ReedTabl, OneZero, Envelope, Noise, WaveLoop, PoleZero
Saxofony.cpp A Faux Saxophone DelayL, ReedTabl, OneZero, Envelope, Noise, WaveLoop
Flute.cpp Pretty Good Flute JetTabl, DelayL, OnePole, PoleZero, Noise, ADSR, WaveLoop
BlowBotl.cpp Blown Bottle JetTabl, BiQuad, PoleZero, Noise, ADSR, WaveLoop
BandedWG.cpp Banded Waveguide Meta-Object Delay, BowTabl, ADSR, BiQuad
Modal.cpp N Resonances Envelope, WaveLoop, BiQuad, OnePole
ModalBar.cpp Various presets 4 Resonance Models
FM.cpp N Operator FM Master ADSR, WaveLoop, TwoZero
HevyMetl.cpp Distorted FM Synthesizer 3 Cascade with FB Modulator
PercFlut.cpp Percussive Flute 3 Cascade Operators
Rhodey.cpp Rhodes-Like Electric Piano 2 Parallel Simple FMs
Wurley.cpp Wurlitzer Electric Piano 2 Parallel Simple FMs
TubeBell.cpp Classic FM Bell 2 Parallel Simple FMs
FMVoices.cpp 3 Formant FM Voice 3 Carriers Share 1 Modulator
BeeThree.cpp Cheezy Additive Organ 4 Oscillators Additive
Sampler.cpp Sampling Synthesizer 5 each ADSR, WvIn, WaveLoop, OnePole
Moog.cpp Swept Filter Sampler with Swept Filter
Resonate.cpp Filtered Noise ADSR, BiQuad, Noise
Drummer.cpp Drum Synthesizer Bunch of WvIns, and OnePole
Shakers.cpp PhISM statistical model for shakers and real-world sound effects
Mesh2D.cpp Two-dimensional, rectilinear digital waveguide mesh.
Reverb.cpp Reverberator Effects Processor Master Class for reverberators
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
Flanger.cpp Flanger Effects Processor DelayL, WaveLoop
Chorus.cpp Chorus Effects Processor DelayL, WaveLoop
PitShift.cpp Cheap Pitch Shifter DelayL
*********** OTHER SUPPORT CLASSES AND FILES **************
RtAudio.cpp Multi-OS/API audio I/O routines
RtMidi.cpp Multi-OS/API MIDI I/O routines
Messager.cpp Pipe, socket, and MIDI control message handling
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.msg #defines for often used and universal MIDI/SKINI symbols
SKINI.tbl Table of SKINI messages
Derived: Modulatr.cpp Per. and Rnd. Vibrato: RawWave, SubNoise, OnePole
SingWave.cpp Looping Wavetable with: Modulatr, Envelope
Control: Controller.cpp Pipe, Socket, and MIDI control message handling

View File

@@ -1,20 +1,18 @@
STK: A ToolKit of Audio Synthesis Classes and Instruments in C++
Version 3.2
The Synthesis ToolKit in C++ (STK)
By Perry R. Cook, 1995-2000
and Gary P. Scavone, 1997-2000.
By Perry R. Cook and Gary P. Scavone, 1995-2002.
Please read the file README.txt for more general STK information.
Please read the file README for more general STK information.
STK 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 seem to perform well though we have had some problems with them at CCRMA. You can read more about ALSA at http://www.alsa-project.org/. ALSA is open source and holds great promise for audio under Linux. Select (uncomment) the proper API #define statement in Object.h.
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.
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.
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, make sure you uncomment the MIDIATOR define statement in Object.h. This support currently only works within the OSS API framework, though I should be able to get it to work with ALSA in the future as well.
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__).
There are a few things that need to be done on your system to get the MIDIator working. Add the following lines to your bootup sequence in /etc/rc.d/rc.local:
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

View File

@@ -1,14 +1,9 @@
STK: A ToolKit of Audio Synthesis Classes and Instruments in C++
Version 3.2
The Synthesis ToolKit in C++ (STK)
By Perry R. Cook, 1995-2000
and Gary P. Scavone, 1997-2000.
By Perry R. Cook and Gary P. Scavone, 1995-2002.
Please read the file README for more general STK information.
Please read the file README.txt for more general STK information.
STK has always worked under NeXTStep without realtime audio or MIDI support. In general, STK should compile in this way using any generic C++ compiler. C++ exception handling was added to STK with release 3.2. I have had some difficulty testing this release under NeXTStep because our NeXTStep compilers at CCRMA are very old. We tried a newer version of gcc-2.7.2.2 and that mostly worked, though it died trying to compile the BowedBar class. Also, I was unable to locate the correct header for the random() function.
In summary, I _think_ STK will compile under NeXTStep with a fairly recent compiler, but you may have to do a little work to make it happen. If you do succeed, please let us know.
Just for clarification, "realtime" support and the use of the __STK_REALTIME_ define statement includes audio and MIDI input/output routines, as well as socket and thread routines for realtime message acquisition (Controller) and internet audio streaming (StrmWvIn, StrmWvOut).
STK has always worked under NeXTStep without realtime audio or MIDI support. In general, STK should compile in this way using any generic C++ compiler. C++ exception handling was added to STK with release 3.2. We managed to get a version of gcc compiled for NeXTStep that can deal with C++ exceptions.

View File

@@ -1,14 +1,12 @@
STK: A ToolKit of Audio Synthesis Classes and Instruments in C++
Version 3.2
The Synthesis ToolKit in C++ (STK)
By Perry R. Cook, 1995-2000
and Gary P. Scavone, 1997-2000.
By Perry R. Cook and Gary P. Scavone, 1995-2002.
Please read the file README.txt for more general STK information.
Please read the file README for more general STK information.
It seems that SGI systems are not distributed with the GNU Makefile utilities. The default Make utility has very limited functionality, so your safest bet is to download the GNU Makefile utilities from the Internet and use STK's default Makefile. If this is not possible, try using Makefile.sgi (make -f Makefile.sgi).
When using the Makefiles provided, first try invoking "gmake" (for GNU make). If that doesn't work, try to download the GNU Makefile utilities from the Internet and use STK's default Makefile. If this is not possible, try using Makefile.sgi (make -f Makefile.sgi).
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.
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 without difficulty using CC version 7.30.
NOTE REGARDING PTHREADS:

View File

@@ -1,23 +1,23 @@
STK: A ToolKit of Audio Synthesis Classes and Instruments in C++
Version 3.2
The Synthesis ToolKit in C++ (STK)
By Perry R. Cook, 1995-2000
and Gary P. Scavone, 1997-2000.
By Perry R. Cook and Gary P. Scavone, 1995-2002.
Please read the file README.txt for more general STK information.
Please read the file README for more general STK information.
DirectX and WindowsNT Issues:
-----------------------------
STK is currently distributed with Visual C++ 6.0 project and workspace files.
STK is currently distributed with Visual C++ 6.0 project and workspace files. It has been tested using both Visual C++ 6.0 and Visual C++ .NET.
The STK realtime sound input capabilities under Windoze are only supported using the DirectSoundCapture API. The latency is pretty horrendous, but what do you expect? Also, there is a 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. I stopped supporting the WinMM audio output code with this release. So, if you wish to compile STK under WindowsNT (without realtime audio input support), you'll have to download an older version of STK, uncomment the __WINMM_API_ flag (and comment out the __WINDS_API flag) in Object.h and recompile the source code.
IMPORTANT VC++ NOTE: When compiling "release" versions of STK programs, link to the release multithreaded library. When compiling "debug" versions, link to the debug multithreaded library. Compiler errors will result otherwise. Also, the Microsoft folk are up to their old habits of trying to change standards. The .NET compiler will complain about cerr for some reason.
Realtime sound output under Windoze is supported using the DirectSound (dsound.lib) API. All new versions of Win95/98/NT come with the DirectSound library, but early versions did not. If you have trouble running the distributed executables, then you probably don't have DirectSound installed on your system. You can download the necessary DirectSound stuff from Microsoft's WWW pages (http://www.microsoft.com/directx/download.asp).
The STK realtime sound input capabilities under Windoze are only supported using the DirectSoundCapture API. The latency is pretty horrendous, but what do you expect? Also, there is a 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. I stopped supporting the WinMM audio output code with release 3.2.
Realtime sound output under Windoze is supported using the DirectSound (dsound.lib) API. All new versions of WindowsXX come with the DirectSound library, but early versions did not. If you have trouble running the distributed executables, then you probably don't have DirectSound installed on your system. You can download the necessary DirectSound stuff from Microsoft's WWW pages (http://www.microsoft.com/directx/download.asp).
Realtime MIDI input is supported using the winmm.lib API.
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 (STK.dsw), then you will have to do a LOT of configuring to recreate it ... it's probably easier just to download the distribution again from our WWW sites. Anyway, for your benefit and mine, here is a list of things that need to be added to the various "Project Settings":
Visual C++ 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":
1. Under General: Set "Output files:" to <blank> (this will put the executable in the main project directory.
@@ -27,9 +27,11 @@ 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. Add all the necessary files to the project.
5. Under C/C++ > Preprocessor: Add "__WINDOWS_DS__" to the definitions field.
Remember that items 1-3 above need to be done for each project and for each configuration. There might be an easy way to make global changes, but I couldn't figure it out.
6. Add all the necessary files to the project.
Remember that items 1-5 above need to be done for each project and for each configuration. There might be an easy way to make global changes, but I couldn't figure it out.
To use the Tcl/Tk GUIs, you will have to install Tcl/Tk. I got version 8.0 and it works very well (and installed easily). The distribution is available on the WWW and is free.
@@ -40,12 +42,12 @@ Finally, to use it all -
PLAY SKINI SCOREFILES IN REALTIME:
syntmono Clarinet -or < scores/streetsf.ski
demo Clarinet -or < scores/streetsf.ski
USE TCL/TK GUIs FOR REALTIME CONTROL:
1. Open a DOS console window and start syntmono (eg. syntmono Clarinet -or -is).
1. Open a DOS console window and start syntmono (eg. demo Clarinet -or -is).
2. Double click on a Tcl/Tk file in TCLSpecs (eg. TCLPhys.tcl) from the Windows Explorer to start the GUI. Select the "communications" menu item and "Socket" and make the connection.
@@ -54,16 +56,18 @@ USE TCL/TK GUIs FOR REALTIME CONTROL:
USE REALTIME MIDI INPUT FOR CONTROL:
1. Open a DOS console window and start syntmono with MIDI input (eg. syntmono Clarinet -or -im).
1. Open a DOS console window and start syntmono with MIDI input (eg. demo Clarinet -or -im).
This assumes you already have MIDI setup correctly for your computer.
WINDOWS 2000/XP:
There is a big advantage in using Windows 2000/XP over 95/98 with STK in that piping works, just as under unix. Also, the scheduler in 2000/XP seems to be much better, so socketed messages don't get clumped together like they do in Windows 95/98. The script files (ex. Demo) can be renamed with .bat extensions, allowing them to work in the same way as in unix systems.
WINDOWS NT ONLY:
Realtime piping seems to work under WindowsNT in much the same way as on Unix platforms. Thus, it is possible to pipe realtime control data to syntmono under WindowsNT as well.
WINDOWS 2000:
I don't have Windows 2000 and I doubt I'll get it anytime soon. However, we briefly tested release 3.2 of STK on Perry's Win2000 machine and it worked fine. There is an advantage in using Windows 2000 over 95/98 in that piping works, just as under unix. Also, the scheduler in Win2000 seems to be much better, so socketed messages don't get clumped together like they do in Win 95/98. Since 2000 is supposed to ship with DirectX 7.0, the DirectSoundCapture functionality should work as well.

View File

@@ -1,128 +0,0 @@
STK: A ToolKit of Audio Synthesis Classes and Instruments in C++
Version 3.2
By Perry R. Cook, 1995-2000
and Gary P. Scavone, 1997-2000.
Please read the Legal and Ethical notes near the bottom of this document.
OVERVIEW:
STK is a set of audio signal processing C++ classes and instruments for music synthesis. You can use these classes to create programs which make cool sounds using a variety of synthesis techniques. This is not a terribly novel concept, except that STK is very portable (it's mostly platform-independent C and C++ code) AND it's completely user-extensible. So, the code you write using STK actually has some chance of working in another 5-10 years. STK currently runs with "realtime" support (audio and MIDI) on SGI (Irix), Linux, and Windows computer platforms. Generic, non-realtime support has been tested under NeXTStep, but should work with any standard C++ compiler. STK is free for non-commercial use. The only parts of STK that are platform-dependent concern real-time sound, MIDI, and control input and output ... but we've taken care of that for you. The interface for MIDI input and the simple Tcl/Tk graphical user interfaces (GUIs) provided is the same, so it's easy to voice and experiment in real time using either the GUIs or MIDI.
STK isn't one particular program. Rather, STK is a set of C++ classes that you can use to create your own programs. We've provided a few example applications that demonstrate some of the ways that you could use these classes. But 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" GUI, you probably don't want to use STK. Spending hundreds of hours making platform-dependent GUI code would go against one of the fundamental design goals of STK - platform independence. STK can generate simultaneous .snd, .wav, .aif, and .mat output soundfile formats (as well as realtime sound output), so you can view your results using one of the numerous sound/signal analysis tools already available over the WWW (e.g. Snd, Cool Edit, Matlab). For those instances where a simple GUI with sliders and buttons is helpful, we use Tcl/Tk (which is freely distributed for all the STK supported platforms). A number of Tcl/Tk GUI scripts are distributed with the STK release.
SYSTEM REQUIREMENTS:
See the individual README's (eg. README-linux) for platform specific information and system requirements. In general, you will use either the provided Makefiles (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:
STK has undergone several key revisions, changes, and additions since its last release. 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 ReleaseNotes to see what has changed since the last release.
The control message handling scheme has been simplified greatly with release 3.2 through the use of the Controller 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!
As mentioned above, it is possible to record the audio ouput of an STK program to .snd, .wav, .raw, .aif, and .mat (Matlab MAT-file) output file types. Though somewhat obsolete, the program MD2SKINI can be used to write SKINI scorefiles from realtime MIDI input. Finally, STK should compile with non-realtime functionality on any platform with a generic C++ compiler.
For those who wish to make a library from the core STK classes, there is a Makefile in the src directory that will accomplish that (Linux and SGI only).
GETTING STARTED:
A number of example "projects" are provided with this distribution. The effects directory contains a program that demonstrates realtime duplex mode (simultaneous audio input and output) operation, as well as several simple delay-line based effects algorithms. RagaMatic is a totally cool application for achieving inner peace. The examples directory contains several simple programs which demonstrate audio input/output, as well as the use of the audio internet streaming classes. The syntmono directory offers a program for monophonic STK instrument playback and manipulation. Syntmono is used to demonstrate most of the current STK instruments. Control data (in the form of MIDI or SKINI messages) is acquired by syntmono through pipe, socket, or MIDI connections. Tcl/Tk GUIs are provided which output SKINI formatted messages. A variety of SKINI scorefiles are distributed with STK and can be found in the "scores" directory of the syntmono project. MD2SKINI is an executable (currently compiles from the syntmono project) which takes raw MIDI input, converts it to SKINI format, and outputs the result to stdout or any socket host and port ID.
Unless you downloaded the distribution with precompiled Windoze binaries, it is necessary to first compile the sources. Under Linux or Irix, simply typing "make" in any of the particular project directories will begin the compilation process. If your Unix system does not have the GNU Makefile utilities, you will have to use one of the platform specific Makefiles (eg. make -f Makefile.sgi). To compile the projects under Windoze, you should use the VC++ 6.0 project files provided with the STK distribution.
SYNTMONO:
Syntmono is used to demonstrate most of the current STK instruments. Syntmono can take realtime control input via MIDI and/or SKINI format via pipes or sockets, or it can be fed SKINI scorefile (non-realtime) input. Syntmono can output data in realtime, .wav, .snd, .aif, .mat (Matlab MAT-file), and/or .raw formats. Assuming you have successfully compiled the syntmono executable, a scorefile can be redirected to syntmono and the output heard in realtime in the following way:
syntmono Clarinet -or < scores/streetsf.ski
The "-or" flag specifies the realtime output option. Typing syntmono without arguments will provide a brief description of the instruments possible and the various input/output option flags. Tcl/Tk GUIs are provided in the "tcl" directory of each project, though you will have to install Tcl/Tk version 8.0 or higher on your system to use them (older versions of Tcl/Tk under Linux seem to be more forgiving than under IRIX). Realtime SKINI control data can be piped to syntmono from a Tcl/Tk GUI on Unix platforms and WinNT in the following way:
wish < TCLSpecs/TCLPhys.tcl | syntmono Clarinet -or -ip
The "-ip" flag specifies piped realtime input. It is not possible to use realtime pipes under Windoze95/98, so socket communication must be used instead. For socket communication, it is necessary to first start the syntmono socket server using the "-is" flag (socketed realtime input). For the time being, a default (hardwired) socket port of 2001 is being used by syntmono. After syntmono is running (and waiting for a socket client connection), a Tcl/Tk GUI can be started. When using the GUI, it is necessary to invoke the "communications" menu item and select "socket" to establish the connection. The same procedure is also possible on Unix platforms. Finally, realtime MIDI control input can be used to control syntmono by typing:
syntmono Clarinet -or -im
The "-im" flag specifies realtime MIDI input. It is possible to use piped, socketed, and/or MIDI control input simultaneously.
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.
LEGAL AND ETHICAL:
This software was designed and created to be made publicly available for free, primarily for academic purposes, so if you use it, pass it on with this documentation, and for free.
If you make a million dollars with it, give us some. If you make compositions with it, put us in the program notes.
Some of the concepts are covered by various patents, some known to us and likely others which are unknown. Many of the ones known to us are administered by the Stanford Office of Technology and Licensing.
The good news is that large hunks of the techniques used here are public domain. To avoid subtle legal issues, we'll not state what's freely useable here, but we'll try to note within the various classes where certain things are likely to be protected by patents.
FURTHER READING:
For more documentation on this ToolKit, the classes, etc., read the file Hierarchy.txt and the individual class definitions. 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.
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.
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:
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.
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.
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 . . .

View File

@@ -1,8 +1,19 @@
STK: A ToolKit of Audio Synthesis Classes and Instruments in C++
Release 3.2
The Synthesis ToolKit in C++ (STK)
By Perry R. Cook, 1995-2000
and Gary P. Scavone, 1997-2000
By Perry R. Cook and Gary P. Scavone, 1995-2002.
v4.0: (April 2002)
- new documentation and tutorial
- several new instruments, including Saxofony, BlowBotl, and StifKarp
- new Stk base class, replacing Object class
- new Filter class structure and methods
- extensive modifications to WvIn and WvOut class structures and methods
- looping functionality moved to WaveLoop (subclass of WvIn)
- automatic file type detection in WvIn ... hosed WavWvIn, AifWvIn, RawWavIn, SndWavIn, and MatWvIn subclasses
- new file type specifier argument in WvOut ... hosed WavWvOut, AifWvOut, RawWavOut, SndWavOut, and MatWvOut subclasses
- some simplifications of Messager class (was Controller)
- new independent RtAudio class
- extensive revisions in code and a significant number of API changes
v3.2: (13 November 2000)
- new control handling class (Controller)

View File

@@ -1,10 +1,8 @@
This describes the 1.1 implementation of SKINI,
updated for the 2.x release of STK:
This describes the latest (version 1.1) implementation of SKINI.
Synthesis toolKit Instrument Network Interface
for the Synthesis Toolkit in C++ by Perry R. Cook
and Gary Scavone, 1999.
for the Synthesis Toolkit in C++ by Perry R. Cook.
*********************************
* Too good to be true? *
@@ -72,8 +70,8 @@ upon/from which to build and depart.
I am basically a bottom-up designer with an awareness of top-
down design ideas, so SKINI above all reflects the needs of my
particular research and creative projects as they have arisen and
developed. SKINI11 represents a profound advance beyond SKINI08
and SKINI09 (the first versions), future SKINI's might
developed. SKINI 1.1 represents a profound advance beyond
versions 0.8 and 0.9 (the first versions), future SKINI's might
reflect some changes. Compatibility with prior scorefiles
will be attempted, but there aren't that many scorefiles out
there yet.
@@ -87,7 +85,7 @@ upon/from which to build and depart.
the channel number is scanned as a long int. Channels could be socket
numbers, machine IDs, serial numbers, or even unique tags for each
event in a synthesis. Other fields might be used, as specified in the
SKINI11.tbl file. This is described in more detail later.
SKINI.tbl file. This is described in more detail later.
Fields in a SKINI line are delimited by spaces, commas, or
tabs. The SKINI parser only operates on a line at a time,
@@ -103,7 +101,7 @@ upon/from which to build and depart.
NonMIDI message types include SetPath (sets a path for file
use later), and OpenReadFile (for streaming, mixing, and applying
effects to soundfiles along with synthesis, for example).
Other NonMIDI message types include Trilling, HammerOn, etc. (these
Other non-MIDI message types include Trilling, HammerOn, etc. (these
translate to gestures, behaviors, and contexts for use by
intellegent players and instruments using SKINI). Where possible
I will still use these as MIDI extension messages, so foot
@@ -111,31 +109,31 @@ upon/from which to build and depart.
All fields other than type, time, and channel are optional, and the
types and useage of the additional fields is defined in the file
SKINI11.tbl.
SKINI.tbl.
The other important file used by SKINI is SKINI11.msg, which is a
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.
4) C Files Used To Implement SKINI11
4) C Files Used To Implement SKINI
SKINI11.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
receiving SKINI messages a line at a time, usually in real time,
but not restricted to real time.
SKINI11.msg should be included by anything wanting to use the
SKINI11.cpp object. This is not mandatory, but use of the __SK_blah_
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.
SKINI11.tbl is used only by the SKINI parser object (SKINI11.cpp).
In the file SKINI11.tbl, an array of structures is declared and
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
@@ -159,29 +157,28 @@ upon/from which to build and depart.
message line. (We might allow for multiple messages per
line later using the semicolon, but probably not. A series
of lines with deltaTimes of 0.0 denotes simultaneous events.
For Readability, multiple messages per line doesn't help much,
For read-ability, multiple messages per line doesn't help much,
so it's unlikely to be supported later).
d) The first field must be a SKINI message name. (like NoteOn).
These might become case-insensitive in SKINI11+, so don't plan
on exciting clever overloading of names (like noTeOn being
These might become case-insensitive in future versions, so don't
plan on exciting clever overloading of names (like noTeOn being
different from NoTeON). There can be a number of leading
spaces or tabs, but don't exceed 32 or so.
e) The second field must be a time specification in seconds.
For real-time applications, this field can be 0.0. A time
field can be either delta-time (most common and the only one
supported in SKINI0.8), or absolute time. Absolute time
A time field can be either delta-time (most common and the only one
supported in version 0.8), or absolute time. Absolute time
messages have an '=' appended to the beginning of the floating
point number with no space. So 0.10000 means delta time of
100ms., while =0.10000 means absolute time of 100 ms. Absolute
100 ms, while =0.10000 means absolute time of 100 ms. Absolute
time messages make most sense in score files, but could also be
used for (loose) synchronization in a real-time context. Real
time messages should be time-ordered AND time-correct. That is,
if you've sent 100 total delta-time messages of 1.0 seconds, and
then send an absolute time message of =90.0 seconds, or if you
send two absolute time messages of =100.0 and =90.0 in that
order, things will get really fouled up. The SKINI1.1 parser
order, things will get really fouled up. The SKINI parser
doesn't know about time, however. The WvOut device is the
master time keeper in the Synthesis Toolkit, so it should be
queried to see if absolute time messages are making sense.
@@ -198,7 +195,7 @@ upon/from which to build and depart.
A -1 channel can be used as don't care, omni, or other functions
depending on your needs and taste.
g) All remaining fields are specified in the SKINI11.tbl file.
g) All remaining fields are specified in the SKINI.tbl file.
In general, there are maximum two more fields, which are either
SK_INT (long), SK_DBL (double float), or SK_STR (string). The
latter is the mechanism by which more arguments can be specified
@@ -208,7 +205,7 @@ upon/from which to build and depart.
6) A Short SKINI File:
/* Howdy!!! Welcome to SKINI11, by P. Cook 1999
/* Howdy!!! Welcome to SKINI, by P. Cook 1999
NoteOn 0.000082 2 55 82
NoteOff 1.000000 2 55 0
@@ -240,10 +237,10 @@ upon/from which to build and depart.
NoteOff 0.000000 2 71 82
NoteOff 0.000000 2 79 82
7) The SKINI11.tbl File, How Messages are Parsed
7) The SKINI.tbl File, How Messages are Parsed:
The SKINI11.tbl file contains an array of structures which
are accessed by the parser object SKINI11.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:
struct SKINISpec { char messageString[32];
long type;
@@ -272,14 +269,14 @@ upon/from which to build and depart.
scanning the string to EndOfLine and then passing
it to a more intellegent handler. For example,
MIDI SYSEX (system exclusive) messages of up to
256bytes can be read as space-delimited integers
256 bytes can be read as space-delimited integers
into the 1K SK_STR buffer. Longer bulk dumps,
soundfiles, etc. should be handled as a new
message type pointing to a FileName, Socket, or
something else stored in the SK_STR field, or
as a new type of multi-line message.
Here's a couple of lines from the SKINI11.tbl file
Here's a couple of lines from the SKINI.tbl file
{"NoteOff" , __SK_NoteOff_, SK_DBL, SK_DBL},
{"NoteOn" , __SK_NoteOn_, SK_DBL, SK_DBL},
@@ -287,13 +284,13 @@ upon/from which to build and depart.
{"ControlChange" , __SK_ControlChange_, SK_INT, SK_DBL},
{"Volume" , __SK_ControlChange_, __SK_Volume_ , SK_DBL},
{"StringDamping" , __SK_ControlChange_, __SK_StringDamping_ , SK_DBL},
{"StringDetune" , __SK_ControlChange_, __SK_StringDetune_ , SK_DBL},
{"StringDamping" , __SK_ControlChange_, __SK_StringDamping_, SK_DBL},
{"StringDetune" , __SK_ControlChange_, __SK_StringDetune_, SK_DBL},
The first three are basic MIDI messages. The first two would cause the
parser, after recognizing a match of the string "NoteOff" or "NoteOn",
to set the message type to 128 or 144 (__SK_NoteOff_ and __SK_NoteOn_
are #defined in the file SKINI11.msg to be the MIDI byte value, without
are #defined in the file SKINI.msg to be the MIDI byte value, without
channel, of the actual MIDI messages for NoteOn and NoteOff). The parser
would then set the time or delta time (this is always done and is
therefore not described in the SKINI Message Struct). The next two
@@ -329,37 +326,36 @@ upon/from which to build and depart.
to read a SKINI file and control a single instrument.
instrument = new Mandolin(50.0);
score = new SKINI11(argv[1]);
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");
printf("Bad News Here!!! Backward Absolute Time Required.\n");
tempDouble = 0.0;
}
}
tempLong = (long) (tempDouble * SRATE);
tempLong = (long) (tempDouble * Stk::sampleRate());
for (i=0;i<tempLong;i++) {
output.tick(instrument->tick());
}
tempDouble3 = score->getByteThree();
if (score->getType()== __SK_NoteOn_ ) {
tempDouble3 *= NORM_7;
tempDouble3 *= NORM_MIDI;
if (score->getByteThree() == 0) {
tempDouble3 = 0.5;
instrument->noteOff(tempDouble3);
}
else {
tempLong = (int) score->getByteTwo();
tempDouble2 = __MIDI_To_Pitch[tempLong];
tempDouble2 = Midi2Pitch[tempLong];
instrument->noteOn(tempDouble2,tempDouble3);
}
}
else if (score->getType() == __SK_NoteOff_) {
tempDouble3 *= NORM_7;
tempDouble3 *= NORM_MIDI;
instrument->noteOff(tempDouble3);
}
else if (score->getType() == __SK_ControlChange_) {
@@ -369,7 +365,7 @@ Required.\n");
score->nextMessage();
}
When the score (SKINI11 object) object is created from the
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.

155
doc/doxygen/Doxyfile Normal file
View File

@@ -0,0 +1,155 @@
# Doxyfile 1.2.6
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = STK
PROJECT_NUMBER =
OUTPUT_DIRECTORY = .
OUTPUT_LANGUAGE = English
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = YES
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
INTERNAL_DOCS = NO
CLASS_DIAGRAMS = YES
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
VERBATIM_HEADERS = YES
SHOW_INCLUDE_FILES = YES
JAVADOC_AUTOBRIEF = NO
INHERIT_DOCS = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
ENABLED_SECTIONS =
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
ALIASES =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = NO
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = index.txt information.txt classes.txt download.txt usage.txt maillist.txt system.txt tutorial.txt skini.txt ../../include/
FILE_PATTERNS = *.h
RECURSIVE = NO
EXCLUDE =
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = ../html
HTML_HEADER = header.html
HTML_FOOTER = footer.html
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = YES
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
COMPACT_LATEX = NO
PAPER_TYPE = letter
EXTRA_PACKAGES =
LATEX_HEADER = header.tex
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_PATH =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
CGI_NAME = search.cgi
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH = /usr/local/bin/
EXT_DOC_PATHS =

10
doc/doxygen/classes.txt Normal file
View File

@@ -0,0 +1,10 @@
/*! \page classes Class Documentation
<UL>
<LI><a class="qindex" href="hierarchy.html">Class Hierarchy</a></LI>
<LI><a class="qindex" href="annotated.html">Class/Enum List</a></LI>
<LI><a class="qindex" href="files.html">File List</a></LI>
<LI><a class="qindex" href="functions.html">Compound Members</a></LI>
</UL>
*/

115
doc/doxygen/download.txt Normal file
View File

@@ -0,0 +1,115 @@
/*! \page download Download and Release Notes
<B>Version 4.0, 30 April 2002</B><P>
<A HREF="Release/stk-4.0.tar.gz">STK Version 4.0: Source distribution</A> (1.64 MB tar/gzipped)<BR>
<A HREF="Release/stk-4.0.binaries.tar.gz">STK Version 4.0: Source distribution with precompiled windows binaries</A> (2.26 MB tar/gzipped)<BR>
<P>
\section notes Release Notes:
\subsection v4 Version 4.0
<UL>
<LI>New documentation and tutorial.</LI>
<LI>Several new instruments, including Saxofony, BlowBotl, and StifKarp.</LI>
<LI>New Stk base class, replacing Object class.</LI>
<LI>New Filter class structure and methods.</LI>
<LI>Extensive modifications to WvIn and WvOut class structures and methods.</LI>
<LI>Looping functionality moved to WaveLoop (subclass of WvIn).</LI>
<LI>Automatic file type detection in WvIn ... hosed WavWvIn, AifWvIn, RawWavIn, SndWavIn, and MatWvIn subclasses.</LI>
<LI>New file type specifier argument in WvOut ... hosed WavWvOut, AifWvOut, RawWavOut, SndWavOut, and MatWvOut subclasses.</LI>
<LI>Some simplifications of Messager class (was Controller).</LI>
<LI>New independent RtAudio class.</LI>
<LI>Extensive revisions in code and a significant number of API changes.</LI>
</UL>
\subsection v3dot2 Version 3.2
<UL>
<LI>New input control handling class (Controller)</LI>
<LI>Added AIFF file input/output support.</LI>
<LI>New C++ error handling capabilities.</LI>
<LI>New input/output internet streaming support (StrmWvIn/StrmWvOut).</LI>
<LI>Added native ALSA support for linux.</LI>
<LI>Added optional "device" argument to all "Rt" classes (audio and MIDI) and printout of devices when argument is invalid.</LI>
<LI>WvIn classes rewritten to support very big files (incremental load from disk).</LI>
<LI>Changed WvIn/WvOut classes to work with sample frame buffers.</LI>
<LI>Fixed looping and negative rate calculations in WvIn classes.</LI>
<LI>Fixed interpolation bug in RtWvIn.</LI>
<LI>Windoze RtAudio code rewritten (thank Dave!).</LI>
<LI>Simplified byte-swapping functions (in-place swapping).</LI>
<LI>"Stereo-ized" RagaMatic.</LI>
<LI>Miscellaneous renamings.</LI>
<LI>Probably a bunch more fixes that I've long since forgotten about.</LI>
</UL>
\subsection v3dot1 Version 3.1
<UL>
<LI>New RagaMatic project ... very cool!!!</LI>
<LI>Less clipping in the Shakers class.</LI>
<LI>Added "microphone position" to Mandolin in STKdemo.</LI>
<LI>Fixed MIDI system message exclusion under Irix.</LI>
<LI>Added a few bitmaps for the Shaker instruments.</LI>
<LI>Made destructors virtual for Reverb.h, WvIn.h and Simple.h.</LI>
<LI>Fixed bug setting delay length in DLineA when value too big.</LI>
<LI>Fixed bug in WinMM realtime code (RTSoundIO).</LI>
<LI>Added tick() method to BowTabl, JetTabl, and ReedTabl (same as lookup).</LI>
<LI>Switched to pthread API on SGI platforms.</LI>
<LI>Added some defines to Object.h for random number generation, FPU overflow checking, etc....</LI>
<LI>A few minor changes, some bug fixes ... can't remember all of them.</LI>
</UL>
\subsection v3 Version 3.0
<UL>
<LI>New #define flags for OS and realtime dependencies (this will probably cause problems for old personal STK code, but it was necessary to make future ports easier).</LI>
<LI>Expanded and cleaned the Shakers class.</LI>
<LI>New BowedBar algorithm/class.</LI>
<LI>Fixed Linux MIDI input bug.</LI>
<LI>Fixed MIDI status masking problem in Windows.</LI>
<LI>OS type defines now in Makefile.</LI>
<LI>New RAWWAVE_PATH define in Object.h.</LI>
<LI>Syntmono project pulled out to separate directory and cleaned up.</LI>
<LI>Socketing capabilities under Unix, as well as Windoze.</LI>
<LI>Multiple simultaneous socket client connections to STK servers now possible.</LI>
<LI>MD2SKINI now can merge MIDI and piped messages under Irix and Linux (for TCL->MD2SKINI->syntmono control).</LI>
<LI>Defined INT16 and INT32 types and fixed various WvIn and WvOut classes.</LI>
<LI>Updated MatWvIn and MatWvOut for new MAT-file documentation from Matlab.</LI>
<LI>New demo Tcl/Tk GUI (TclDemo.tcl).</LI>
<LI>Minor fixes to FM behavior.</LI>
<LI>Added record/duplex capabilities to RTSoundIO (Linux, SGI, and Windoze).</LI>
<LI>Fixed bugs in WavWvOut and MatWvOut header specifications.</LI>
<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>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>
</UL>
\subsection v2dot02 Version 2.02
<UL>
<LI>Created RawWave abstract class, with subclasses of RawLoop (looping rawwave oscillator), RawShot (non-looping, non-interpolating rawwave player ... used to be RawWvIn), and RawInterp (looping or non-looping, interpolating rawwave player ... used to be RawWave).</LI>
<LI>Modified DrumSynt to correctly handle sample rates different than 22050 Hz.</LI>
<LI>Modified syntmono parsing vs. tick routine so that some ticking occurs between each message. When multiple messages are waiting to be processed, the time between message updates is inversely proportional to the number of messages in the buffer.</LI>
<LI>Fixed DirectSound playback bug in WinXX distribution. Sound was being played at 8-bit, 22 kHz in all cases. Playback is now 16-bit and dependent on SRATE.</LI>
<LI>Fixed bug in MD2SKINI which prevented some NoteOff statements from being output.</LI>
<LI>This distribution includes an example STK project, mus151, which demonstrates a means for keeping a user's personal projects separate from the main distribution. This is highly recommended, in order to simplify upgrades to future STK releases.</LI>
</UL>
\subsection v2 Version 2
<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>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.
</UL>
*/

9
doc/doxygen/footer.html Normal file
View File

@@ -0,0 +1,9 @@
<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>&copy;1995-2002 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
</table>
</BODY>
</HTML>

10
doc/doxygen/header.html Normal file
View File

@@ -0,0 +1,10 @@
<HTML>
<HEAD>
<TITLE>The Synthesis ToolKit in C++ (STK)</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<img src="princeton.gif"> &nbsp; <img src="ccrma.gif"><P>
<a class="qindex" href="index.html">Home</a> &nbsp; <a class="qindex" href="information.html">Information</a> &nbsp; <a class="qindex" href="classes.html">Classes</a> &nbsp; <a class="qindex" href="download.html">Download</a> &nbsp; <a class="qindex" href="usage.html">Usage</a> &nbsp; <a class="qindex" href="maillist.html">Mail List</a> &nbsp; <a class="qindex" href="system.html">Requirements</a> &nbsp; <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
<HR>

31
doc/doxygen/header.tex Normal file
View File

@@ -0,0 +1,31 @@
\documentclass[letter]{book}
\usepackage{makeidx}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{float}
\usepackage{alltt}
\usepackage{doxygen}
\usepackage{hyperref}
\makeindex
\setcounter{tocdepth}{1}
\setlength{\footrulewidth}{0.4pt}
\begin{document}
\begin{titlepage}
\vspace*{7cm}
\begin{center}
{\Large User Manual}\\
\vspace*{0.5cm}
{\Large The Synthesis ToolKit in C++}\\
\vspace*{1cm}
{\large by Perry R. Cook and Gary P. Scavone}\\
\vspace*{0.5cm}
{\small \copyright 1995--2002}\\
\end{center}
\end{titlepage}
\clearemptydoublepage
\pagenumbering{roman}
\rfoot[\fancyplain{}{\bfseries\scriptsize The Synthesis ToolKit in C++ by Perry R. Cook and Gary P. Scavone, \copyright~1995--2002}]{}
\lfoot[]{\fancyplain{}{\bfseries\scriptsize The Synthesis ToolKit in C++ by Perry R. Cook and Gary P. Scavone, \copyright~1995--2002}}
\tableofcontents
\clearemptydoublepage
\pagenumbering{arabic}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

15
doc/doxygen/index.txt Normal file
View File

@@ -0,0 +1,15 @@
/*! \mainpage <I>The Synthesis ToolKit in C++ (STK)</I>
<BODY BGCOLOR="white">
The <B>Synthesis ToolKit in C++ (STK)</B> is a set of audio signal processing and synthesis classes and algorithms written in C++. You can use these classes to create programs that make sounds with a variety of synthesis techniques. This is not a terribly novel concept, except that the Synthesis ToolKit is extremely portable (it's mostly platform-independent C and C++ code), and it's completely user-extensible (no libraries, no hidden drivers, and all source code is included). 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, 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
- \ref download
- \ref usage
- \ref maillist
- \ref system
- \ref tutorial
*/

View File

@@ -0,0 +1,50 @@
/*! \page information General Information
<H3>References</H3>
<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++.
<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++.
<P>
<LI><A HREF="http://www.cs.princeton.edu/~prc/NewWork.html#STK">Perry's STK Web Page</A></LI>
<BR>
This is a link to Perry Cook's STK Web page. He has information about the \ref skini, the protocol used to control STK instruments, as well as a lot of other cool stuff.
</UL>
<H4>What is the <I>Synthesis ToolKit</I>?</H4>
The Synthesis ToolKit in C++ (STK) is a set of audio signal processing and synthesis classes and algorithms written in C++. You can use these classes to create programs that make sounds with a variety of synthesis techniques. This is not a terribly novel concept, except that the Synthesis ToolKit is extremely portable (it's mostly platform-independent C and C++ code), and it's completely user-extensible (no libraries, no hidden drivers, and all source code is included). 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, 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.
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).
<H4>A brief history of the <I>Synthesis ToolKit in C++.</I></H4>
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.
<H4>Legal and Ethical Notes</H4>
This software was designed and created to be made publicly available for free, primarily for academic purposes, so if you use it, pass it on with this documentation, and for free. If you make a million dollars with it, give us some. If you make compositions with it, put us in the program notes.
<P>
Some of the concepts are covered by various patents, some known to us and likely others which are unknown. Many of the ones known to us are administered by the Stanford Office of Technology and Licensing. The good news is that large hunks of the techniques used here are public domain. To avoid subtle legal issues, we will not state what's freely useable here, but we will try to note within the various classes where certain things are likely to be protected by patents.
<H4>Disclaimer</H4>
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.
*/

12
doc/doxygen/maillist.txt Normal file
View File

@@ -0,0 +1,12 @@
/*! \page maillist The Mail List
An <A HREF="mailto:stk-request@ccrma.stanford.edu">STK</A> mailing list has been set up to facilitate communication among STK users. Subscribing to this list is your best way of keeping on top of new releases, bug fixes, and various user developments.
<P>
To join send a message to <A HREF="mailto:stk-request@ccrma.stanford.edu">&lt;stk-request@ccrma.stanford.edu&gt;</A>
with the contents: <TT>subscribe</TT>
<P>
To be removed from the list send a message to <A HREF="mailto:stk-request@ccrma.stanford.edu">&lt;stk-request@ccrma.stanford.edu&gt;</A>
with the contents: <TT>unsubscribe</TT>
*/

218
doc/doxygen/skini.txt Normal file
View File

@@ -0,0 +1,218 @@
/*! \page skini Synthesis toolKit Instrument Network Interface (SKINI)
This describes the latest (version 1.1) implementation of SKINI for the Synthesis Toolkit in C++ (STK) by Perry R. Cook.
\code
Too good to be true?
Have control and read it too?
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.
\section compatibility MIDI Compatibility
SKINI was designed to be MIDI compatible wherever possible, and extend MIDI in incremental, then maybe profound ways.
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.
- 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 50cent 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.
\section why Why SKINI?
SKINI was designed to be extensable and hackable for a number of applications: imbedded synthesis in a game or VR simulation, scoring and mixing tasks, real-time and non-real time applications which could benefit from controllable sound synthesis, JAVA controlled synthesis, or eventually maybe JAVA synthesis, etc. SKINI is not intended to be "the mother of scorefiles," but since the entire system is based on text representations of names, floats, and ints, converters from one scorefile language to SKINI, or back, should be easily created.
I am basically a bottom-up designer with an awareness of top-down design ideas, so SKINI above all reflects the needs of my particular research and creative projects as they have arisen and developed. SKINI 1.1 represents a profound advance beyond versions 0.8 and 0.9 (the first versions), future SKINI's might reflect some changes. Compatibility with prior scorefiles will be attempted, but there aren't that many scorefiles out there yet.
\section messages SKINI Messages
A basic SKINI message is a line of text. There are only three required fields, the message type (an ASCII name), the time (either delta or absolute), and the channel number. Don't freak out and think that this is MIDI channel 0-15 (which is supported), because the channel number is scanned as a long int. Channels could be socket numbers, machine IDs, serial numbers, or even unique tags for each event in a synthesis. Other fields might be used, as specified in the SKINI.tbl file. This is described in more detail later.
Fields in a SKINI line are delimited by spaces, commas, or tabs. The SKINI parser only operates on a line at a time, so a newline means the message is over. Multiple messages are NOT allowed directly on a single line (by use of the ; for example in C). This could be supported, but it isn't in version 1.1.
Message types include standard MIDI types like NoteOn, NoteOff, ControlChange, etc. MIDI extension message types (messages which look better than MIDI but actually get turned into MIDI-like messages) include LipTension, StringDamping, etc. Non-MIDI message types include SetPath (sets a path for file use later), and OpenReadFile (for streaming, mixing, and applying effects to soundfiles along with synthesis, for example). Other non-MIDI message types include Trilling, HammerOn, etc. (these translate to gestures, behaviors, and contexts for use by intellegent players and instruments using SKINI). Where possible I will still use these as MIDI extension messages, so foot switches, etc. can be used to control them in real time.
All fields other than type, time, and channel are optional, and the types and useage of the additional fields is defined in the file SKINI.tbl.
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
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.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.
\section parser SKINI Messages and the SKINI Parser:
The parser isn't all that smart, but neither am I. Here are the basic rules governing a valid SKINI message:
- If the first (non-delimiter ... see below) character in a SKINI string is '/' that line is treated as a comment and echoed to stdout.
- If there are no characters on a line, that line is treated as blank and echoed to stdout. Tabs and spaces are treated as non-characters.
- Spaces, commas, and tabs delimit the fields in a SKINI message line. (We might allow for multiple messages per line later using the semicolon, but probably not. A series of lines with deltaTimes of 0.0 denotes simultaneous events. For read-ability, multiple messages per line doesn't help much, so it's unlikely to be supported later).
- The first field must be a SKINI message name (like NoteOn). These might become case-insensitive in future versions, so don't plan on exciting clever overloading of names (like noTeOn being different from NoTeON). There can be a number of leading spaces or tabs, but don't exceed 32 or so.
- The second field must be a time specification in seconds. A time field can be either delta-time (most common and the only one supported in version 0.8), or absolute time. Absolute time messages have an '=' appended to the beginning of the floating point number with no space. So 0.10000 means delta time of 100 ms, while =0.10000 means absolute time of 100 ms. Absolute time messages make most sense in score files, but could also be used for (loose) synchronization in a real-time context. Real-time messages should be time-ordered AND time-correct. That is, if you've sent 100 total delta-time messages of 1.0 seconds, and then send an absolute time message of =90.0 seconds, or if you send two absolute time messages of =100.0 and =90.0 in that order, things will get really fouled up. The SKINI parser doesn't know about time, however. The WvOut device is the master time keeper in the Synthesis Toolkit, so it should be queried to see if absolute time messages are making sense. There's an example of how to do that later in this document. Absolute times are returned by the parser as negative numbers (since negative deltaTimes are not allowed).
- The third field must be an integer channel number. Don't go crazy and think that this is just MIDI channel 0-15 (which is supported). The channel number is scanned as a long int. Channels 0-15 are in general to be treated as MIDI channels. After that it's wide open. Channels could be socket numbers, machine IDs, serial numbers, or even unique tags for each event in a synthesis. A -1 channel can be used as don't care, omni, or other functions depending on your needs and taste.
- All remaining fields are specified in the SKINI.tbl file. In general, there are maximum two more fields, which are either SK_INT (long), SK_DBL (double float), or SK_STR (string). The latter is the mechanism by which more arguments can be specified on the line, but the object using SKINI must take that string apart (retrived by using getRemainderString()) and scan it. Any excess fields are stashed in remainderString.
\section file A Short SKINI File:
\code
/* Howdy!!! Welcome to SKINI, by P. Cook 1999
NoteOn 0.000082 2 55 82
NoteOff 1.000000 2 55 0
NoteOn 0.000082 2 69 82
StringDetune 0.100000 2 10
StringDetune 0.100000 2 30
StringDetune 0.100000 2 50
NoteOn 0.000000 2 69 82
StringDetune 0.100000 2 40
StringDetune 0.100000 2 22
StringDetune 0.100000 2 12
//
StringDamping 0.000100 2 0.0
NoteOn 0.000082 2 55 82
NoteOn 0.200000 2 62 82
NoteOn 0.100000 2 71 82
NoteOn 0.200000 2 79 82
NoteOff 1.000000 2 55 82
NoteOff 0.000000 2 62 82
NoteOff 0.000000 2 71 82
NoteOff 0.000000 2 79 82
StringDamping =4.000000 2 0.0
NoteOn 0.000082 2 55 82
NoteOn 0.200000 2 62 82
NoteOn 0.100000 2 71 82
NoteOn 0.200000 2 79 82
NoteOff 1.000000 2 55 82
NoteOff 0.000000 2 62 82
NoteOff 0.000000 2 71 82
NoteOff 0.000000 2 79 82
\endcode
\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:
\code
struct SKINISpec {
char messageString[32];
long type;
long data2;
long data3;
};
\endcode
so an assignment of one of these structs looks like:
\code
MessageStr$ ,type, data2, data3,
\endcode
<TT>type</TT> is the message type sent back from the SKINI line parser.
<TT>data<n></TT> 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.
- SK_INT : byte (actually scanned as 32 bit signed long int). 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, MIDI SYSEX (system exclusive) messages of up to 256 bytes can be read as space-delimited integers into the 1K SK_STR buffer. Longer bulk dumps, soundfiles, etc. should be handled as a new message type pointing to a FileName, Socket, or something else stored in the SK_STR field, or as a new type of multi-line message.
Here's a couple of lines from the SKINI.tbl file
\code
{"NoteOff" , __SK_NoteOff_, SK_DBL, SK_DBL},
{"NoteOn" , __SK_NoteOn_, SK_DBL, SK_DBL},
{"ControlChange" , __SK_ControlChange_, SK_INT, SK_DBL},
{"Volume" , __SK_ControlChange_, __SK_Volume_ , SK_DBL},
{"StringDamping" , __SK_ControlChange_, __SK_StringDamping_, SK_DBL},
{"StringDetune" , __SK_ControlChange_, __SK_StringDetune_, SK_DBL},
\endcode
The first three are basic MIDI messages. The first two would cause the parser, after recognizing a match of the string "NoteOff" or "NoteOn", to set the message type to 128 or 144 (__SK_NoteOff_ and __SK_NoteOn_ are #defined in the file SKINI.msg to be the MIDI byte value, without channel, of the actual MIDI messages for NoteOn and NoteOff). The parser would then set the time or delta time (this is always done and is therefore not described in the SKINI Message Struct). The next two fields would be scanned as double-precision floats and assigned to the byteTwo and byteThree variables of the SKINI parser. The remainder of the line is stashed in the remainderString variable.
The ControlChange spec is basically the same as NoteOn and NoteOff, but the second data byte is set to an integer (for checking later as to what MIDI control is being changed).
The Volume spec is a MIDI Extension message, which behaves like a ControlChange message with the controller number set explicitly to the value for MIDI Volume (7). Thus the following two lines would accomplish the same changing of MIDI volume on channel 2:
\code
ControlChange 0.000000 2 7 64.1
Volume 0.000000 2 64.1
\endcode
I like the 2nd line better, thus my motivation for SKINI in the first place.
The StringDamping and StringDetune messages behave the same as the Volume message, but use Control Numbers which aren't specifically nailed-down in MIDI. Note that these Control Numbers are carried around as long ints, so we're not limited to 0-127. If, however, you want to use a MIDI controller to play an instrument, using controller numbers in the 0-127 range might make sense.
\section using Using SKINI:
Here's a simple example of code which uses the SKINI object to read a SKINI file and control a single instrument.
\code
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;
}
}
tempLong = (long) (tempDouble * Stk::sampleRate());
for (i=0;i<tempLong;i++) {
output.tick(instrument->tick());
}
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 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();
}
\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.
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.
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 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.
*/

29
doc/doxygen/system.txt Normal file
View File

@@ -0,0 +1,29 @@
/*! \page system System Requirements
<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 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>
</UL>
<B>Windows95/98/2000/XP (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.microsoft.com/directx/">DirectX</A> 5.0 (or higher) runtime libraries to use the precompiled binaries.</LI>
<LI>Visual C++ 6.0 for compiling (though a precompiled distribution is available).</LI>
<LI>For compiling the source (if not already in your system): <UL><LI><A HREF="Misc/dsound.h">dsound.h</A> header file (DirectX 6.1) - put somewhere in your header search path</LI><LI><A HREF="Misc/dsound.lib">dsound.lib</A> library file (DirectX 6.1) - put somewhere in your library search path</LI></UL></LI>
</UL>
<B>WindowsNT (specific)</B>
<UL>
<LI>STK is no longer supported under WindowsNT because DirectX support for NT is minimal. Unless DirectX 5.0 or higher becomes available for NT, STK won't work.</LI>
</UL>
<P>
*/

149
doc/doxygen/tutorial.txt Normal file
View File

@@ -0,0 +1,149 @@
/*! \page tutorial Tutorial
- \ref intro
- \ref start
- \ref compile
- \ref rtvsnonrt
\section intro Introduction
First and foremost, the Synthesis ToolKit is a set of C++ classes. That means you need to know some basics about programming in C++ to make use of STK (beyond the example programs we provide). STK's "target audience" is people who:
<UL>
<LI>already know how to program in C and C++</LI>
<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>know C, but 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>
</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.).
\section start Getting Started
We'll begin our introduction to the Synthesis ToolKit with a simple sine-wave oscillator program. STK doesn't 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. The class RtWvOut will send "realtime" samples to the audio output hardware on your computer.
\code
// sineosc.cpp
#include "WaveLoop.h"
#include "RtWvOut.h"
int main()
{
// Set the global sample rate before creating class instances.
Stk::setSampleRate( 44100.0 );
// Define and load the sine wave file
WaveLoop *input = new WaveLoop("sinewave.raw", TRUE);
input->setFrequency(440.0);
// Define and open the default realtime output device for one-channel playback
RtWvOut *output = new RtWvOut(1);
// Play the oscillator for 40000 samples
for (int i=0; i<40000; i++) {
output->tick( input->tick() );
}
// Clean up
delete input;
delete output;
return 0;
}
\endcode
WaveLoop is a subclass of WvIn, which supports 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. WvIn provides interpolating, read once ("oneshot") functionality, as well as methods for setting the read rate and read position.
Nearly all STK classes implement tick() methods which take and/or return sample values. Within the tick() method, the fundamental sample calculations are performed for a given class. Most STK classes consume/generate a single sample per operation and their tick() method takes/returns each sample "by value". In addition, every class implementing a tick() method also provides an overloaded tick() 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 tickFrame() functions. When a tick() 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 MY_FLOAT \#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.
Finally, STK 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 "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( "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
for (int i=0; i<40000; i++) {
try {
output->tick(input->tick());
}
catch (StkError &) {
goto cleanup;
}
}
cleanup:
delete input;
delete output;
return 0;
}
\endcode
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.
\section compile Compiling
\subsection compileLinux Linux
In general, you will probably want to use a <TT>Makefile</TT> for your STK programs and projects. For this particular program, however, the following will suffice (on a linux system):
\code
g++ -Wall -D__LINUX_OSS__ -D__LITTLE_ENDIAN__ -o sineosc Stk.cpp WvIn.cpp WaveLoop.cpp WvOut.cpp RtWvOut.cpp RtAudio.cpp sineosc.cpp -lpthread
\endcode
This assumes you've set up a directory that includes the files <TT>sineosc.cpp</TT>, the rawwave file <TT>sinewave.raw</TT>, and the header and source files for the classes Stk, WvIn, WaveLoop, WvOut, RtWvOut, and RtAudio. There are other, more convenient, means for structuring projects that will be discussed later.
Most linux systems currently come installed with the OSS audio hardware drivers. If your system instead has ALSA audio drivers installed and you wish to make use of native ALSA API calls, a link to the ALSA library must be specified in the above compile statement (<TT>-lasound</TT>) and the preprocessor definition should instead be <TT>__LINUX_ALSA__</TT>.
\subsection compileIrix Irix
The irix (SGI) and linux operating systems are both flavors of unix and thus behave similarly. Making the same assumptions as in the linux case, the following compile statement should work:
\code
CC -Wall -D__IRIX_AL__ -o sineosc Stk.cpp WvIn.cpp WaveLoop.cpp WvOut.cpp RtWvOut.cpp RtAudio.cpp sineosc.cpp -lpthread
\endcode
\subsection compileWin Windows
I have personally only worked with Visual C++ when compiling programs under windoze. I'll assume you've become familiar with Visual C+ and don't need a tutorial on its particular idiosyncrasies. In creating the VC++ project, add the Stk, WvIn, WaveLoop, WvOut, RtWvOut, and RtAudio class files, as well as the <TT>sineosc.cpp</TT> and <TT>sinewave.raw</TT> files. You will also need to link to the DirectSound library (<TT>dsound.lib</TT>), select the multithreaded library, and provide the <TT>__WINDOWS_DS__</TT> and <TT>__LITTLE_ENDIAN__</TT> preprocessor definitions.
\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, and Windows (except Windows NT) systems using the <TT>__LINUX_OSS__</TT>, <TT>__LINUX_ALSA__</TT>, <TT>__IRIX_AL__</TT>, or <TT>__WINDOWS_DS__</TT> preprocessor definitions.
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.
\section continued To Be Continued ...
*/

183
doc/doxygen/usage.txt Normal file
View File

@@ -0,0 +1,183 @@
/*! \page usage Usage Documentation
- \ref directory
- \ref compiling
- \ref control
- \ref instruments
- \ref nort
- \ref rt
- \ref tcl
- \ref midi
<HR>
\section directory Directory Structure:
The top level distribution contains the following directories:
<UL>
<LI> The <I><B>src</B></I> directory contains the source .cpp files for almost all the STK unit generator and algorithm classes.</LI><P>
<LI> The <I><B>include</B></I> directory contains the header files for almost 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>doc</B></I> directory contains documentation about STK.</LI><P>
<LI> The <I><B>projects</B></I> directory contains various demo and example STK programs.</LI><P>
</UL>
This release of STK comes with four separate "project" directories:
<OL>
<LI> The <I><B>demo</B></I> project is used to demonstrate nearly all of the STK instruments. The <I><B>demo</B></I> program has been written to allow a variety of control input and sound data output options. %Simple graphical user interfaces (GUIs) are also provided.<P></LI>
<LI> The <I><B>effects</B></I> project demonstrates realtime duplex mode (simultaneous audio input and output) operation, when available, as well as various delay-line based effects algorithms.<P></LI>
<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>
</OL>
\section compiling Compiling:
<UL>
<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>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. Assuming your system has the <A HREF="http://gnu.cetcol.net.co/">GNU</A> Makefile utilities installed, typing <TT>make</TT> within a particular project directory will initiate the compilation process. The <TT>Makefile</TT> will have to be modified to change the default audio/MIDI system API and for big-endian processors. Special support exists under Linux for the MIDIator serial MIDI device, enabled using the __MIDIATOR__ preprocessor definition (together with either the __LINUX_ALSA__ or __LINUX_OSS__ definitions). See the README-Linux 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. If your system has the <A HREF="http://gnu.cetcol.net.co/">GNU</A> Makefile utilities installed, typing <TT>make</TT> (or <TT>gmake</TT>) within a particular project directory will initiate the compilation process. If your system does not have the GNU Makefile utilities, you should first try to download and install them. If this is not possible, a generic Makefile is provided with the <I><B>demo</B></I> project (Makefile.sgi). It can be invoked by typing <TT>make -f Makefile.sgi</TT> within that project directory. STK 4.0 is confirmed to compile using CC version 7.30. There may be problems with old compiler versions.</LI>
<LI><B>Windows95/98/2000/XP:</B> Realtime support is enabled with the <TT>__WINDOWS_DS__</TT> preprocessor definition and linkage with the <TT>dsound.lib</TT>, <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 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 file 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> I've given up trying to make things work under NT. You'll have to switch to Windows 2000 (which does seem to work).</LI>
</UL>
\section control Control Data:
All STK programs in this distribution take input control data in the form of <A HREF="skini.html">SKINI</A> or MIDI messages only. The Messager class unifies the various means of acquiring control data under a single, easy to use set of functions. The way that SKINI messages can be sent to the programs is dependent upon the operating system in use, as well as whether the program is running in realtime or not. In general, it is possible to:
<OL>
<LI>Redirect or pipe SKINI scorefiles to an executable.</LI>
<LI>Pipe realtime SKINI input messages to an executable (not possible under Windows95/98).</LI>
<LI>Socket realtime SKINI input messages to an executable.</LI>
<LI>Acquire realtime MIDI messages from a MIDI port on your computer.</LI>
</OL>
<A HREF="http://dev.scriptics.com">Tcl/Tk</A> graphical user interfaces (GUI) are provided with this distribution which can generate realtime SKINI messages. Note that the Messager class allows multiple simultaneous socket client connections, together with MIDI and/or piped input. The <I><B>Md2Skini</B></I> program (in the <I><B>demo</B></I> directory) is mostly obsolete but can be used to create SKINI scorefiles from realtime MIDI input.
\section instruments Demo: STK Instruments
The <I><B>demo</B></I> project demonstrates the behavior of all the distributed STK instruments. The instruments available with this release include:
<UL>
<LI>Clarinet: Pretty good physical model of the clarinet</LI>
<LI>BlowHole: A clarinet physical model with one tonehole and one register vent</LI>
<LI>Saxofony: A psuedo-conical bore reed instrument which sometimes sounds like a saxophone</LI>
<LI>Flute: Pretty good physical model of the flute</LI>
<LI>Brass: Not so bad physical model of a brass instrument</LI>
<LI>BlowBotl: A basic helmholtz resonator and air jet model</LI>
<LI>Bowed: Not hideous physical model of a bowed string instrument</LI>
<LI>Plucked: Yer basic plucked string physical model</LI>
<LI>StifKarp: A simple plucked, stiff string physical model</LI>
<LI>Sitar: A simple sitar/plucked string physical model</LI>
<LI>Mandolin: Two-string mandolin physical model</LI>
<LI>Rhodey: Rhodes-like electric piano FM synthesis model</LI>
<LI>Wurley: Wurlitzer-like electric piano FM synthesis model</LI>
<LI>TubeBell: FM synthesis model</LI>
<LI>HevyMetl: Distorted synthesizer FM synthesis model</LI>
<LI>PercFlut: Percussive flute-like FM synthesis model</LI>
<LI>BeeThree: Cheezy organ FM synthesis model</LI>
<LI>Moog: Swept filter sampler</LI>
<LI>FMVoices: Three-formant FM voice synthesis</LI>
<LI>Resonate: Noise through a BiQuad filter</LI>
<LI>Drummer: Sampling synthesis</LI>
<LI>BandedWG: Banded waveguide meta-object for bowed bars, tibetan bowls, etc.</LI>
<LI>Shakers: Various stochastic event models of shaker instruments</LI>
<LI>ModalBar: Various four-resonance presets (marimba, vibraphone, etc...)</LI>
<LI>Mesh2D: Two-dimensional, rectilinear digital waveguide mesh</LI>
</UL>
\section nort Demo: Non-Realtime Use
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 -w myfile.wav
\endcode
or (on WindowsXX and/or Unix)
\code
demo BeeThree -w 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.
\section rt Demo: Realtime Use
STK realtime audio and MIDI input/output and realtime SKINI control input via socketing support is provided for Linux, SGI, and Windows95/98/2000/XP operating systems. STK realtime SKINI control input via piping is possible under Linux, SGI, and Windows2000/XP only.
<P>
Control input and audio output options are typically specified as command-line arguments to STK programs. For example, the <I><B>demo</B></I> program is invoked as:
\code
demo instrument flags
\endcode
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>-ip</I> or <I>-is</I> for realtime SKINI control input via piping or socketing, respectively,</LI>
<LI><I>-im <file name></I> for MIDI control input</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.
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
\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.
\section tcl Realtime Control Input using Tcl/Tk Graphical User Interfaces:
There are a number of <A HREF="http://dev.scriptics.com">Tcl/Tk</A> GUIs supplied with the STK projects. These scripts require Tcl/Tk version 8.0 or later, which can be downloaded for free over the WWW. On Unix and Windows2000/XP platforms, you can run the various executable scripts (e.g. StkDemo.bat) provided with each project to start everything up (you may need to symbolically link the wish80 executable to the name <I>wish</I>). The PhysicalDemo script just implements the following command-line sequence:
\code
wish < tcl/Physical.tcl | demo Clarinet -or -ip
\endcode
On WindowsXX and Unix platforms, the following operations are necessary to establish a socket connection between the Tcl/Tk GUI and the STK program:
<OL>
<LI>Open a DOS shell and start the STK program with the <I>-is</I> flag (ex. <I><B>demo Clarinet -or -is</B></I>).</LI>
<LI>Open the Tcl/Tk GUI (e.g. tcl/Physical.tcl) by double-clicking on it, or type <TT>wish < tcl/Physical.tcl</TT> in another DOS shell.</LI>
<LI>Establish the socket connection by selecting <I>Socket</I> under the Communications menu item in the Tcl/Tk GUI.</LI>
</OL>
Note that it is possible to specify a hostname when establishing the socket connection from the socket client. Thus, the STK socket server program and the Tcl/Tk GUI need not necessarily reside on the same computer.
\section midi Realtime MIDI Control Input:
On all supported realtime platforms, you can direct realtime MIDI input to the STK Clarinet by typing:
\code
demo Clarinet -or -im
\endcode
*/

View File

@@ -1,46 +1,88 @@
/*******************************************/
/* ADSR Subclass of the Envelope Class, */
/* by Perry R. Cook, 1995-96 */
/* This is the traditional ADSR (Attack */
/* Decay, Sustain, Release) envelope. */
/* It responds to simple KeyOn and KeyOff */
/* messages, keeping track of it's state. */
/* There are two tick (update value) */
/* methods, one returns the value, and */
/* other returns the state (0 = A, 1 = D, */
/* 2 = S, 3 = R) */
/*******************************************/
/***************************************************/
/*! \class ADSR
\brief STK ADSR envelope class.
#if !defined(__ADSR_h)
#define __ADSR_h
This Envelope subclass implements a
traditional ADSR (Attack, Decay,
Sustain, Release) envelope. It
responds to simple keyOn and keyOff
messages, keeping track of its state.
The \e state = ADSR::DONE after the
envelope value reaches 0.0 in the
ADSR::RELEASE state.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__ADSR_H)
#define __ADSR_H
#include "Envelope.h"
class ADSR : public Envelope
{
public:
//! Envelope states.
enum { ATTACK, DECAY, SUSTAIN, RELEASE, DONE };
//! Default constructor.
ADSR(void);
//! Class destructor.
~ADSR(void);
//! Set target = 1, state = \e ADSR::ATTACK.
void keyOn(void);
//! Set target = 0, state = \e ADSR::RELEASE.
void keyOff(void);
//! Set the attack rate.
void setAttackRate(MY_FLOAT aRate);
//! Set the decay rate.
void setDecayRate(MY_FLOAT aRate);
//! Set the sustain level.
void setSustainLevel(MY_FLOAT aLevel);
//! Set the release rate.
void setReleaseRate(MY_FLOAT aRate);
//! Set the attack rate based on a time duration.
void setAttackTime(MY_FLOAT aTime);
//! Set the decay rate based on a time duration.
void setDecayTime(MY_FLOAT aTime);
//! Set the release rate based on a time duration.
void setReleaseTime(MY_FLOAT aTime);
//! 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 the target value.
void setTarget(MY_FLOAT aTarget);
//! 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);
//! Return one envelope output value.
MY_FLOAT tick(void);
//! Return \e vectorSize envelope outputs in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
protected:
MY_FLOAT attackRate;
MY_FLOAT decayRate;
MY_FLOAT sustainLevel;
MY_FLOAT releaseRate;
public:
ADSR();
~ADSR();
void keyOn();
void keyOff();
void setAttackRate(MY_FLOAT aRate);
void setDecayRate(MY_FLOAT aRate);
void setSustainLevel(MY_FLOAT aLevel);
void setReleaseRate(MY_FLOAT aRate);
void setAttackTime(MY_FLOAT aTime);
void setDecayTime(MY_FLOAT aTime);
void setReleaseTime(MY_FLOAT aTime);
void setAllTimes(MY_FLOAT attTime, MY_FLOAT decTime, MY_FLOAT susLevel, MY_FLOAT relTime);
void setTarget(MY_FLOAT aTarget);
void setValue(MY_FLOAT aValue);
MY_FLOAT tick();
int informTick();
MY_FLOAT lastOut();
};
#endif

View File

@@ -1,30 +0,0 @@
/*******************************************/
/*
AifWvIn Input Class,
by Gary P. Scavone, 2000
This object inherits from WvIn and is
used to open Audio Interchange File
Format files with 16-bit data (signed
integer) for playback.
.aif files are always bif-endian.
*/
/*******************************************/
#if !defined(__AifWvIn_h)
#define __AifWvIn_h
#include "Object.h"
#include "WvIn.h"
class AifWvIn : public WvIn
{
public:
AifWvIn(char *fileName, const char *mode);
~AifWvIn();
protected:
void getData(long index);
};
#endif

View File

@@ -1,32 +0,0 @@
/*******************************************/
/*
AifWvOut Output Class,
by Gary P. Scavone, 2000
This object inherits from WvOut and is
used to write Audio Interchange File
Format files with 16-bit data (signed
integer).
.aif files are always bif-endian.
*/
/*******************************************/
#if !defined(__AifWvOut_h)
#define __AifWvOut_h
#include "Object.h"
#include "WvOut.h"
class AifWvOut : public WvOut
{
protected:
FILE *fd;
public:
AifWvOut(char *fileName, int chans = 1);
~AifWvOut();
void tick(MY_FLOAT sample);
void mtick(MY_MULTI samples);
};
#endif

108
include/BandedWG.h Normal file
View File

@@ -0,0 +1,108 @@
/***************************************************/
/*! \class BandedWG
\brief Banded waveguide modeling class.
This class uses banded waveguide techniques to
model a variety of sounds, including bowed
bars, glasses, and bowls. For more
information, see Essl, G. and Cook, P. "Banded
Waveguides: Towards Physical Modelling of Bar
Percussion Instruments", Proceedings of the
1999 International Computer Music Conference.
Control Change Numbers:
- Bow Pressure = 2
- Bow Motion = 4
- Strike Position = 8 (not implemented)
- Vibrato Frequency = 11
- Gain = 1
- Bow Velocity = 128
- Set Striking = 64
- Instrument Presets = 16
- Uniform Bar = 0
- Tuned Bar = 1
- Glass Harmonica = 2
- Tibetan Bowl = 3
by Georg Essl, 1999 - 2002.
Modified for Stk 4.0 by Gary Scavone.
*/
/***************************************************/
#if !defined(__BANDEDWG_H)
#define __BANDEDWG_H
#define MAX_BANDED_MODES 17
#include "Instrmnt.h"
#include "Delay.h"
#include "BowTabl.h"
#include "ADSR.h"
#include "BiQuad.h"
class BandedWG : public Instrmnt
{
public:
//! Class constructor.
BandedWG();
//! Class destructor.
~BandedWG();
//! Reset and clear all internal state.
void clear();
//! Set strike position (0.0 - 1.0).
void setStrikePosition(MY_FLOAT position);
//! Select a preset.
void setPreset(int preset);
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
//! Apply bow velocity/pressure to instrument with given amplitude and rate of increase.
void startBowing(MY_FLOAT amplitude, MY_FLOAT rate);
//! Decrease bow velocity/breath pressure with given rate of decrease.
void stopBowing(MY_FLOAT rate);
//! Pluck the instrument with given amplitude.
void pluck(MY_FLOAT amp);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
protected:
bool doPluck;
bool trackVelocity;
int nModes;
int presetModes;
BowTabl *bowTabl;
ADSR *adsr;
BiQuad *bandpass;
Delay *delay;
MY_FLOAT maxVelocity;
MY_FLOAT modes[MAX_BANDED_MODES];
MY_FLOAT freakency;
MY_FLOAT baseGain;
MY_FLOAT gains[MAX_BANDED_MODES];
MY_FLOAT integrationConstant;
MY_FLOAT bowVelocity;
MY_FLOAT bowTarget;
MY_FLOAT bowPosition;
int strikePosition;
};
#endif

View File

@@ -1,23 +1,56 @@
/******************************************/
/* HammondOid Organ Subclass */
/* of Algorithm 8 (TX81Z) Subclass of */
/* 4 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/******************************************/
/***************************************************/
/*! \class BeeThree
\brief STK Hammond-oid organ FM synthesis instrument.
#if !defined(__BeeThree_h)
#define __BeeThree_h
This class implements a simple 4 operator
topology, also referred to as algorithm 8 of
the TX81Z.
#include "FM4Alg8.h"
\code
Algorithm 8 is :
1 --.
2 -\|
+-> Out
3 -/|
4 --
\endcode
class BeeThree : public FM4Alg8
Control Change Numbers:
- Operator 4 (feedback) Gain = 2
- Operator 3 Gain = 4
- LFO Speed = 11
- LFO Depth = 1
- ADSR 2 & 4 Target = 128
The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha. If you are of the
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__BEETHREE_H)
#define __BEETHREE_H
#include "FM.h"
class BeeThree : public FM
{
public:
//! Class constructor.
BeeThree();
//! Class destructor.
~BeeThree();
virtual void setFreq(MY_FLOAT frequency);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
};
#endif

View File

@@ -1,40 +1,100 @@
/*******************************************/
/*
BiQuad (2-pole, 2-zero) Filter Class,
by Perry R. Cook, 1995-96.
Modified by Julius Smith, 2000:
setA1,setA2,setB1,setB2
/***************************************************/
/*! \class BiQuad
\brief STK biquad (two-pole, two-zero) filter class.
See books on filters to understand
more about how this works. Nothing
out of the ordinary in this version.
This protected Filter subclass implements a
two-pole, two-zero digital filter. A method
is provided for creating a resonance in the
frequency response while maintaining a constant
filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/*******************************************/
/***************************************************/
#if !defined(__BiQuad_h)
#define __BiQuad_h
#if !defined(__BIQUAD_H)
#define __BIQUAD_H
#include "Filter.h"
class BiQuad : public Filter
class BiQuad : protected Filter
{
protected:
MY_FLOAT poleCoeffs[2];
MY_FLOAT zeroCoeffs[2];
public:
//! Default constructor creates a second-order pass-through filter.
BiQuad();
~BiQuad();
void clear();
void setA1(MY_FLOAT a1);
void setA2(MY_FLOAT a2);
//! Class destructor.
virtual ~BiQuad();
//! Clears all internal states of the filter.
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
//! Set the b[1] coefficient value.
void setB1(MY_FLOAT b1);
//! Set the b[2] coefficient value.
void setB2(MY_FLOAT b2);
void setPoleCoeffs(MY_FLOAT *coeffs);
void setZeroCoeffs(MY_FLOAT *coeffs);
void setGain(MY_FLOAT aValue);
void setFreqAndReson(MY_FLOAT freq, MY_FLOAT reson);
//! Set the a[1] coefficient value.
void setA1(MY_FLOAT a1);
//! Set the a[2] coefficient value.
void setA2(MY_FLOAT a2);
//! Sets the filter coefficients for a resonance at \e frequency (in Hz).
/*!
This method determines the filter coefficients corresponding to
two complex-conjugate poles with the given \e frequency (in Hz)
and \e radius from the z-plane origin. If \e normalize is true,
the filter zeros are placed at z = 1, z = -1, and the coefficients
are then normalized to produce a constant unity peak gain
(independent of the filter \e gain parameter). The resulting
filter frequency response has a resonance at the given \e
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);
//! Set the filter coefficients for a notch at \e frequency (in Hz).
/*!
This method determines the filter coefficients corresponding to
two complex-conjugate zeros with the given \e frequency (in Hz)
and \e radius from the z-plane origin. No filter normalization
is attempted.
*/
void setNotch(MY_FLOAT frequency, MY_FLOAT radius);
//! Sets the filter zeroes for equal resonance gain.
/*!
When using the filter as a resonator, zeroes places at z = 1, z
= -1 will result in a constant gain at resonance of 1 / (1 - R),
where R is the pole radius setting.
*/
void setEqualGainZeroes();
//! 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);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT 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);
};
#endif

77
include/BlowBotl.h Normal file
View File

@@ -0,0 +1,77 @@
/***************************************************/
/*! \class BlowBotl
\brief STK blown bottle instrument class.
This class implements a helmholtz resonator
(biquad filter) with a polynomial jet
excitation (a la Cook).
Control Change Numbers:
- Noise Gain = 4
- Vibrato Frequency = 11
- Vibrato Gain = 1
- Volume = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__BOTTLE_H)
#define __BOTTLE_H
#include "Instrmnt.h"
#include "JetTabl.h"
#include "BiQuad.h"
#include "PoleZero.h"
#include "Noise.h"
#include "ADSR.h"
#include "WaveLoop.h"
class BlowBotl : public Instrmnt
{
public:
//! Class constructor.
BlowBotl();
//! Class destructor.
~BlowBotl();
//! Reset and clear all internal state.
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
//! Apply breath velocity to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
//! Decrease breath velocity with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT 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;
};
#endif

View File

@@ -1,35 +1,98 @@
/***********************************************/
/*
Waveguide reed model with a register hole
and one tonehole
/***************************************************/
/*! \class BlowHole
\brief STK clarinet physical model with one
register hole and one tonehole.
by Gary P. Scavone, 2000.
This class is based on the clarinet model,
with the addition of a two-port register hole
and a three-port dynamic tonehole
implementation, as discussed by Scavone and
Cook (1998).
In this implementation, the distances between
the reed/register hole and tonehole/bell are
fixed. As a result, both the tonehole and
register hole will have variable influence on
the playing frequency, which is dependent on
the length of the air column. In addition,
the highest playing freqeuency is limited by
these fixed lengths.
This is a digital waveguide model, making its
use possibly subject to patents held by Stanford
University, Yamaha, and others.
Control Change Numbers:
- Reed Stiffness = 2
- Noise Gain = 4
- Tonehole State = 11
- Register State = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***********************************************/
/***************************************************/
#if !defined(__BlowHole_h)
#define __BlowHole_h
#if !defined(__BLOWHOLE_H)
#define __BLOWHOLE_H
#include "Instrmnt.h"
#include "DLineL.h"
#include "DelayL.h"
#include "ReedTabl.h"
#include "OneZero.h"
#include "PoleZero.h"
#include "Envelope.h"
#include "Noise.h"
#include "RawWvIn.h"
#include "WaveLoop.h"
class BlowHole : public Instrmnt
{
public:
//! Class constructor.
BlowHole(MY_FLOAT lowestFrequency);
//! Class destructor.
~BlowHole();
//! Reset and clear all internal state.
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
//! Set the tonehole state (0.0 = closed, 1.0 = fully open).
void setTonehole(MY_FLOAT newValue);
//! Set the register hole state (0.0 = closed, 1.0 = fully open).
void setVent(MY_FLOAT newValue);
//! Apply breath pressure to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
//! Decrease breath pressure with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
protected:
DLineL *delays;
DelayL *delays[3];
ReedTabl *reedTable;
OneZero *filter;
PoleZero *tonehole;
PoleZero *vent;
Envelope *envelope;
Noise *noise;
RawWvIn *vibr;
WaveLoop *vibrato;
long length;
MY_FLOAT scatter;
MY_FLOAT th_coeff;
@@ -38,20 +101,8 @@ class BlowHole : public Instrmnt
MY_FLOAT rh_gain;
MY_FLOAT outputGain;
MY_FLOAT noiseGain;
MY_FLOAT vibrGain;
public:
BlowHole(MY_FLOAT lowestFreq);
~BlowHole();
void clear();
virtual void setFreq(MY_FLOAT frequency);
void setTonehole(MY_FLOAT newValue);
void setVent(MY_FLOAT newValue);
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
void stopBlowing(MY_FLOAT rate);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
virtual void noteOff(MY_FLOAT amp);
virtual MY_FLOAT tick();
virtual void controlChange(int number, MY_FLOAT value);
MY_FLOAT vibratoGain;
};
#endif

View File

@@ -1,27 +1,62 @@
/***********************************************/
/* Simple Bow Table Object, after Smith */
/* by Perry R. Cook, 1995-96 */
/***********************************************/
/***************************************************/
/*! \class BowTabl
\brief STK bowed string table class.
#if !defined(__BowTabl_h)
#define __BowTabl_h
This class implements a simple bowed string
non-linear function, as described by Smith (1986).
#include "Object.h"
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
class BowTabl : public Object
#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;
public:
BowTabl();
~BowTabl();
void setOffset(MY_FLOAT aValue);
void setSlope(MY_FLOAT aValue);
MY_FLOAT lookup(MY_FLOAT sample);
MY_FLOAT tick(MY_FLOAT sample);
MY_FLOAT lastOut();
};
#endif

View File

@@ -1,56 +1,86 @@
/******************************************/
/* Bowed String model ala Smith */
/* after McIntyre, Schumacher, Woodhouse */
/* by Perry Cook, 1995-96 */
/* */
/* This is a waveguide model, and thus */
/* relates to various Stanford Univ. */
/* and possibly Yamaha and other patents.*/
/* */
/* Controls: CONTROL1 = bowPressure */
/* CONTROL2 = bowPosition */
/* CONTROL3 = vibrFreq */
/* MOD_WHEEL= vibrGain */
/* */
/******************************************/
/***************************************************/
/*! \class Bowed
\brief STK bowed string instrument class.
#if !defined(__Bowed_h)
#define __Bowed_h
This class implements a bowed string model, a
la Smith (1986), after McIntyre, Schumacher,
Woodhouse (1983).
This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.
Control Change Numbers:
- Bow Pressure = 2
- Bow Position = 4
- Vibrato Frequency = 11
- Vibrato Gain = 1
- Volume = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__BOWED_H)
#define __BOWED_H
#include "Instrmnt.h"
#include "DLineL.h"
#include "DelayL.h"
#include "BowTabl.h"
#include "OnePole.h"
#include "BiQuad.h"
#include "RawWvIn.h"
#include "WaveLoop.h"
#include "ADSR.h"
class Bowed : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Bowed(MY_FLOAT lowestFrequency);
//! Class destructor.
~Bowed();
//! Reset and clear all internal state.
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
//! Set vibrato gain.
void setVibrato(MY_FLOAT gain);
//! Apply breath pressure to instrument with given amplitude and rate of increase.
void startBowing(MY_FLOAT amplitude, MY_FLOAT rate);
//! Decrease breath pressure with given rate of decrease.
void stopBowing(MY_FLOAT rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
protected:
DLineL *neckDelay;
DLineL *bridgeDelay;
BowTabl *bowTabl;
OnePole *reflFilt;
BiQuad *bodyFilt;
RawWvIn *vibr;
DelayL *neckDelay;
DelayL *bridgeDelay;
BowTabl *bowTable;
OnePole *stringFilter;
BiQuad *bodyFilter;
WaveLoop *vibrato;
ADSR *adsr;
MY_FLOAT maxVelocity;
MY_FLOAT baseDelay;
MY_FLOAT vibrGain;
MY_FLOAT vibratoGain;
MY_FLOAT betaRatio;
public:
Bowed(MY_FLOAT lowestFreq);
~Bowed();
void clear();
void startBowing(MY_FLOAT amplitude,MY_FLOAT rate);
void stopBowing(MY_FLOAT rate);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
virtual void noteOff(MY_FLOAT amp);
virtual void setFreq(MY_FLOAT frequency);
void setVibrato(MY_FLOAT amount);
virtual void controlChange(int number, MY_FLOAT value);
virtual MY_FLOAT tick();
};
#endif

View File

@@ -1,62 +0,0 @@
/*********************************************/
/* Bowed Bar model */
/* by Georg Essl, 1999 */
/* For details refer to: */
/* G.Essl, P.R.Cook: "Banded Waveguides: */
/* Towards Physical Modelling of Bar */
/* Percussion Instruments", ICMC'99 */
/*********************************************/
#if !defined(__BowedBar_h)
#define __BowedBar_h
#include "Instrmnt.h"
#include "DLineN.h"
#include "BowTabl.h"
#include "ADSR.h"
#include "BiQuad.h"
class BowedBar : public Instrmnt
{
protected:
BowTabl *bowTabl;
ADSR *adsr;
BiQuad *bandpass;
MY_FLOAT maxVelocity;
MY_FLOAT modes[4];
DLineN delay[4];
int NR_MODES;
float Zs[4][2];
MY_FLOAT coeffs[4][2];
float filtOut[4];
float filtIn[4];
MY_FLOAT filtGain[4];
MY_FLOAT freq;
int length;
MY_FLOAT R;
MY_FLOAT GAIN;
MY_FLOAT gains[4];
MY_FLOAT slope;
MY_FLOAT velinput;
MY_FLOAT integration_const;
int trackVel;
MY_FLOAT bowvel, bowTarg, bowPos, lastBowPos;
int doPluck;
public:
BowedBar();
~BowedBar();
void tuneBandPasses();
void clear();
void startBowing(MY_FLOAT amplitude,MY_FLOAT rate);
void stopBowing(MY_FLOAT rate);
void pluck(MY_FLOAT amp);
void setStrikePosition(MY_FLOAT position);
void noteOn(MY_FLOAT freq, MY_FLOAT amp);
void noteOff(MY_FLOAT amp);
void setFreq(MY_FLOAT frequency);
void controlChange(int number, MY_FLOAT value);
MY_FLOAT tick();
};
#endif

View File

@@ -1,53 +1,83 @@
/******************************************/
/* Simple Brass Instrument Model ala */
/* Cook (TBone, HosePlayer) */
/* by Perry R. Cook, 1995-96 */
/* */
/* This is a waveguide model, and thus */
/* relates to various Stanford Univ. */
/* and possibly Yamaha and other patents.*/
/* */
/* Controls: CONTROL1 = lipTension */
/* CONTROL2 = slideLength */
/* CONTROL3 = vibFreq */
/* MOD_WHEEL= vibAmt */
/******************************************/
/***************************************************/
/*! \class Brass
\brief STK simple brass instrument class.
#if !defined(__Brass_h)
#define __Brass_h
This class implements a simple brass instrument
waveguide model, a la Cook (TBone, HosePlayer).
This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.
Control Change Numbers:
- Lip Tension = 2
- Slide Length = 4
- Vibrato Frequency = 11
- Vibrato Gain = 1
- Volume = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__BRASS_H)
#define __BRASS_H
#include "Instrmnt.h"
#include "DLineA.h"
#include "LipFilt.h"
#include "DCBlock.h"
#include "DelayA.h"
#include "BiQuad.h"
#include "PoleZero.h"
#include "ADSR.h"
#include "RawWvIn.h"
#include "WaveLoop.h"
class Brass: public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Brass(MY_FLOAT lowestFrequency);
//! Class destructor.
~Brass();
//! Reset and clear all internal state.
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
//! Set the lips frequency.
void setLip(MY_FLOAT frequency);
//! Apply breath pressure to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
//! Decrease breath pressure with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
protected:
DLineA *delayLine;
LipFilt *lipFilter;
DCBlock *dcBlock;
DelayA *delayLine;
BiQuad *lipFilter;
PoleZero *dcBlock;
ADSR *adsr;
RawWvIn *vibr;
WaveLoop *vibrato;
long length;
MY_FLOAT lipTarget;
MY_FLOAT slideTarget;
MY_FLOAT vibrGain;
MY_FLOAT vibratoGain;
MY_FLOAT maxPressure;
public:
Brass(MY_FLOAT lowestFreq);
~Brass();
void clear();
virtual void setFreq(MY_FLOAT frequency);
void setLip(MY_FLOAT frequency);
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
void stopBlowing(MY_FLOAT rate);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
virtual void noteOff(MY_FLOAT amp);
virtual void controlChange(int number, MY_FLOAT value);
virtual MY_FLOAT tick();
};
#endif

View File

@@ -1,5 +0,0 @@
#include "Object.h"
void swap16(unsigned char *ptr);
void swap32(unsigned char *ptr);
void swap64(unsigned char *ptr);

65
include/Chorus.h Normal file
View File

@@ -0,0 +1,65 @@
/***************************************************/
/*! \class Chorus
\brief STK chorus effect class.
This class implements a chorus effect.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__CHORUS_H)
#define __CHORUS_H
#include "Stk.h"
#include "DelayL.h"
#include "WaveLoop.h"
class Chorus : public Stk
{
public:
//! Class constructor, taking the longest desired delay length.
Chorus(MY_FLOAT baseDelay);
//! Class destructor.
~Chorus();
//! Reset and clear all internal state.
void clear();
//! Set modulation depth.
void setModDepth(MY_FLOAT 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;
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT 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);
protected:
DelayL *delayLine[2];
WaveLoop *mods[2];
MY_FLOAT baseLength;
MY_FLOAT modDepth;
MY_FLOAT lastOutput[2];
MY_FLOAT effectMix;
};
#endif

View File

@@ -1,53 +1,83 @@
/******************************************/
/* Clarinet model ala Smith */
/* after McIntyre, Schumacher, Woodhouse */
/* by Perry Cook, 1995-96 */
/* */
/* This is a waveguide model, and thus */
/* relates to various Stanford Univ. */
/* and possibly Yamaha and other patents.*/
/* */
/* Controls: CONTROL1 = reedStiffns */
/* CONTROL2 = noiseGain */
/* CONTROL3 = vibFreq */
/* MOD_WHEEL= vibAmt */
/******************************************/
/***************************************************/
/*! \class Clarinet
\brief STK clarinet physical model class.
#if !defined(__Clarinet_h)
#define __Clarinet_h
This class implements a simple clarinet
physical model, as discussed by Smith (1986),
McIntyre, Schumacher, Woodhouse (1983), and
others.
This is a digital waveguide model, making its
use possibly subject to patents held by Stanford
University, Yamaha, and others.
Control Change Numbers:
- Reed Stiffness = 2
- Noise Gain = 4
- Vibrato Frequency = 11
- Vibrato Gain = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__CLARINET_H)
#define __CLARINET_H
#include "Instrmnt.h"
#include "DLineL.h"
#include "DelayL.h"
#include "ReedTabl.h"
#include "OneZero.h"
#include "Envelope.h"
#include "Noise.h"
#include "RawWvIn.h"
#include "WaveLoop.h"
class Clarinet : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Clarinet(MY_FLOAT lowestFrequency);
//! Class destructor.
~Clarinet();
//! Reset and clear all internal state.
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
//! Apply breath pressure to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
//! Decrease breath pressure with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
protected:
DLineL *delayLine;
DelayL *delayLine;
ReedTabl *reedTable;
OneZero *filter;
Envelope *envelope;
Noise *noise;
RawWvIn *vibr;
WaveLoop *vibrato;
long length;
MY_FLOAT outputGain;
MY_FLOAT noiseGain;
MY_FLOAT vibrGain;
public:
Clarinet(MY_FLOAT lowestFreq);
~Clarinet();
void clear();
virtual void setFreq(MY_FLOAT frequency);
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
void stopBlowing(MY_FLOAT rate);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
virtual void noteOff(MY_FLOAT amp);
virtual MY_FLOAT tick();
virtual void controlChange(int number, MY_FLOAT value);
MY_FLOAT vibratoGain;
};
#endif

View File

@@ -1,119 +0,0 @@
/******************************************/
/*
Controller Class,
by Gary P. Scavone, 2000
This object will accept control messages
from a variety of sources, such as a MIDI
port, scorefile, socket connection, or
pipe. MIDI messages are retrieved with
the RtMidi class. All other input sources
(scorefile, socket, or pipe) are assumed
to provide SKINI formatted messages.
For each call of getNextMessage(), the
active input devices are queried to see
if a new control message is available.
Only one message per call is returned, so
a subsequent call begins querying the
next available device "after" the previously
handled one.
This class is primarily for use in STK
main() event loops.
One of my 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 are
then sent via a socket connection to the message
socket server. Perhaps in the future, I will be
able to simplify things.
*/
/******************************************/
#if !defined(__Controller_h)
#define __Controller_h
#include "Object.h"
#include "SKINI11.h"
#if defined(__STK_REALTIME_)
#include "RtMidi.h"
#include "StkError.h"
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <netdb.h>
#include <fcntl.h>
#include <errno.h>
void *stdinHandler(void *);
#elif defined(__OS_Win_)
#include <process.h>
#include <winsock.h>
void stdinHandler(void *);
#endif
#endif // __STK_REALTIME
#define STK_MIDI 0x0001
#define STK_PIPE 0x0002
#define STK_SOCKET 0x0004
#define STK_SCOREFILE 0x0008
#define MESSAGE_LENGTH 128
#define MAX_MESSAGES 25
#define STK_SOCKET_PORT 2001
class Controller : public Object
{
protected:
int source;
long default_ticks;
int type;
MY_FLOAT channel;
MY_FLOAT byte2;
MY_FLOAT byte3;
char message[MAX_MESSAGES][MESSAGE_LENGTH];
int msg_index;
int num_messages;
SKINI11 *score;
#if defined(__STK_REALTIME_)
fd_set mask;
int maxfd;
int fd[16];
int local_socket;
RtMidi *midi_input;
int parseSocketData(int fd);
#if (defined(__OS_IRIX_) || defined(__OS_Linux_))
pthread_t stdin_thread;
#elif defined(__OS_Win_)
unsigned long stdin_thread;
#endif
#endif // __STK_REALTIME
public:
Controller(int inputMask);
~Controller();
void setDefaultTicks(long nSamples);
int getNextMessage();
int getType();
MY_FLOAT getByte2();
MY_FLOAT getByte3();
MY_FLOAT getChannel();
};
#endif // defined(__Controller_h)

View File

@@ -1,26 +0,0 @@
/*******************************************/
/* DC Blocking Filter */
/* by Perry R. Cook, 1995-96 */
/* */
/* This guy is very helpful in, uh, */
/* blocking DC. Needed because a simple */
/* low-pass reflection filter allows DC */
/* to build up inside recursive */
/* structures. */
/*******************************************/
#if !defined(__DCBlock_h)
#define __DCBlock_h
#include "Filter.h"
class DCBlock : public Filter
{
public:
DCBlock();
~DCBlock();
void clear();
MY_FLOAT tick(MY_FLOAT sample);
};
#endif

View File

@@ -1,43 +0,0 @@
/*******************************************/
/* AllPass Interpolating Delay Line */
/* Object by Perry R. Cook 1995-96. */
/* Revised by Gary P. Scavone, 1999. */
/* */
/* This one uses a delay line of maximum */
/* length specified on creation, and */
/* interpolates fractional length using */
/* an all-pass filter. This version is */
/* more efficient for computing static */
/* length delay lines (alpha and coeff */
/* are computed only when the length */
/* is set, there probably is a more */
/* efficient computational form if alpha */
/* is changed often (each sample)). */
/* */
/*******************************************/
#if !defined(__DLineA_h)
#define __DLineA_h
#include "Filter.h"
class DLineA : public Filter
{
protected:
long inPoint;
long outPoint;
long length;
MY_FLOAT alpha;
MY_FLOAT coeff;
MY_FLOAT lastIn;
public:
DLineA();
DLineA(long max_length);
~DLineA();
void clear();
void setDelay(MY_FLOAT length);
MY_FLOAT tick(MY_FLOAT sample);
};
#endif

View File

@@ -1,45 +0,0 @@
/*******************************************/
/*
Linearly Interpolating Delay Line
Object by Perry R. Cook 1995-96.
Added methods by Julius Smith, 2000.
This one uses a delay line of maximum
length specified on creation, and
linearly interpolates fractional
length. It is designed to be more
efficient if the delay length is not
changed very often.
*/
/*******************************************/
#if !defined(__DLineL_h)
#define __DLineL_h
#include "Filter.h"
class DLineL : public Filter
{
protected:
long inPoint;
long outPoint;
long length;
MY_FLOAT alpha;
MY_FLOAT omAlpha;
MY_FLOAT currentDelay;
public:
DLineL();
DLineL(long max_length);
~DLineL();
void clear();
void setDelay(MY_FLOAT length);
MY_FLOAT delay(void);
MY_FLOAT energy(void);
long currentInPoint(void);
long currentOutPoint(void);
MY_FLOAT contentsAt(int n);
MY_FLOAT contentsAtNowMinus(int n);
MY_FLOAT tick(MY_FLOAT sample);
};
#endif

View File

@@ -1,45 +0,0 @@
/*******************************************/
/*
Non-Interpolating Delay Line
Object by Perry R. Cook 1995-96.
Revised by Gary Scavone, 1999.
Added methods by Julius Smith, 2000.
This one uses either a delay line of
maximum length specified on creation
or a default length of 2047 samples.
A non-interpolating delay line is
typically used in non-time varying
(reverb) applications.
*/
/*******************************************/
#if !defined(__DLineN_h)
#define __DLineN_h
#include "Filter.h"
class DLineN : public Filter
{
protected:
long inPoint;
long outPoint;
long length;
MY_FLOAT currentDelay;
public:
DLineN();
DLineN(long max_length);
~DLineN();
void clear();
void setDelay(MY_FLOAT length);
MY_FLOAT energy(void);
long currentInPoint(void);
long currentOutPoint(void);
MY_FLOAT contentsAt(int n);
MY_FLOAT contentsAtNowMinus(int n);
MY_FLOAT delay(void);
MY_FLOAT tick(MY_FLOAT sample);
};
#endif

77
include/Delay.h Normal file
View File

@@ -0,0 +1,77 @@
/***************************************************/
/*! \class Delay
\brief STK non-interpolating delay line class.
This protected Filter subclass implements
a non-interpolating digital delay-line.
A fixed maximum length of 4095 and a delay
of zero is set using the default constructor.
Alternatively, the delay and maximum length
can be set during instantiation with an
overloaded constructor.
A non-interpolating delay line is typically
used in fixed delay-length applications, such
as for reverberation.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__DELAY_H)
#define __DELAY_H
#include "Filter.h"
class Delay : protected Filter
{
public:
//! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay.
Delay();
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
Delay(long theDelay, long maxDelay);
//! Class destructor.
virtual ~Delay();
//! Clears the internal state of the delay line.
void clear();
//! Set the delay-line length.
/*!
The valid range for \e theDelay is from 0 to the maximum delay-line length.
*/
void setDelay(long theDelay);
//! Return the current delay-line length.
long getDelay(void) const;
//! Calculate and return the signal energy in the delay-line.
MY_FLOAT energy(void) const;
//! Return the value at \e tapDelay samples from the delay-line input.
/*!
The valid range for \e tapDelay is 1 to the delay-line length.
*/
MY_FLOAT contentsAt(long tapDelay) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
//! Input one sample to the delay-line and return one output.
virtual MY_FLOAT tick(MY_FLOAT 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);
protected:
long inPoint;
long outPoint;
long length;
MY_FLOAT delay;
};
#endif

65
include/DelayA.h Normal file
View File

@@ -0,0 +1,65 @@
/***************************************************/
/*! \class DelayA
\brief STK allpass interpolating delay line class.
This Delay subclass implements a fractional-
length digital delay-line using a first-order
allpass filter. A fixed maximum length
of 4095 and a delay of 0.5 is set using the
default constructor. Alternatively, the
delay and maximum length can be set during
instantiation with an overloaded constructor.
An allpass filter has unity magnitude gain but
variable phase delay properties, making it useful
in achieving fractional delays without affecting
a signal's frequency magnitude response. In
order to achieve a maximally flat phase delay
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.
*/
/***************************************************/
#if !defined(__DelayA_h)
#define __DelayA_h
#include "Delay.h"
class DelayA : public Delay
{
public:
//! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay.
DelayA();
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
DelayA(MY_FLOAT theDelay, long maxDelay);
//! Class destructor.
~DelayA();
//! Clears the internal state of the delay line.
void clear();
//! Set the delay-line length
/*!
The valid range for \e theDelay is from 0.5 to the maximum delay-line length.
*/
void setDelay(MY_FLOAT theDelay);
//! Return the current delay-line length.
MY_FLOAT getDelay(void);
//! Input one sample to the delay-line and return one output.
MY_FLOAT tick(MY_FLOAT sample);
protected:
MY_FLOAT alpha;
MY_FLOAT coeff;
MY_FLOAT apInput;
};
#endif

61
include/DelayL.h Normal file
View File

@@ -0,0 +1,61 @@
/***************************************************/
/*! \class DelayL
\brief STK linear interpolating delay line class.
This Delay subclass implements a fractional-
length digital delay-line using first-order
linear interpolation. A fixed maximum length
of 4095 and a delay of zero is set using the
default constructor. Alternatively, the
delay and maximum length can be set during
instantiation with an overloaded constructor.
Linear interpolation is an efficient technique
for achieving fractional delay lengths, though
it does introduce high-frequency signal
attenuation to varying degrees depending on the
fractional delay setting. The use of higher
order Lagrange interpolators can typically
improve (minimize) this attenuation characteristic.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__DELAYL_H)
#define __DELAYL_H
#include "Delay.h"
class DelayL : public Delay
{
public:
//! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay.
DelayL();
//! Overloaded constructor which specifies the current and maximum delay-line lengths.
DelayL(MY_FLOAT theDelay, long maxDelay);
//! Class destructor.
~DelayL();
//! Set the delay-line length.
/*!
The valid range for \e theDelay is from 0 to the maximum delay-line length.
*/
void setDelay(MY_FLOAT theDelay);
//! Return the current delay-line length.
MY_FLOAT getDelay(void) const;
//! Input one sample to the delay-line and return one output.
MY_FLOAT tick(MY_FLOAT sample);
protected:
MY_FLOAT alpha;
MY_FLOAT omAlpha;
};
#endif

View File

@@ -1,47 +0,0 @@
/*******************************************/
/* Master Class for Drum Synthesizer */
/* by Perry R. Cook, 1995-96 */
/* */
/* This instrument contains a bunch of */
/* RawWvIn objects, run through a bunch */
/* of one-pole filters. All the */
/* corresponding rawwave files have been */
/* sampled at 22050 Hz. Thus, if the */
/* compile-time SRATE = 22050, then */
/* no interpolation is used. Otherwise, */
/* the rawwave data is appropriately */
/* interpolated for the current SRATE. */
/* You can specify the maximum Polyphony */
/* (maximum number of simultaneous voices)*/
/* in a #define in the .h file. */
/* */
/* Modified for RawWvIn class */
/* by Gary P. Scavone (4/99) */
/*******************************************/
#if !defined(__DrumSynt_h)
#define __DrumSynt_h
#include "Instrmnt.h"
#include "RawWvIn.h"
#include "OnePole.h"
#define DRUM_NUMWAVES 11
#define DRUM_POLYPHONY 4
class DrumSynt : public Instrmnt
{
protected:
RawWvIn *waves[DRUM_POLYPHONY];
OnePole *filters[DRUM_POLYPHONY];
int sounding[DRUM_POLYPHONY];
int numSounding;
public:
DrumSynt();
~DrumSynt();
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
void noteOff(MY_FLOAT amp);
virtual MY_FLOAT tick();
};
#endif

59
include/Drummer.h Normal file
View File

@@ -0,0 +1,59 @@
/***************************************************/
/*! \class Drummer
\brief STK drum sample player class.
This class implements a drum sampling
synthesizer using WvIn objects and one-pole
filters. The drum rawwave files are sampled
at 22050 Hz, but will be appropriately
interpolated for other sample rates. You can
specify the maximum polyphony (maximum number
of simultaneous voices) via a #define in the
Drummer.h.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__DRUMMER_H)
#define __DRUMMER_H
#include "Instrmnt.h"
#include "WvIn.h"
#include "OnePole.h"
#define DRUM_NUMWAVES 11
#define DRUM_POLYPHONY 4
class Drummer : public Instrmnt
{
public:
//! Class constructor.
Drummer();
//! Class destructor.
~Drummer();
//! 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.
*/
void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
protected:
WvIn *waves[DRUM_POLYPHONY];
OnePole *filters[DRUM_POLYPHONY];
int sounding[DRUM_POLYPHONY];
int nSounding;
};
#endif

53
include/Echo.h Normal file
View File

@@ -0,0 +1,53 @@
/***************************************************/
/*! \class Echo
\brief STK echo effect class.
This class implements a echo effect.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__ECHO_H)
#define __ECHO_H
#include "Stk.h"
#include "Delay.h"
class Echo : public Stk
{
public:
//! Class constructor, taking the longest desired delay length.
Echo(MY_FLOAT longestDelay);
//! Class destructor.
~Echo();
//! Reset and clear all internal state.
void clear();
//! 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;
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT 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);
protected:
Delay *delayLine;
long length;
MY_FLOAT lastOutput;
MY_FLOAT effectMix;
};
#endif

View File

@@ -1,41 +1,68 @@
/*******************************************/
/* Envelope Class, Perry R. Cook, 1995-96 */
/* This is the base class for envelopes. */
/* This one is capable of ramping state */
/* from where it is to a target value by */
/* a rate. It also responds to simple */
/* KeyOn and KeyOff messages, ramping to */
/* 1.0 on keyon and to 0.0 on keyoff. */
/* There are two tick (update value) */
/* methods, one returns the value, and */
/* other returns 0 if the envelope is at */
/* the target value (the state bit). */
/*******************************************/
/***************************************************/
/*! \class Envelope
\brief STK envelope base class.
#if !defined(__Envelope_h)
#define __Envelope_h
This class implements a simple envelope
generator which is capable of ramping to
a target value by a specified \e rate.
It also responds to simple \e keyOn and
\e keyOff messages, ramping to 1.0 on
keyOn and to 0.0 on keyOff.
#include "Object.h"
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
class Envelope : public Object
#if !defined(__ENVELOPE_H)
#define __ENVELOPE_H
#include "Stk.h"
class Envelope : public Stk
{
public:
//! Default constructor.
Envelope(void);
//! Class destructor.
virtual ~Envelope(void);
//! Set target = 1.
virtual void keyOn(void);
//! Set target = 0.
virtual void keyOff(void);
//! Set the \e rate.
void setRate(MY_FLOAT aRate);
//! Set the \e rate based on a time duration.
void setTime(MY_FLOAT aTime);
//! Set the target value.
virtual void setTarget(MY_FLOAT aTarget);
//! Set current and target values to \e aValue.
virtual void setValue(MY_FLOAT aValue);
//! 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);
//! Return \e vectorSize envelope outputs in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
protected:
MY_FLOAT value;
MY_FLOAT target;
MY_FLOAT rate;
int state;
public:
Envelope();
virtual ~Envelope();
void keyOn();
void keyOff();
void setRate(MY_FLOAT aRate);
void setTime(MY_FLOAT aTime);
void setTarget(MY_FLOAT aTarget);
void setValue(MY_FLOAT aValue);
MY_FLOAT tick();
int informTick();
MY_FLOAT lastOut();
};
#endif

View File

@@ -1,34 +0,0 @@
/********************************************/
/*
General Finite-Impulse-Response (FIR)
Digital Filter Class
by Julius Smith, 1997
*/
/********************************************/
#if !defined(__FIR_h)
#define __FIR_h
#include "Object.h"
class FIR : public Object
{
protected:
int length;
MY_FLOAT *coeffs;
MY_FLOAT *pastInputs;
int piOffset;
MY_FLOAT delay;
public:
FIR(int length);
FIR(const char *filterFile);
~FIR();
void clear(void);
void setCoeffs(MY_FLOAT *theCoeffs);
MY_FLOAT tick(MY_FLOAT input);
MY_FLOAT lastOutput;
MY_FLOAT getDelay(MY_FLOAT freq);
int getLength(void);
};
#endif

103
include/FM.h Normal file
View File

@@ -0,0 +1,103 @@
/***************************************************/
/*! \class FM
\brief STK abstract FM synthesis base class.
This class controls an arbitrary number of
waves and envelopes, determined via a
constructor argument.
Control Change Numbers:
- Control One = 2
- Control Two = 4
- LFO Speed = 11
- LFO Depth = 1
- ADSR 2 & 4 Target = 128
The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha. If you are of the
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__FM_H)
#define __FM_H
#include "Instrmnt.h"
#include "ADSR.h"
#include "WaveLoop.h"
#include "TwoZero.h"
class FM : public Instrmnt
{
public:
//! Class constructor, taking the number of wave/envelope operators to control.
FM( int operators = 4 );
//! Class destructor.
virtual ~FM();
//! Reset and clear all wave and envelope states.
void clear();
//! Load the rawwave filenames in waves.
void loadWaves(const char **filenames);
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
//! Set the frequency ratio for the specified wave.
void setRatio(int waveIndex, MY_FLOAT ratio);
//! Set the gain for the specified wave.
void setGain(int waveIndex, MY_FLOAT gain);
//! Set the modulation speed in Hz.
void setModulationSpeed(MY_FLOAT mSpeed);
//! Set the modulation depth.
void setModulationDepth(MY_FLOAT mDepth);
//! Set the value of control1.
void setControl1(MY_FLOAT cVal);
//! Set the value of control1.
void setControl2(MY_FLOAT cVal);
//! Start envelopes toward "on" targets.
void keyOn();
//! Start envelopes toward "off" targets.
void keyOff();
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Pure virtual function ... must be defined in subclasses.
virtual MY_FLOAT tick() = 0;
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT 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];
};
#endif

View File

@@ -1,30 +0,0 @@
/******************************************/
/* Algorithm 3 (TX81Z) Subclass of */
/* 4 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/* */
/* Alg 3 is : 4--\ */
/* 3-->2-- + -->1-->Out */
/* */
/* Controls: control1 = total mod index */
/* control2 = crossfade of two */
/* modulators */
/* control3 = LFO speed */
/* modWheel = LFO amount */
/* */
/******************************************/
#if !defined(__FM4Alg3_h)
#define __FM4Alg3_h
#include "FM4Op.h"
class FM4Alg3 : public FM4Op
{
public:
FM4Alg3();
virtual ~FM4Alg3();
MY_FLOAT tick();
};
#endif

View File

@@ -1,30 +0,0 @@
/******************************************/
/* Algorithm 4 (TX81Z) Subclass of */
/* 4 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/* */
/* Alg 4 is : 4->3--\ */
/* 2-- + -->1-->Out */
/* */
/* Controls: control1 = total mod index */
/* control2 = crossfade of two */
/* modulators */
/* control3 = LFO speed */
/* modWheel = LFO amount */
/* */
/******************************************/
#if !defined(__FM4Alg4_h)
#define __FM4Alg4_h
#include "FM4Op.h"
class FM4Alg4 : public FM4Op
{
public:
FM4Alg4();
virtual ~FM4Alg4();
MY_FLOAT tick();
};
#endif

View File

@@ -1,33 +0,0 @@
/******************************************/
/* Algorithm 5 (TX81Z) Subclass of */
/* 4 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/* This connection topology is 2 simple */
/* FM Pairs summed together, like: */
/* */
/* 1 -> 2 -\ */
/* +-> Out */
/* 3 -> 4 -/ */
/* */
/* Controls: control1 = mod index 1 */
/* control2 = crossfade of two */
/* outputs */
/* control3 = LFO speed */
/* modWheel = LFO amount */
/* */
/******************************************/
#if !defined(__FM4Alg5_h)
#define __FM4Alg5_h
#include "FM4Op.h"
class FM4Alg5 : public FM4Op
{
public:
FM4Alg5();
virtual ~FM4Alg5();
MY_FLOAT tick();
};
#endif

View File

@@ -1,36 +0,0 @@
/******************************************/
/* Algorithm 6 (TX81Z) Subclass of */
/* 4 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/* This connection topology is three */
/* Carriers and a common Modulator */
/* */
/* /->1 -\ */
/* 4-|-->2 - +-> Out */
/* \->3 -/ */
/* */
/* Controls: control1 = vowel */
/* control2 = spectral tilt */
/* control3 = LFO speed */
/* modWheel = LFO amount */
/* */
/******************************************/
#if !defined(__FM4Alg6_h)
#define __FM4Alg6_h
#include "FM4Op.h"
class FM4Alg6 : public FM4Op
{
protected:
MY_FLOAT tilt[3];
MY_FLOAT mods[3];
public:
FM4Alg6();
virtual ~FM4Alg6();
MY_FLOAT tick();
virtual void controlChange(int number, MY_FLOAT value);
};
#endif

View File

@@ -1,34 +0,0 @@
/******************************************/
/* Algorithm 8 (TX81Z) Subclass of */
/* 4 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/* This connection topology is simple */
/* Additive Synthesis, like: */
/* */
/* 1 --. */
/* 2 -\| */
/* +-> Out */
/* 3 -/| */
/* 4 -- */
/* */
/* Controls: control1 = op4 (fb) gain */
/* control2 = op3 gain */
/* control3 = LFO speed */
/* modWheel = LFO amount */
/* */
/******************************************/
#if !defined(__FM4Alg8_h)
#define __FM4Alg8_h
#include "FM4Op.h"
class FM4Alg8 : public FM4Op
{
public:
FM4Alg8();
virtual ~FM4Alg8();
virtual MY_FLOAT tick();
};
#endif

View File

@@ -1,59 +0,0 @@
/*******************************************/
/* Master Class for 4 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/* This instrument contains an 4 waves, */
/* 4 envelopes, and various state vars. */
/* */
/* The basic Chowning/Stanford FM patent */
/* expired April 1995, but there exist */
/* follow-on patents, mostly assigned to */
/* Yamaha. If you are of the type who */
/* should worry about this (making money) */
/* worry away. */
/* */
/*******************************************/
#if !defined(__FM4Op_h)
#define __FM4Op_h
#include "Instrmnt.h"
#include "ADSR.h"
#include "RawWvIn.h"
#include "TwoZero.h"
class FM4Op : public Instrmnt
{
protected:
ADSR *adsr[4];
RawWvIn *waves[4];
RawWvIn *vibWave;
TwoZero *twozero;
MY_FLOAT baseFreq;
MY_FLOAT ratios[4];
MY_FLOAT gains[4];
MY_FLOAT modDepth;
MY_FLOAT control1;
MY_FLOAT control2;
MY_FLOAT __FM4Op_gains[100];
MY_FLOAT __FM4Op_susLevels[16];
MY_FLOAT __FM4Op_attTimes[32];
public:
FM4Op();
virtual ~FM4Op();
void loadWaves(char* wave1, char* wave2, char* wave3, char* wave4);
void clear();
void setFreq(MY_FLOAT frequency);
void setRatio(int whichOne, MY_FLOAT ratio);
void setGain(int whichOne, MY_FLOAT gain);
void keyOn();
void keyOff();
void noteOff(MY_FLOAT amp);
/* There's no tick() method here, because that depends on the algorithm */
void setModulationSpeed(MY_FLOAT mSpeed);
void setModulationDepth(MY_FLOAT mDepth);
void setControl1(MY_FLOAT cVal);
void setControl2(MY_FLOAT cVal);
virtual void controlChange(int number, MY_FLOAT value);
};
#endif

View File

@@ -1,24 +1,65 @@
/******************************************/
/* Singing Voice Synthesis Subclass */
/* of Algorithm 6 (TX81Z) Subclass of */
/* 4 Operator FM Synth */
/* by Perry R. Cook, 1996 */
/******************************************/
/***************************************************/
/*! \class FMVoices
\brief STK singing FM synthesis instrument.
#if !defined(__FMVoices_h)
#define __FMVoices_h
This class implements 3 carriers and a common
modulator, also referred to as algorithm 6 of
the TX81Z.
#include "FM4Alg6.h"
\code
Algorithm 6 is :
/->1 -\
4-|-->2 - +-> Out
\->3 -/
\endcode
class FMVoices : public FM4Alg6
Control Change Numbers:
- Vowel = 2
- Spectral Tilt = 4
- LFO Speed = 11
- LFO Depth = 1
- ADSR 2 & 4 Target = 128
The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha. If you are of the
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__FMVOICES_H)
#define __FMVOICES_H
#include "FM.h"
class FMVoices : public FM
{
public:
//! Class constructor.
FMVoices();
//! Class destructor.
~FMVoices();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
protected:
int currentVowel;
public:
FMVoices();
virtual void setFreq(MY_FLOAT frequency);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
virtual void controlChange(int number, MY_FLOAT value);
MY_FLOAT tilt[3];
MY_FLOAT mods[3];
};
#endif

View File

@@ -1,28 +1,112 @@
/*******************************************/
/* Filter Class, by Perry R. Cook, 1995-96*/
/* This is the base class for all filters.*/
/* To me, most anything is a filter, but */
/* I'll be a little less general here, and*/
/* define a filter as something which has */
/* input(s), output(s), and gain. */
/*******************************************/
/***************************************************/
/*! \class Filter
\brief STK filter class.
#if !defined(__Filter_h)
#define __Filter_h
This class implements a generic structure which
can be used to create a wide range of filters.
It can function independently or be subclassed
to provide more specific controls based on a
particular filter type.
#include "Object.h"
In particular, this class implements the standard
difference equation:
class Filter : public Object
a[0]*y[n] = b[0]*x[n] + ... + b[nb]*x[n-nb] -
a[1]*y[n-1] - ... - a[na]*y[n-na]
If a[0] is not equal to 1, the filter coeffcients
are normalized by a[0].
The \e gain parameter is applied at the filter
input and does not affect the coefficient values.
The default gain value is 1.0. This structure
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.
*/
/***************************************************/
#if !defined(__FILTER_H)
#define __FILTER_H
#include "Stk.h"
class Filter : public Stk
{
protected:
public:
//! Default constructor creates a zero-order pass-through "filter".
Filter(void);
//! 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.
*/
Filter(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients);
//! Class destructor.
virtual ~Filter(void);
//! Clears all internal states of the filter.
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].
*/
void setCoefficients(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *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.
*/
void setNumerator(int nb, MY_FLOAT *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.
*/
void setDenominator(int na, MY_FLOAT *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);
//! Return the current filter gain.
virtual MY_FLOAT getGain(void) const;
//! Return the last computed output value.
virtual MY_FLOAT lastOut(void) const;
//! Input one sample to the filter and return one output.
virtual MY_FLOAT tick(MY_FLOAT 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);
protected:
MY_FLOAT gain;
int nB;
int nA;
MY_FLOAT *b;
MY_FLOAT *a;
MY_FLOAT *outputs;
MY_FLOAT *inputs;
MY_FLOAT lastOutput;
public:
Filter();
virtual ~Filter();
MY_FLOAT lastOut();
};
#endif

View File

@@ -1,64 +1,100 @@
/******************************************/
/* WaveGuide Flute ala Karjalainen, */
/* Smith, Waryznyk, etc. */
/* with polynomial Jet ala Cook */
/* by Perry Cook, 1995-96 */
/* */
/* This is a waveguide model, and thus */
/* relates to various Stanford Univ. */
/* and possibly Yamaha and other patents.*/
/* */
/* Controls: CONTROL1 = jetDelay */
/* CONTROL2 = noiseGain */
/* CONTROL3 = vibFreq */
/* MOD_WHEEL= vibAmt */
/******************************************/
/***************************************************/
/*! \class Flute
\brief STK flute physical model class.
#if !defined(__Flute_h)
#define __Flute_h
This class implements a simple flute
physical model, as discussed by Karjalainen,
Smith, Waryznyk, etc. The jet model uses
a polynomial, a la Cook.
This is a digital waveguide model, making its
use possibly subject to patents held by Stanford
University, Yamaha, and others.
Control Change Numbers:
- Jet Delay = 2
- Noise Gain = 4
- Vibrato Frequency = 11
- Vibrato Gain = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__FLUTE_H)
#define __FLUTE_H
#include "Instrmnt.h"
#include "JetTabl.h"
#include "DLineL.h"
#include "DelayL.h"
#include "OnePole.h"
#include "DCBlock.h"
#include "PoleZero.h"
#include "Noise.h"
#include "ADSR.h"
#include "RawWvIn.h"
#include "WaveLoop.h"
class Flute : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Flute(MY_FLOAT lowestFrequency);
//! Class destructor.
~Flute();
//! Reset and clear all internal state.
void clear();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
//! Set the reflection coefficient for the jet delay (-1.0 - 1.0).
void setJetReflection(MY_FLOAT coefficient);
//! Set the reflection coefficient for the air column delay (-1.0 - 1.0).
void setEndReflection(MY_FLOAT 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);
//! Apply breath velocity to instrument with given amplitude and rate of increase.
void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate);
//! Decrease breath velocity with given rate of decrease.
void stopBlowing(MY_FLOAT rate);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
protected:
DLineL *jetDelay;
DLineL *boreDelay;
DelayL *jetDelay;
DelayL *boreDelay;
JetTabl *jetTable;
OnePole *filter;
DCBlock *dcBlock;
PoleZero *dcBlock;
Noise *noise;
ADSR *adsr;
RawWvIn *vibr;
MY_FLOAT lastFreq;
WaveLoop *vibrato;
long length;
MY_FLOAT lastFrequency;
MY_FLOAT maxPressure;
MY_FLOAT jetRefl;
MY_FLOAT endRefl;
MY_FLOAT jetReflection;
MY_FLOAT endReflection;
MY_FLOAT noiseGain;
MY_FLOAT vibrGain;
MY_FLOAT vibratoGain;
MY_FLOAT outputGain;
MY_FLOAT jetRatio;
public:
Flute(MY_FLOAT lowestFreq);
~Flute();
void clear();
void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate);
void stopBlowing(MY_FLOAT rate);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
virtual void noteOff(MY_FLOAT amp);
void setJetRefl(MY_FLOAT refl);
void setEndRefl(MY_FLOAT refl);
virtual void setFreq(MY_FLOAT frequency);
virtual MY_FLOAT tick();
virtual void controlChange(int number, MY_FLOAT value);
void setJetDelay(MY_FLOAT aLength);
};
#endif

View File

@@ -1,46 +1,93 @@
/*******************************************/
/* Sweepable Formant (2-pole) */
/* Filter Class, by Perry R. Cook, 1995-96*/
/* See books on filters to understand */
/* more about how this works. Nothing */
/* out of the ordinary in this version. */
/*******************************************/
/***************************************************/
/*! \class FormSwep
\brief STK sweepable formant filter class.
#if !defined(__FormSwep_h)
#define __FormSwep_h
This public BiQuad filter subclass implements
a formant (resonance) which can be "swept"
over time from one frequency setting to another.
It provides methods for controlling the sweep
rate and target frequency.
#include "Filter.h"
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
class FormSwep : public Filter
#if !defined(__FORMSWEP_H)
#define __FORMSWEP_H
#include "BiQuad.h"
class FormSwep : public BiQuad
{
public:
//! Default constructor creates a second-order pass-through filter.
FormSwep();
//! Class destructor.
~FormSwep();
//! Sets the filter coefficients for a resonance at \e frequency (in Hz).
/*!
This method determines the filter coefficients corresponding to
two complex-conjugate poles with the given \e frequency (in Hz)
and \e radius from the z-plane origin. The filter zeros are
placed at z = 1, z = -1, and the coefficients are then normalized to
produce a constant unity gain (independent of the filter \e gain
parameter). The resulting filter frequency response has a
resonance at the given \e 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 aFrequency, MY_FLOAT aRadius);
//! Set both the current and target resonance parameters.
void setStates(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0);
//! Set target resonance parameters.
void setTargets(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0);
//! Set the sweep rate (between 0.0 - 1.0).
/*!
The formant parameters are varied in increments of the
sweep rate between their current and target values.
A sweep rate of 1.0 will produce an immediate change in
resonance parameters from their current values to the
target values. A sweep rate of 0.0 will produce no
change in resonance parameters.
*/
void setSweepRate(MY_FLOAT aRate);
//! Set the sweep rate in terms of a time value in seconds.
/*!
This method adjusts the sweep rate based on a
given time for the formant parameters to reach
their target values.
*/
void setSweepTime(MY_FLOAT aTime);
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT 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);
protected:
MY_FLOAT poleCoeffs[2];
MY_FLOAT freq;
MY_FLOAT reson;
int dirty;
MY_FLOAT targetFreq;
MY_FLOAT targetReson;
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 currentFreq;
MY_FLOAT currentReson;
MY_FLOAT currentGain;
MY_FLOAT deltaFreq;
MY_FLOAT deltaReson;
MY_FLOAT deltaFrequency;
MY_FLOAT deltaRadius;
MY_FLOAT deltaGain;
MY_FLOAT sweepState;
MY_FLOAT sweepRate;
public:
FormSwep();
~FormSwep();
void clear();
void setPoleCoeffs(MY_FLOAT *coeffs);
void setGain(MY_FLOAT aValue);
void setFreqAndReson(MY_FLOAT aFreq, MY_FLOAT aReson);
void setStates(MY_FLOAT aFreq, MY_FLOAT aReson, MY_FLOAT aGain);
void setTargets(MY_FLOAT aFreq, MY_FLOAT aReson, MY_FLOAT aGain);
void setSweepRate(MY_FLOAT aRate);
void setSweepTime(MY_FLOAT aTime);
MY_FLOAT tick(MY_FLOAT sample);
};
#endif

View File

@@ -1,22 +0,0 @@
/******************************************/
/* Heavy Metal Synth Subclass */
/* of Algorithm 3 (TX81Z) Subclass of */
/* 3 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/******************************************/
#if !defined(__HeavyMtl_h)
#define __HeavyMtl_h
#include "FM4Alg3.h"
class HeavyMtl : public FM4Alg3
{
public:
HeavyMtl();
~HeavyMtl();
virtual void setFreq(MY_FLOAT frequency);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
};
#endif

52
include/HevyMetl.h Normal file
View File

@@ -0,0 +1,52 @@
/***************************************************/
/*! \class HevyMetl
\brief STK heavy metal FM synthesis instrument.
This class implements 3 cascade operators with
feedback modulation, also referred to as
algorithm 3 of the TX81Z.
\code
Algorithm 3 is : 4--\
3-->2-- + -->1-->Out
\endcode
Control Change Numbers:
- Total Modulator Index = 2
- Modulator Crossfade = 4
- LFO Speed = 11
- LFO Depth = 1
- ADSR 2 & 4 Target = 128
The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha. If you are of the
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__HEVYMETL_H)
#define __HEVYMETL_H
#include "FM.h"
class HevyMetl : public FM
{
public:
//! Class constructor.
HevyMetl();
//! Class destructor.
~HevyMetl();
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
};
#endif

View File

@@ -1,26 +1,53 @@
/******************************************/
/* Instrument SuperClass for Toolkit96 */
/* Perry R. Cook, Princeton University */
/******************************************/
/***************************************************/
/*! \class Instrmnt
\brief STK instrument abstract base class.
#if !defined(__Instrmnt_h)
#define __Instrmnt_h
This class provides a common interface for
all STK instruments.
#include "Object.h"
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
class Instrmnt : public Object
#if !defined(__INSTRMNT_H)
#define __INSTRMNT_H
#include "Stk.h"
#include <iostream.h>
class Instrmnt : public Stk
{
public:
//! Default constructor.
Instrmnt();
//! Class destructor.
virtual ~Instrmnt();
//! Start a note with the given frequency and amplitude.
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) = 0;
//! Stop a note with the given amplitude (speed of decay).
virtual void noteOff(MY_FLOAT amplitude) = 0;
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
//! Return the last output value.
MY_FLOAT lastOut() const;
//! Compute one output sample.
virtual MY_FLOAT tick() = 0;
//! Computer \e vectorSize outputs and return them in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
protected:
MY_FLOAT lastOutput;
public:
Instrmnt();
virtual ~Instrmnt();
MY_FLOAT lastOut();
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
virtual void noteOff(MY_FLOAT amp);
virtual void setFreq(MY_FLOAT frequency);
virtual MY_FLOAT tick();
virtual void controlChange(int number, MY_FLOAT value);
};
#endif

View File

@@ -1,51 +1,48 @@
/*******************************************/
/* JVRev Reverb Subclass */
/* by Tim Stilson, 1998 */
/* based on CLM JCRev */
/* Integrated into STK by Gary Scavone */
/* */
/* This is based on some of the famous */
/* Stanford CCRMA reverbs (NRev, KipRev) */
/* all based on the Chowning/Moorer/ */
/* Schroeder reverberators, which use */
/* networks of simple allpass and comb */
/* delay filters. This particular */
/* arrangement consists of 3 allpass */
/* filters in series, followed by 4 comb */
/* filters in parallel, an optional */
/* lowpass filter, and two decorrelation */
/* delay lines in parallel at the output. */
/*******************************************/
/***************************************************/
/*! \class JCRev
\brief John Chowning's reverberator class.
#if !defined(__JCRev_h)
#define __JCRev_h
This class is derived from the CLM JCRev
function, which is based on the use of
networks of simple allpass and comb delay
filters. This class implements three series
allpass units, followed by four parallel comb
filters, and two decorrelation delay lines in
parallel at the output.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__JCREV_H)
#define __JCREV_H
#include "Object.h"
#include "Reverb.h"
#include "DLineN.h"
#include "Delay.h"
class JCRev : public Reverb
{
protected:
DLineN *APdelayLine[3];
DLineN *CdelayLine[4];
DLineN *outLdelayLine;
DLineN *outRdelayLine;
MY_FLOAT allPassCoeff;
MY_FLOAT combCoeff[4];
MY_FLOAT combsum,combsum1,combsum2;
MY_FLOAT lastOutL;
MY_FLOAT lastOutR;
MY_FLOAT effectMix;
public:
// Class constructor taking a T60 decay time argument.
JCRev(MY_FLOAT T60);
// Class destructor.
~JCRev();
//! Reset and clear all internal state.
void clear();
void setEffectMix(MY_FLOAT mix);
MY_FLOAT lastOutput();
MY_FLOAT lastOutputL();
MY_FLOAT lastOutputR();
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
protected:
Delay *allpassDelays[3];
Delay *combDelays[4];
Delay *outLeftDelay;
Delay *outRightDelay;
MY_FLOAT allpassCoefficient;
MY_FLOAT combCoefficient[4];
};
#endif

View File

@@ -1,27 +1,44 @@
/**********************************************/
/* Jet Table Object by Perry R. Cook, 1995-96 */
/* Consult Fletcher and Rossing, Karjalainen, */
/* Cook, more, for information. */
/* This, as with many other of my "tables", */
/* is not a table, but is computed by poly- */
/* nomial calculation. */
/**********************************************/
/***************************************************/
/*! \class JetTabl
\brief STK jet table class.
#if !defined(__JetTabl_h)
#define __JetTabl_h
This class implements a flue jet non-linear
function, computed by a polynomial calculation.
Contrary to the name, this is not a "table".
#include "Object.h"
Consult Fletcher and Rossing, Karjalainen,
Cook, and others for more information.
class JetTabl : public Object
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;
public:
JetTabl();
~JetTabl();
MY_FLOAT lookup(MY_FLOAT deltaP);
MY_FLOAT tick(MY_FLOAT deltaP);
MY_FLOAT lastOut();
};
#endif

View File

@@ -1,28 +0,0 @@
/************************************************/
/* Lip Filter Object by Perry R. Cook, 1995-96 */
/* The lip of the brass player has dynamics */
/* which are controlled by the mass, spring */
/* constant, and damping of the lip. This */
/* filter simulates that behavior and the */
/* transmission/reflection properties as */
/* well. See Cook TBone and HosePlayer */
/* instruments and articles. */
/************************************************/
#include "Object.h"
#include "BiQuad.h"
class LipFilt : public Object
{
protected:
BiQuad *filter;
MY_FLOAT lastOutput;
public:
LipFilt();
~LipFilt();
void clear();
void setFreq(MY_FLOAT frequency);
MY_FLOAT tick(MY_FLOAT mouthSample,MY_FLOAT boreSample);
MY_FLOAT lastOut();
};

View File

@@ -1,44 +1,71 @@
/********************************************/
/* Commuted Mandolin Subclass of enhanced */
/* dual plucked-string model */
/* by Perry Cook, 1995-96 */
/* Controls: CONTROL1 = bodySize */
/* CONTROL2 = pluckPosition */
/* CONTROL3 = loopGain */
/* MOD_WHEEL= deTuning */
/* */
/* Note: Commuted Synthesis, as with many */
/* other WaveGuide techniques, is covered */
/* by patents, granted, pending, and/or */
/* applied-for. All are assigned to the */
/* Board of Trustees, Stanford University. */
/* For information, contact the Office of */
/* Technology Licensing, Stanford U. */
/********************************************/
/***************************************************/
/*! \class Mandolin
\brief STK mandolin instrument model class.
#if !defined(__Mandolin_h)
#define __Mandolin_h
This class inherits from PluckTwo and uses
"commuted synthesis" techniques to model a
mandolin instrument.
#include "Plucked2.h"
#include "RawWvIn.h"
This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.
Commuted Synthesis, in particular, is covered
by patents, granted, pending, and/or
applied-for. All are assigned to the Board of
Trustees, Stanford University. For
information, contact the Office of Technology
Licensing, Stanford University.
class Mandolin : public Plucked2
Control Change Numbers:
- Body Size = 2
- Pluck Position = 4
- String Sustain = 11
- String Detuning = 1
- Microphone Position = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__MANDOLIN_H)
#define __MANDOLIN_H
#include "PluckTwo.h"
#include "WvIn.h"
class Mandolin : public PluckTwo
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Mandolin(MY_FLOAT lowestFrequency);
//! Class destructor.
virtual ~Mandolin();
//! Pluck the strings with the given amplitude (0.0 - 1.0) using the current frequency.
void pluck(MY_FLOAT 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);
//! Start a note with the given frequency and amplitude (0.0 - 1.0).
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Set the body size (a value of 1.0 produces the "default" size).
void setBodySize(MY_FLOAT size);
//! Compute one output sample.
virtual MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
protected:
RawWvIn *soundfile[12];
WvIn *soundfile[12];
MY_FLOAT directBody;
int mic;
long dampTime;
int waveDone;
public:
Mandolin(MY_FLOAT lowestFreq);
virtual ~Mandolin();
void pluck(MY_FLOAT amplitude);
void pluck(MY_FLOAT amplitude,MY_FLOAT position);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
void setBodySize(MY_FLOAT size);
virtual void controlChange(int number, MY_FLOAT value);
virtual MY_FLOAT tick();
bool waveDone;
};
#endif

View File

@@ -1,37 +0,0 @@
/*******************************************/
/* MatWvIn Input Class, */
/* by Gary P. Scavone, 1999 */
/* */
/* This object inherits from WvIn and is */
/* used to open Matlab MAT-file data */
/* (doubles) files for playback. In */
/* order for this class to work, the */
/* MAT-file must contain a single array */
/* (matrix) of double-precision floating */
/* point values (can be multi-channel). */
/* It does not work for any other data */
/* formats. */
/* */
/* MAT-file data is either big- or */
/* little-endian, which can be determined */
/* from the header. */
/*******************************************/
#if !defined(__MatWvIn_h)
#define __MatWvIn_h
#include "Object.h"
#include "WvIn.h"
class MatWvIn : public WvIn
{
public:
MatWvIn(char *fileName, char *mode);
~MatWvIn();
protected:
void getData(long index);
int doSwap;
int interleaved;
};
#endif

View File

@@ -1,36 +0,0 @@
/*******************************************/
/* Matlab MAT-file Output Class, */
/* by Gary P. Scavone, 1999. */
/* This object creates a Matlab MAT-file */
/* structure with a numeric array */
/* subelement and fills it with buffers */
/* of samples (doubles). */
/* */
/* When originally created, the Matlab */
/* MAT-file format was not public and I */
/* had to reverse-engineer the format. */
/* Matlab finally released the format in */
/* the Spring of 1999, and this class was */
/* updated to more closely adhere to */
/* specifications. */
/*******************************************/
#if !defined(__MatWvOut_h)
#define __MatWvOut_h
#include "Object.h"
#include "WvOut.h"
class MatWvOut : public WvOut
{
protected:
FILE *fd;
double *matdata; /* not MY_FLOAT because MAT-file uses doubles */
public:
MatWvOut(char *infileName, int chans = 1);
~MatWvOut();
void tick(MY_FLOAT sample);
void mtick(MY_MULTI samples);
};
#endif // defined(__MatWvOut_h)

105
include/Mesh2D.h Normal file
View File

@@ -0,0 +1,105 @@
/***************************************************/
/*! \class Mesh2D
\brief Two-dimensional rectilinear waveguide mesh class.
This class implements a rectilinear,
two-dimensional digital waveguide mesh
structure. For details, see Van Duyne and
Smith, "Physical Modeling with the 2-D Digital
Waveguide Mesh", Proceedings of the 1993
International Computer Music Conference.
This is a digital waveguide model, making its
use possibly subject to patents held by Stanford
University, Yamaha, and others.
Control Change Numbers:
- X Dimension = 2
- Y Dimension = 4
- Mesh Decay = 11
- X-Y Input Position = 1
by Julius Smith, 2000 - 2002.
Revised by Gary Scavone for STK, 2002.
*/
/***************************************************/
#if !defined(__MESH2D_H)
#define __MESH2D_H
#include "Instrmnt.h"
#include "OnePole.h"
#define NXMAX ((short)(12))
#define NYMAX ((short)(12))
class Mesh2D : public Instrmnt
{
public:
//! Class constructor, taking the x and y dimensions in samples.
Mesh2D(short nX, short nY);
//! Class destructor.
~Mesh2D();
//! Reset and clear all internal state.
void clear();
//! Set the x dimension size in samples.
void setNX(short lenX);
//! Set the y dimension size in samples.
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);
//! Set the loss filters gains (0.0 - 1.0).
void setDecay(MY_FLOAT decayFactor);
//! Impulse the mesh with the given amplitude (frequency ignored).
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay) ... currently ignored.
void noteOff(MY_FLOAT amplitude);
//! Calculate and return the signal energy stored in the mesh.
MY_FLOAT energy();
//! Compute one output sample, without adding energy to the mesh.
MY_FLOAT tick();
//! Input a sample to the mesh and compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
protected:
MY_FLOAT tick0();
MY_FLOAT 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
// 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
};
#endif

147
include/Messager.h Normal file
View File

@@ -0,0 +1,147 @@
/***************************************************/
/*! \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.
For each call to nextMessage(), the active
input sources are queried to see if a new
control message is available.
This class is primarily for use in STK main()
event loops.
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.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__MESSAGER_H)
#define __MESSSAGER_H
#include "Stk.h"
#include "SKINI.h"
#define MESSAGE_LENGTH 128
#define MAX_MESSAGES 25
#if defined(__STK_REALTIME__)
#include "Thread.h"
#include "Socket.h"
#include "RtMidi.h"
#define STK_MIDI 0x0001
#define STK_PIPE 0x0002
#define STK_SOCKET 0x0004
extern "C" THREAD_RETURN THREAD_TYPE stdinHandler(void * ptr);
#if (defined(__OS_IRIX__) || defined(__OS_LINUX__))
#include <sys/types.h>
#include <sys/time.h>
#endif
#endif // __STK_REALTIME__
class Messager : public Stk
{
public:
//! Constructor performs initialization based on an input mask.
/*!
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. For realtime input types, an StkError can be
thrown during instantiation.
*/
Messager(int inputMask = 0);
//! Class destructor.
~Messager();
//! Check for a new input message and return the message type.
/*!
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.
*/
long nextMessage(void);
//! Set the delta time (in samples) returned between valid realtime messages. This setting has no affect for scorefile messages.
void setRtDelta(long nSamples);
//! Return the current message "delta time" in samples.
long getDelta(void) const;
//! Return the current message type.
long getType() const;
//! Return the byte two value for the current message.
MY_FLOAT getByteTwo() const;
//! Return the byte three value for the current message.
MY_FLOAT getByteThree() const;
//! Return the channel number for the current message.
long getChannel() const;
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;
#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__
};
#endif // defined(__MESSAGER_H)

86
include/Modal.h Normal file
View File

@@ -0,0 +1,86 @@
/***************************************************/
/*! \class Modal
\brief STK resonance model instrument.
This class contains an excitation wavetable,
an envelope, an oscillator, and N resonances
(non-sweeping BiQuad filters), where N is set
during instantiation.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__MODAL_H)
#define __MODAL_H
#include "Instrmnt.h"
#include "Envelope.h"
#include "WaveLoop.h"
#include "BiQuad.h"
#include "OnePole.h"
class Modal : public Instrmnt
{
public:
//! Class constructor, taking the desired number of modes to create.
Modal( int modes = 4 );
//! Class destructor.
virtual ~Modal();
//! Reset and clear all internal state.
void clear();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
//! Set the ratio and radius for a specified mode filter.
void setRatioAndRadius(int modeIndex, MY_FLOAT ratio, MY_FLOAT radius);
//! Set the master gain.
void setMasterGain(MY_FLOAT aGain);
//! Set the direct gain.
void setDirectGain(MY_FLOAT aGain);
//! Set the gain for a specified mode filter.
void setModeGain(int modeIndex, MY_FLOAT gain);
//! Initiate a strike with the given amplitude (0.0 - 1.0).
virtual void strike(MY_FLOAT amplitude);
//! Damp modes with a given decay factor (0.0 - 1.0).
void damp(MY_FLOAT amplitude);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
virtual MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT 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;
};
#endif

View File

@@ -1,55 +0,0 @@
/*******************************************/
/*
Four Resonance Modal Synthesis Instrument
by Perry R. Cook, 1995-2000
This instrument contains an excitation
wavetable, an envelope, an oscillator,
and four resonances (Non-Sweeping BiQuad
Filters).
*/
/*******************************************/
#if !defined(__Modal4_h)
#define __Modal4_h
#include "Instrmnt.h"
#include "Envelope.h"
#include "RawWvIn.h"
#include "BiQuad.h"
#include "OnePole.h"
class Modal4 : public Instrmnt
{
protected:
Envelope *envelope;
RawWvIn *wave;
BiQuad *filters[4];
OnePole *onepole;
RawWvIn *vibr;
MY_FLOAT vibrGain;
MY_FLOAT masterGain;
MY_FLOAT directGain;
MY_FLOAT stickHardness;
MY_FLOAT strikePosition;
MY_FLOAT baseFreq;
MY_FLOAT ratios[4];
MY_FLOAT resons[4];
public:
Modal4();
virtual ~Modal4();
void clear();
virtual void setFreq(MY_FLOAT frequency);
void setRatioAndReson(int whichOne, MY_FLOAT ratio, MY_FLOAT reson);
void setMasterGain(MY_FLOAT aGain);
void setDirectGain(MY_FLOAT aGain);
void setFiltGain(int whichOne, MY_FLOAT gain);
virtual void strike(MY_FLOAT amplitude);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
virtual void noteOff(MY_FLOAT amp);
void damp(MY_FLOAT amplitude);
virtual void controlChange(int number, MY_FLOAT value);
virtual MY_FLOAT tick();
};
#endif

View File

@@ -1,30 +1,60 @@
/*******************************************/
/*
ModalBar SubClass of Modal4 Instrument
by Perry R. Cook, 1999-2000
/***************************************************/
/*! \class ModalBar
\brief STK resonant bar instrument class.
Controls: CONTROL1 = stickHardness
CONTROL2 = strikePosition
CONTROL3 = Mode Presets
This class implements a number of different
struck bar instruments. It inherits from the
Modal class.
Control Change Numbers:
- Stick Hardness = 2
- Stick Position = 4
- Vibrato Gain = 11
- Vibrato Frequency = 7
- Volume = 128
- Modal Presets = 16
- Marimba = 0
- Vibraphone = 1
- Agogo = 2
- Wood1 = 3
- Reso = 4
- Wood2 = 5
- Beats = 6
- Two Fixed = 7
- Clump = 8
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/*******************************************/
/***************************************************/
#if !defined(__ModalBar_h)
#define __ModalBar_h
#if !defined(__MODALBAR_H)
#define __MODALBAR_H
#include "Modal4.h"
#include "Modal.h"
class ModalBar : public Modal4
class ModalBar : public Modal
{
private:
public:
//! Class constructor.
ModalBar();
//! Class destructor.
~ModalBar();
//! Set stick hardness (0.0 - 1.0).
void setStickHardness(MY_FLOAT hardness);
//! Set stick position (0.0 - 1.0).
void setStrikePosition(MY_FLOAT position);
void setModalPreset(int which);
//! Select a bar preset (currently modulo 9).
void setPreset(int preset);
//! Set the modulation (vibrato) depth.
void setModulationDepth(MY_FLOAT mDepth);
virtual void controlChange(int number, MY_FLOAT value);
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
void controlChange(int number, MY_FLOAT value);
};
#endif

61
include/Modulate.h Normal file
View File

@@ -0,0 +1,61 @@
/***************************************************/
/*! \class Modulate
\brief STK periodic/random modulator.
This class combines random and periodic
modulations to give a nice, natural human
modulation function.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__MODULATE_H)
#define __MODULATE_H
#include "Stk.h"
#include "WaveLoop.h"
#include "SubNoise.h"
#include "OnePole.h"
class Modulate : public Stk
{
public:
//! Class constructor.
Modulate();
//! Class destructor.
~Modulate();
//! Reset internal state.
void reset();
//! Set the periodic (vibrato) rate or frequency in Hz.
void setVibratoRate(MY_FLOAT aRate);
//! Set the periodic (vibrato) gain.
void setVibratoGain(MY_FLOAT aGain);
//! Set the random modulation gain.
void setRandomGain(MY_FLOAT aGain);
//! Compute one output sample.
MY_FLOAT tick();
//! Return \e vectorSize outputs in \e vector.
virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
//! Return the last computed output value.
MY_FLOAT lastOut() const;
protected:
WaveLoop *vibrato;
SubNoise *noise;
OnePole *filter;
MY_FLOAT vibratoGain;
MY_FLOAT randomGain;
MY_FLOAT lastOutput;
};
#endif

View File

@@ -1,36 +0,0 @@
/*******************************************/
/* Modulator Class, Perry R. Cook, 1995-96*/
/* This Object combines random and */
/* periodic modulations to give a nice */
/* natural human modulation function. */
/*******************************************/
#if !defined(__Modulatr_h)
#define __Modulatr_h
#include "Object.h"
#include "RawWvIn.h"
#include "SubNoise.h"
#include "OnePole.h"
class Modulatr : public Object
{
protected:
RawWvIn *vibwave;
SubNoise *noise;
OnePole *onepole;
MY_FLOAT vibAmt;
MY_FLOAT rndAmt;
MY_FLOAT lastOutput;
public:
Modulatr();
~Modulatr();
void reset();
void setVibFreq(MY_FLOAT vibFreq);
void setVibAmt(MY_FLOAT vibAmount);
void setRndAmt(MY_FLOAT rndAmount);
MY_FLOAT tick();
MY_FLOAT lastOut();
};
#endif

62
include/Moog.h Normal file
View File

@@ -0,0 +1,62 @@
/***************************************************/
/*! \class Moog
\brief STK moog-like swept filter sampling synthesis class.
This instrument uses one attack wave, one
looped wave, and an ADSR envelope (inherited
from the Sampler class) and adds two sweepable
formant (FormSwep) filters.
Control Change Numbers:
- Filter Q = 2
- Filter Sweep Rate = 4
- Vibrato Frequency = 11
- Vibrato Gain = 1
- Gain = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__MOOG_H)
#define __MOOG_H
#include "Sampler.h"
#include "FormSwep.h"
class Moog : public Sampler
{
public:
//! Class constructor.
Moog();
//! Class destructor.
~Moog();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
//! Start a note with the given frequency and amplitude.
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Set the modulation (vibrato) speed in Hz.
void setModulationSpeed(MY_FLOAT mSpeed);
//! Set the modulation (vibrato) depth.
void setModulationDepth(MY_FLOAT mDepth);
//! Compute one output sample.
virtual MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
protected:
FormSwep *filters[2];
MY_FLOAT modDepth;
MY_FLOAT filterQ;
MY_FLOAT filterRate;
};
#endif

View File

@@ -1,34 +0,0 @@
/******************************************/
/* Moog1 Subclass of */
/* Sampling Synthesizer Class */
/* by Perry R. Cook, 1995-96 */
/* */
/* Controls: CONTROL1 = filterQ */
/* CONTROL2 = filterRate */
/* CONTROL3 = vibFreq */
/* MOD_WHEEL= vibAmt */
/******************************************/
#if !defined(__Moog1_h)
#define __Moog1_h
#include "SamplFlt.h"
class Moog1 : public SamplFlt
{
private:
MY_FLOAT modDepth;
MY_FLOAT filterQ;
MY_FLOAT filterRate;
public:
Moog1();
~Moog1();
virtual void setFreq(MY_FLOAT frequency);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
void setModulationSpeed(MY_FLOAT mSpeed);
void setModulationDepth(MY_FLOAT mDepth);
virtual void controlChange(int number, MY_FLOAT value);
virtual MY_FLOAT tick();
};
#endif

View File

@@ -1,51 +1,49 @@
/******************************************/
/* NRev Reverb Subclass */
/* by Tim Stilson, 1998 */
/* based on CLM NRev */
/* Integrated into STK by Gary Scavone */
/* */
/* This is based on some of the famous */
/* Stanford CCRMA reverbs (NRev, KipRev) */
/* all based on the the Chowning/Moorer/ */
/* Schroeder reverberators, which use */
/* networks of simple allpass and comb */
/* delay filters. This particular */
/* arrangement consists of 6 comb */
/* filters in parallel, followed by 3 */
/* allpass filters, a lowpass filter, */
/* and another allpass in series, */
/* followed by two allpass filters in */
/* parallel with corresponding right and */
/* left outputs. */
/******************************************/
/***************************************************/
/*! \class NRev
\brief CCRMA's NRev reverberator class.
#if !defined(__NRev_h)
#define __NRev_h
This class is derived from the CLM NRev
function, which is based on the use of
networks of simple allpass and comb delay
filters. This particular arrangement consists
of 6 comb filters in parallel, followed by 3
allpass filters, a lowpass filter, and another
allpass in series, followed by two allpass
filters in parallel with corresponding right
and left outputs.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__NREV_H)
#define __NREV_H
#include "Object.h"
#include "Reverb.h"
#include "DLineN.h"
#include "Delay.h"
class NRev : public Reverb
{
protected:
DLineN *APdelayLine[8];
DLineN *CdelayLine[6];
MY_FLOAT allPassCoeff;
MY_FLOAT combCoef[6];
MY_FLOAT lpLastout;
MY_FLOAT lastOutL;
MY_FLOAT lastOutR;
MY_FLOAT effectMix;
public:
// Class constructor taking a T60 decay time argument.
NRev(MY_FLOAT T60);
// Class destructor.
~NRev();
//! Reset and clear all internal state.
void clear();
void setEffectMix(MY_FLOAT mix);
MY_FLOAT lastOutput();
MY_FLOAT lastOutputL();
MY_FLOAT lastOutputR();
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
protected:
Delay *allpassDelays[8];
Delay *combDelays[6];
MY_FLOAT allpassCoefficient;
MY_FLOAT combCoefficient[6];
MY_FLOAT lowpassState;
};
#endif

View File

@@ -1,23 +1,43 @@
/*******************************************/
/* Noise Generator Class, */
/* by Perry R. Cook, 1995-96 */
/* White noise as often as you like. */
/*******************************************/
/***************************************************/
/*! \class Noise
\brief STK noise generator.
#if !defined(__Noise_h)
#define __Noise_h
Generic random number generation using the
C rand() function. The quality of the rand()
function varies from one OS to another.
#include "Object.h"
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
class Noise : public Object
#if !defined(__NOISE_H)
#define __NOISE_H
#include "Stk.h"
class Noise : public Stk
{
protected:
MY_FLOAT lastOutput;
public:
public:
//! Default constructor.
Noise();
//! Class destructor.
virtual ~Noise();
MY_FLOAT tick();
MY_FLOAT lastOut();
//! Return a random number between -1.0 and 1.0 using rand().
virtual MY_FLOAT 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);
//! Return the last computed value.
MY_FLOAT lastOut() const;
protected:
MY_FLOAT lastOutput;
};
#endif

View File

@@ -1,137 +0,0 @@
/*********************************************/
/* Object Class, by Perry R. Cook, 1995-99 */
/* */
/* This is mostly here for compatibility */
/* with Objective C. We'll also stick */
/* global defines here, so everyone will */
/* see them. */
/*********************************************/
#if !defined(__Object_h)
#define __Object_h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
class Object
{
public:
protected:
Object();
virtual ~Object();
};
/* The OS type definitions are made in the Makefile */
#if defined(__OS_NeXT_) /* For NeXTStep - Black or White Hardware */
#define RANDLIMIT 2147483647
#elif defined(__OS_IRIX_) /* For SGI */
#define __STK_REALTIME_
#define RANDLIMIT 2147483647
#elif defined(__OS_Linux_) /* For Linux */
#define __STK_REALTIME_
#define __OSS_API_ /* Use OSS API */
// #define __MIDIATOR_ /* Use special MIDIator support */
// #define __ALSA_API_ /* Use ALSA API */
#define __LITTLE_ENDIAN__
#define RANDLIMIT 2147483647
#elif defined(__OS_Win_) /* For WindowsXX or NT */
#define __STK_REALTIME_
#define __LITTLE_ENDIAN__
#define RANDLIMIT 32767
#endif
/*
Real-time audio input and output buffer size. If clicks
are occuring in the input or output sound stream, a
larger buffer size may help. Larger buffer sizes, however,
produce more latency between input and output.
*/
#define RT_BUFFER_SIZE 256
/*
The following definition is concatenated to the beginning
of all references to rawwave files in the various STK core
classes (ex. Clarinet.cpp). If you wish to move the
rawwaves directory to a different location in your file
system, you will need to set this path definition
appropriately. The current definition is a relative reference
that will work "out of the box" for the STK distribution.
*/
#define RAWWAVE_PATH "../../"
/* Sampling Rate */
#define SRATE (MY_FLOAT) 22050.0
/* Other SRATE derived defines */
#define SRATE_OVER_TWO (MY_FLOAT) (SRATE / 2)
#define ONE_OVER_SRATE (MY_FLOAT) (1 / SRATE)
#define TWO_PI_OVER_SRATE (MY_FLOAT) (2 * PI / SRATE)
/* Yer Basic Trigonometric constants */
#if !defined(PI)
#define PI (MY_FLOAT) 3.14159265359
#endif
#define TWO_PI (MY_FLOAT) (MY_FLOAT) (2 * PI)
#define ONE_OVER_TWO_PI (MY_FLOAT) (1.0 / PI)
#define SQRT_TWO 1.414213562
/* Useful random number generator values */
#define ONE_OVER_RANDLIMIT (1.0/RANDLIMIT)
#define RANDLIMIT_OVER_TWO (int)(RANDLIMIT/2)
/* FPU Underflow Limit
* The IEEE specification doesn't call for automatic
* zeroing of floating-point values when they reach
* their numerical limits. Instead, most processors
* switch to a much more computation-intensive mode
* when a FPU underflow occurs. We set a lower limit
* here for our own (not so efficient) checks. Here's
* a useful macro for limiting MY_FLOATs. At this time,
* no FPU underflow checks are being performed.
*/
#define FPU_UFLOW_LIMIT 0.0000000001
#define LIMIT_MY_FLOAT(j) ((((j)<(MY_FLOAT)FPU_UFLOW_LIMIT)&&((j)>(MY_FLOAT)-FPU_UFLOW_LIMIT))?(MY_FLOAT)0.0:(j))
/* States for Envelopes, etc. */
#define ATTACK 0
#define DECAY 1
#define SUSTAIN 2
#define RELEASE 3
/* Machine dependent stuff, possibly useful for optimization.
* For example, changing double to float here increases
* performance (speed) by a whopping 4-6% on 486-flavor machines.
* BUT!! a change from float to double here increases speed by
* 30% or so on SGI machines.
*/
#define MY_FLOAT double
//#define MY_FLOAT float
/* MY_MULTI is just a pointer to MY_FLOAT. This type is used
* to pass multichannel data back and forth within STK.
*/
typedef MY_FLOAT *MY_MULTI;
/* INT16 is just that ... a 16-bit signed integer. */
typedef signed short INT16;
/* INT32 is just that ... a 32-bit signed integer. */
typedef int INT32;
/* Boolean values */
#define FALSE 0
#define TRUE 1
/* Debugging define, causes massive printf's to come out.
* Also enables timing calculations in WaveOut class, other stuff.
* Uncomment to enable.
*/
//#define _debug_ 1
/* MIDI definitions */
#define NORM_7 (MY_FLOAT) 0.0078125 /* this is 1/128 */
#endif

View File

@@ -1,44 +1,72 @@
/*******************************************/
/*
One Pole Filter Class,
by Perry R. Cook, 1995-96.
Added methods by Julius Smith, 2000.
/***************************************************/
/*! \class OnePole
\brief STK one-pole filter class.
The parameter gain is an additional
gain parameter applied to the filter
on top of the normalization that takes
place automatically. So the net max
gain through the system equals the
value of gain. sgain is the combina-
tion of gain and the normalization
parameter, so if you set the poleCoeff
to alpha, sgain is always set to
gain * (1.0 - fabs(alpha)).
This protected Filter subclass implements
a one-pole digital filter. A method is
provided for setting the pole position along
the real axis of the z-plane while maintaining
a constant peak filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/*******************************************/
/***************************************************/
#if !defined(__OnePole_h)
#define __OnePole_h
#if !defined(__ONEPOLE_H)
#define __ONEPOLE_H
#include "Filter.h"
class OnePole : public Filter
class OnePole : protected Filter
{
protected:
MY_FLOAT poleCoeff;
MY_FLOAT sgain;
public:
//! Default constructor creates a first-order low-pass filter.
OnePole();
//! Overloaded constructor which sets the pole position during instantiation.
OnePole(MY_FLOAT thePole);
//! Class destructor.
~OnePole();
void clear();
void setB0(MY_FLOAT aValue); /* set numerator b0 in b0/(1+a1/z) */
void setNum(MY_FLOAT *values);
void setA1(MY_FLOAT aValue); /* set denominator a1 in b0/(1+a1/z) */
void setDen(MY_FLOAT *values);
void setPole(MY_FLOAT aValue);
void setGain(MY_FLOAT aValue);
//! Clears the internal state of the filter.
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
//! Set the a[1] coefficient value.
void setA1(MY_FLOAT a1);
//! Set the pole position in the z-plane.
/*!
This method sets the pole position along the real-axis of the
z-plane and normalizes the coefficients for a maximum gain of one.
A positive pole value produces a low-pass filter, while a negative
pole value produces a high-pass filter. This method does not
affect the filter \e gain value.
*/
void setPole(MY_FLOAT 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);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT 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);
};
#endif

View File

@@ -1,35 +1,72 @@
/*******************************************/
/* One Zero Filter Class, */
/* by Perry R. Cook, 1995-96 */
/* The parameter gain is an additional */
/* gain parameter applied to the filter */
/* on top of the normalization that takes */
/* place automatically. So the net max */
/* gain through the system equals the */
/* value of gain. sgain is the combina- */
/* tion of gain and the normalization */
/* parameter, so if you set the poleCoeff */
/* to alpha, sgain is always set to */
/* gain / (1.0 - fabs(alpha)). */
/*******************************************/
/***************************************************/
/*! \class OneZero
\brief STK one-zero filter class.
#if !defined(__OneZero_h)
#define __OneZero_h
This protected Filter subclass implements
a one-zero digital filter. A method is
provided for setting the zero position
along the real axis of the z-plane while
maintaining a constant filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__ONEZERO_H)
#define __ONEZERO_H
#include "Filter.h"
class OneZero : public Filter
class OneZero : protected Filter
{
protected:
MY_FLOAT zeroCoeff;
MY_FLOAT sgain;
public:
//! Default constructor creates a first-order low-pass filter.
OneZero();
//! Overloaded constructor which sets the zero position during instantiation.
OneZero(MY_FLOAT theZero);
//! Class destructor.
~OneZero();
void clear();
void setGain(MY_FLOAT aValue);
void setCoeff(MY_FLOAT aValue);
//! Clears the internal state of the filter.
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
//! Set the b[1] coefficient value.
void setB1(MY_FLOAT b1);
//! Set the zero position in the z-plane.
/*!
This method sets the zero position along the real-axis of the
z-plane and normalizes the coefficients for a maximum gain of one.
A positive zero value produces a high-pass filter, while a
negative zero value produces a low-pass filter. This method does
not affect the filter \e gain value.
*/
void setZero(MY_FLOAT 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);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT 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);
};
#endif

View File

@@ -1,42 +1,46 @@
/*******************************************/
/* PRCRev, a simple reverb unit */
/* by Perry Cook, 1996. */
/* Incorporated into the Reverb superclass */
/* by Gary Scavone, 1998. */
/* */
/* This is based on some of the famous */
/* Stanford CCRMA reverbs (NRev, KipRev) */
/* all based on the the Chowning/Moorer/ */
/* Schroeder reverberators, which use */
/* networks of simple allpass and comb */
/* delay filters. */
/*******************************************/
/***************************************************/
/*! \class PRCRev
\brief Perry's simple reverberator class.
#if !defined(__PRCRev_h)
#define __PRCRev_h
This class is based on some of the famous
Stanford/CCRMA reverbs (NRev, KipRev), which
were based on the Chowning/Moorer/Schroeder
reverberators using networks of simple allpass
and comb delay filters. This class implements
two series allpass units and two parallel comb
filters.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__PRCREV_H)
#define __PRCREV_H
#include "Reverb.h"
#include "DLineN.h"
#include "Delay.h"
class PRCRev : public Reverb
{
protected:
DLineN *APdelayLine[2];
DLineN *CdelayLine[2];
MY_FLOAT allPassCoeff;
MY_FLOAT combCoeff[2];
MY_FLOAT lastOutL;
MY_FLOAT lastOutR;
MY_FLOAT effectMix;
public:
// Class constructor taking a T60 decay time argument.
PRCRev(MY_FLOAT T60);
// Class destructor.
~PRCRev();
//! Reset and clear all internal state.
void clear();
void setEffectMix(MY_FLOAT mix);
MY_FLOAT lastOutput();
MY_FLOAT lastOutputL();
MY_FLOAT lastOutputR();
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT input);
protected:
Delay *allpassDelays[2];
Delay *combDelays[2];
MY_FLOAT allpassCoefficient;
MY_FLOAT combCoefficient[2];
};
#endif

View File

@@ -1,21 +1,53 @@
/******************************************/
/* Percussive Flute Subclass */
/* of Algorithm 4 (TX81Z) Subclass of */
/* 4 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/******************************************/
/***************************************************/
/*! \class PercFlut
\brief STK percussive flute FM synthesis instrument.
#if !defined(__PercFlut_h)
#define __PercFlut_h
This class implements algorithm 4 of the TX81Z.
#include "FM4Alg4.h"
\code
Algorithm 4 is : 4->3--\
2-- + -->1-->Out
\endcode
class PercFlut : public FM4Alg4
Control Change Numbers:
- Total Modulator Index = 2
- Modulator Crossfade = 4
- LFO Speed = 11
- LFO Depth = 1
- ADSR 2 & 4 Target = 128
The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha. If you are of the
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__PERCFLUT_H)
#define __PERCFLUT_H
#include "FM.h"
class PercFlut : public FM
{
public:
//! Class constructor.
PercFlut();
virtual void setFreq(MY_FLOAT frequency);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
//! Class destructor.
~PercFlut();
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
};
#endif

56
include/PitShift.h Normal file
View File

@@ -0,0 +1,56 @@
/***************************************************/
/*! \class PitShift
\brief STK simple pitch shifter effect class.
This class implements a simple pitch shifter
using delay lines.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__PITSHIFT_H)
#define __PITSHIFT_H
#include "Stk.h"
#include "DelayL.h"
class PitShift : public Stk
{
public:
//! Class constructor.
PitShift();
//! Class destructor.
~PitShift();
//! Reset and clear all internal state.
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;
//! Compute one output sample.
MY_FLOAT tick(MY_FLOAT 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);
protected:
Delay *delayLine[2];
MY_FLOAT lastOutput;
MY_FLOAT delay[2];
MY_FLOAT env[2];
MY_FLOAT effectMix;
MY_FLOAT rate;
};
#endif

84
include/PluckTwo.h Normal file
View File

@@ -0,0 +1,84 @@
/***************************************************/
/*! \class PluckTwo
\brief STK enhanced plucked string model class.
This class implements an enhanced two-string,
plucked physical model, a la Jaffe-Smith,
Smith, and others.
PluckTwo is an abstract class, with no excitation
specified. Therefore, it can't be directly
instantiated.
This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__PLUCKTWO_H)
#define __PLUCKTWO_H
#include "Instrmnt.h"
#include "DelayL.h"
#include "DelayA.h"
#include "OneZero.h"
class PluckTwo : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
PluckTwo(MY_FLOAT lowestFrequency);
//! Class destructor.
virtual ~PluckTwo();
//! Reset and clear all internal state.
void clear();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
//! Detune the two strings by the given factor. A value of 1.0 produces unison strings.
void setDetune(MY_FLOAT detune);
//! Efficient combined setting of frequency and detuning.
void setFreqAndDetune(MY_FLOAT frequency, MY_FLOAT detune);
//! Set the pluck or "excitation" position along the string (0.0 - 1.0).
void setPluckPosition(MY_FLOAT position);
//! Set the base loop gain.
/*!
The actual loop gain is set according to the frequency.
Because of high-frequency loop filter roll-off, higher
frequency settings have greater loop gains.
*/
void setBaseLoopGain(MY_FLOAT aGain);
//! Stop a note with the given amplitude (speed of decay).
virtual void noteOff(MY_FLOAT amplitude);
//! Virtual (abstract) tick function is implemented by subclasses.
virtual MY_FLOAT 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;
};
#endif

View File

@@ -1,39 +1,66 @@
/******************************************/
/* Karplus-Strong plucked string model */
/* by Perry Cook, 1995-96 */
/* */
/* There exist at least two patents, */
/* assigned to Stanford, bearing the */
/* names of Karplus and/or Strong. */
/******************************************/
/***************************************************/
/*! \class Plucked
\brief STK plucked string model class.
#if !defined(__Plucked_h)
#define __Plucked_h
This class implements a simple plucked string
physical model based on the Karplus-Strong
algorithm.
This is a digital waveguide model, making its
use possibly subject to patents held by
Stanford University, Yamaha, and others.
There exist at least two patents, assigned to
Stanford, bearing the names of Karplus and/or
Strong.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__PLUCKED_H)
#define __PLUCKED_H
#include "Instrmnt.h"
#include "DLineA.h"
#include "DelayA.h"
#include "OneZero.h"
#include "OnePole.h"
#include "Noise.h"
class Plucked : public Instrmnt
{
public:
//! Class constructor, taking the lowest desired playing frequency.
Plucked(MY_FLOAT lowestFrequency);
//! Class destructor.
~Plucked();
//! Reset and clear all internal state.
void clear();
//! Set instrument parameters for a particular frequency.
virtual void setFrequency(MY_FLOAT frequency);
//! Pluck the string with the given amplitude using the current frequency.
void pluck(MY_FLOAT amplitude);
//! Start a note with the given frequency and amplitude.
virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
virtual void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
virtual MY_FLOAT tick();
protected:
DLineA *delayLine;
OneZero *loopFilt;
OnePole *pickFilt;
DelayA *delayLine;
OneZero *loopFilter;
OnePole *pickFilter;
Noise *noise;
long length;
MY_FLOAT loopGain;
public:
Plucked(MY_FLOAT lowestFreq);
~Plucked();
void clear();
virtual void setFreq(MY_FLOAT frequency);
void pluck(MY_FLOAT amplitude);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
virtual void noteOff(MY_FLOAT amp);
virtual MY_FLOAT tick();
};
#endif

View File

@@ -1,46 +0,0 @@
/******************************************/
/* Enhanced (Jaffe-Smith, Smith, others) */
/* Karplus-Strong plucked model */
/* by Perry Cook, 1995-96 */
/* This is the super-class, with no */
/* excitation specified. So this one by */
/* itself doesn't make any sound. */
/******************************************/
#if !defined(__Plucked2_h)
#define __Plucked2_h
#include "Instrmnt.h"
#include "DLineL.h"
#include "DLineA.h"
#include "OneZero.h"
class Plucked2 : public Instrmnt
{
protected:
DLineA *delayLine;
DLineA *delayLine2;
DLineL *combDelay;
OneZero *filter;
OneZero *filter2;
long length;
MY_FLOAT loopGain;
MY_FLOAT baseLoopGain;
MY_FLOAT lastFreq;
MY_FLOAT lastLength;
MY_FLOAT detuning;
MY_FLOAT pluckAmp;
MY_FLOAT pluckPos;
public:
Plucked2(MY_FLOAT lowestFreq);
virtual ~Plucked2();
void clear();
virtual void setFreq(MY_FLOAT frequency);
void setDetune(MY_FLOAT detune);
void setFreqAndDetune(MY_FLOAT frequency, MY_FLOAT detune);
void setPluckPos(MY_FLOAT position);
void setBaseLoopGain(MY_FLOAT aGain);
virtual void noteOff(MY_FLOAT amp);
};
#endif

View File

@@ -1,32 +1,79 @@
/*******************************************/
/* PoleZero (1-pole, 1-zero) Filter Class */
/* by Gary P. Scavone, 1999 */
/* */
/* See books on filters to understand */
/* more about how this works. Nothing */
/* out of the ordinary in this version. */
/*******************************************/
/***************************************************/
/*! \class PoleZero
\brief STK one-pole, one-zero filter class.
#if !defined(__PoleZero_h)
#define __PoleZero_h
This protected Filter subclass implements
a one-pole, one-zero digital filter. A
method is provided for creating an allpass
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.
*/
/***************************************************/
#if !defined(__POLEZERO_H)
#define __POLEZERO_H
#include "Filter.h"
class PoleZero : public Filter
class PoleZero : protected Filter
{
protected:
MY_FLOAT a1Coeff;
MY_FLOAT b0Coeff;
MY_FLOAT b1Coeff;
public:
//! Default constructor creates a first-order pass-through filter.
PoleZero();
//! Class destructor.
~PoleZero();
void clear();
void setA1(MY_FLOAT coeff);
void setB0(MY_FLOAT coeff);
void setB1(MY_FLOAT coeff);
void setGain(MY_FLOAT aValue);
//! Clears the internal states of the filter.
void clear(void);
//! Set the b[0] coefficient value.
void setB0(MY_FLOAT b0);
//! Set the b[1] coefficient value.
void setB1(MY_FLOAT b1);
//! Set the a[1] coefficient value.
void setA1(MY_FLOAT a1);
//! Set the filter for allpass behavior using \e coefficient.
/*!
This method uses \e coefficient to create an allpass 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);
//! Create a DC blocking filter with the given pole position in the z-plane.
/*!
This method sets the given pole position, together with a zero
at z=1, to create a DC blocking filter. \e thePole should be
close to one to minimize low-frequency attenuation.
*/
void setBlockZero(MY_FLOAT 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);
//! Return the current filter gain.
MY_FLOAT getGain(void) const;
//! Return the last computed output value.
MY_FLOAT lastOut(void) const;
//! Input one sample to the filter and return one output.
MY_FLOAT tick(MY_FLOAT 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);
};
#endif

View File

@@ -1,28 +0,0 @@
/*******************************************/
/* RawWvIn Input Class, */
/* by Gary P. Scavone, 2000 */
/* */
/* This object inherits from WvIn and is */
/* used to open raw 16-bit data (signed */
/* integer) files for playback. */
/* */
/* STK RawWave files are assumed to be */
/* big-endian. */
/*******************************************/
#if !defined(__RawWvIn_h)
#define __RawWvIn_h
#include "Object.h"
#include "WvIn.h"
class RawWvIn : public WvIn
{
public:
RawWvIn(char *fileName, const char *mode);
~RawWvIn();
protected:
void getData(long index);
};
#endif

View File

@@ -1,29 +0,0 @@
/*******************************************/
/* RawWvOut Output Class */
/* by Gary P. Scavone, 1999 */
/* */
/* This object spits samples into a raw */
/* 16-bit data (signed integer) file. */
/* */
/* STK RawWave files are assumed to be */
/* monaural and big-endian. */
/*******************************************/
#if !defined(__RawWvOut_h)
#define __RawWvOut_h
#include "Object.h"
#include "WvOut.h"
class RawWvOut : public WvOut
{
protected:
FILE *fd;
public:
RawWvOut(char *fileName, int chans = 1);
~RawWvOut();
void tick(MY_FLOAT sample);
void mtick(MY_MULTI samples);
};
#endif // defined(__RawWvOut_h)

View File

@@ -1,30 +1,70 @@
/**********************************************/
/* One break point linear reed table object */
/* by Perry R. Cook, 1995-96 */
/* Consult McIntyre, Schumacher, & Woodhouse */
/* Smith, Hirschman, Cook, Scavone, */
/* more for information. */
/**********************************************/
/***************************************************/
/*! \class ReedTabl
\brief STK reed table class.
#if !defined(__ReedTabl_h)
#define __ReedTabl_h
This class implements a simple one breakpoint,
non-linear reed function, as described by
Smith (1986). This function is based on a
memoryless non-linear spring model of the reed
(the reed mass is ignored) which saturates when
the reed collides with the mouthpiece facing.
#include "Object.h"
See McIntyre, Schumacher, & Woodhouse (1983),
Smith (1986), Hirschman, Cook, Scavone, and
others for more information.
class ReedTabl : public Object
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__REEDTABL_H)
#define __REEDTABL_H
#include "Stk.h"
class ReedTabl : public Stk
{
public:
//! Default constructor.
ReedTabl();
//! Class destructor.
~ReedTabl();
//! Set the table offset value.
/*!
The table offset roughly corresponds to the size
of the initial reed tip opening (a greater offset
represents a smaller opening).
*/
void setOffset(MY_FLOAT aValue);
//! Set the table slope value.
/*!
The table slope roughly corresponds to the reed
stiffness (a greater slope represents a harder
reed).
*/
void setSlope(MY_FLOAT aValue);
//! Return the last output value.
MY_FLOAT lastOut() const;
//! Return the function value for \e input.
/*!
The function input represents the differential
pressure across the reeds.
*/
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 offSet;
MY_FLOAT slope;
MY_FLOAT lastOutput;
public:
ReedTabl();
~ReedTabl();
void setOffset(MY_FLOAT aValue);
void setSlope(MY_FLOAT aValue);
MY_FLOAT lookup(MY_FLOAT deltaP);
MY_FLOAT tick(MY_FLOAT deltaP);
MY_FLOAT lastOut();
};
#endif

78
include/Resonate.h Normal file
View File

@@ -0,0 +1,78 @@
/***************************************************/
/*! \class Resonate
\brief STK noise driven formant filter.
This instrument contains a noise source, which
excites a biquad resonance filter, with volume
controlled by an ADSR.
Control Change Numbers:
- Resonance Frequency (0-Nyquist) = 2
- Pole Radii = 4
- Notch Frequency (0-Nyquist) = 11
- Zero Radii = 1
- Envelope Gain = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__RESONATE_H)
#define __RESONATE_H
#include "Instrmnt.h"
#include "ADSR.h"
#include "BiQuad.h"
#include "Noise.h"
class Resonate : public Instrmnt
{
public:
//! Class constructor.
Resonate();
//! Class destructor.
~Resonate();
//! Reset and clear all internal state.
void clear();
//! Set the filter for a resonance at the given frequency (Hz) and radius.
void setResonance(MY_FLOAT frequency, MY_FLOAT radius);
//! Set the filter for a notch at the given frequency (Hz) and radius.
void setNotch(MY_FLOAT frequency, MY_FLOAT radius);
//! Set the filter zero coefficients for contant resonance gain.
void setEqualGainZeroes();
//! Initiate the envelope with a key-on event.
void keyOn();
//! Signal a key-off event to the envelope.
void keyOff();
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Stop a note with the given amplitude (speed of decay).
void noteOff(MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
virtual void controlChange(int number, MY_FLOAT value);
protected:
ADSR *adsr;
BiQuad *filter;
Noise *noise;
MY_FLOAT poleFrequency;
MY_FLOAT poleRadius;
MY_FLOAT zeroFrequency;
MY_FLOAT zeroRadius;
};
#endif

View File

@@ -1,32 +1,58 @@
/********************************************/
/* Reverb Abstract Class, */
/* by Tim Stilson, 1998 */
/* */
/* Integrated into STK by Gary Scavone */
/* with T60 argument. */
/********************************************/
/***************************************************/
/*! \class Reverb
\brief STK abstract reverberator parent class.
#include "Object.h"
This class provides common functionality for
STK reverberator subclasses.
#if !defined(__Reverb_h)
#define __Reverb_h
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
class Reverb : public Object
#include "Stk.h"
#if !defined(__REVERB_H)
#define __REVERB_H
class Reverb : public Stk
{
public:
//! Class constructor.
Reverb();
//! Class destructor.
virtual ~Reverb();
virtual MY_FLOAT tick(MY_FLOAT sample);
virtual void setEffectMix(MY_FLOAT mix);
int isprime(int val);
//! 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)
#endif // defined(__REVERB_H)
/* CLM also had JLRev and JLLRev variations on the JCRev: JLRev had
longer combs and alpasses, JLLRev further placed the comb coefs
closer to 1.0. In my modified testMono.cpp, I allowed for a
"JLRev" argument, though JLRev.cpp/.h doesn't exist, testMono
simply uses a JCRev but passes a longer base comb length. I also
have comments in JCRev.cpp for the JLLRev coefs.
*/

View File

@@ -1,22 +1,57 @@
/******************************************/
/* Fender Rhodes Electric Piano Subclass */
/* of Algorithm 5 (TX81Z) Subclass of */
/* 4 Operator FM Synth */
/* by Perry R. Cook, 1995-96 */
/******************************************/
/***************************************************/
/*! \class Rhodey
\brief STK Fender Rhodes electric piano FM
synthesis instrument.
#if !defined(__Rhodey_h)
#define __Rhodey_h
This class implements two simple FM Pairs
summed together, also referred to as algorithm
5 of the TX81Z.
#include "FM4Alg5.h"
\code
Algorithm 5 is : 4->3--\
+ --> Out
2->1--/
\endcode
class Rhodey : public FM4Alg5
Control Change Numbers:
- Modulator Index One = 2
- Crossfade of Outputs = 4
- LFO Speed = 11
- LFO Depth = 1
- ADSR 2 & 4 Target = 128
The basic Chowning/Stanford FM patent expired
in 1995, but there exist follow-on patents,
mostly assigned to Yamaha. If you are of the
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__RHODEY_H)
#define __RHODEY_H
#include "FM.h"
class Rhodey : public FM
{
public:
//! Class constructor.
Rhodey();
//! Class destructor.
~Rhodey();
virtual void setFreq(MY_FLOAT frequency);
virtual void noteOn(MY_FLOAT freq, MY_FLOAT amp);
//! Set instrument parameters for a particular frequency.
void setFrequency(MY_FLOAT frequency);
//! Start a note with the given frequency and amplitude.
void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude);
//! Compute one output sample.
MY_FLOAT tick();
};
#endif

View File

@@ -1,155 +1,434 @@
/******************************************/
/*
RtAudio.cpp
Realtime Sound I/O Object for STK
by Gary P. Scavone, 1998-2000.
The sound output sections of this object
were originally based in part on code by
Doug Scott (SGI), Tim Stilson (Linux),
Bill Putnam (Win Wav), and R. Marsanyi
(DirectSound). The latest DirectSound
code was re-written by Dave Chisholm at
CCRMA.
This object provides a standard API
across all platforms for STK realtime
audio input/output. Multi-channel
support is supported when provided by
the soundcard.
Only 16-bit integer input/output
routines are written for the moment
though it would be simple to overload
the methods for other data types.
RtAudio - realtime sound I/O C++ class
by Gary P. Scavone, 2001-2002.
*/
/******************************************/
#if !defined(__RtAudio_h)
#define __RtAudio_h
#if !defined(__RTAUDIO_H)
#define __RTAUDIO_H
#include "Object.h"
#include "StkError.h"
#include <map>
#if defined(__OS_IRIX_)
#include <dmedia/audio.h>
#if defined(__LINUX_ALSA__)
#include <alsa/asoundlib.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
#elif defined(__ALSA_API_)
#include <sys/ioctl.h>
#include <sys/asoundlib.h>
#define THREAD_TYPE
typedef snd_pcm_t *AUDIO_HANDLE;
typedef int DEVICE_ID;
typedef pthread_t THREAD_HANDLE;
typedef pthread_mutex_t MUTEX;
#elif defined(__OSS_API_)
#include <sys/ioctl.h>
#elif defined(__LINUX_OSS__)
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/soundcard.h>
#include <errno.h>
#elif defined(__OS_Win_)
#define THREAD_TYPE
typedef int AUDIO_HANDLE;
typedef int DEVICE_ID;
typedef pthread_t THREAD_HANDLE;
typedef pthread_mutex_t MUTEX;
#elif defined(__WINDOWS_DS__)
#include <windows.h>
#include <dsound.h>
#include <winsock.h>
#include "mmsystem.h"
#include <process.h>
// this is how often we check for new audio input (milliseconds)
#define TIMER_PERIOD 20
// the resolution which we tell windows we are willing to tolerate (milliseconds)
#define TIMER_RESOLUTION 5
// in seconds, doesn't have a real effect on latency
#define DS_CAPTURE_BUFFER_SIZE 2
// this controls the inherent latency of the output ... more fragments produce
// a more stable, though slower, response
#define NUM_FRAGMENTS 10
#define MAX_DEVICES 10
// The following struct is used to hold the extra variables
// specific to the DirectSound implementation.
typedef struct {
void * object;
void * buffer;
UINT bufferPointer;
} AUDIO_HANDLE;
typedef struct DeviceInfo {
LPGUID guid;
char* description;
char* moduleName;
} DeviceInfo;
#define THREAD_TYPE __stdcall
typedef LPGUID DEVICE_ID;
typedef unsigned long THREAD_HANDLE;
typedef CRITICAL_SECTION MUTEX;
#elif defined(__IRIX_AL__)
#include <dmedia/audio.h>
#include <pthread.h>
#include <unistd.h>
#define THREAD_TYPE
typedef ALport AUDIO_HANDLE;
typedef int DEVICE_ID;
typedef pthread_t THREAD_HANDLE;
typedef pthread_mutex_t MUTEX;
#endif
class RtAudio : public Object
// *************************************************** //
//
// RtError class declaration.
//
// *************************************************** //
class RtError
{
public:
enum TYPE {
WARNING,
DEBUG_WARNING,
UNSPECIFIED,
NO_DEVICES_FOUND,
INVALID_DEVICE,
INVALID_STREAM,
MEMORY_ERROR,
INVALID_PARAMETER,
DRIVER_ERROR,
SYSTEM_ERROR,
THREAD_ERROR
};
protected:
#if (defined(__STK_REALTIME_) && defined(__OS_IRIX_))
int stk_chans;
ALport audio_port_in;
ALport audio_port_out;
#elif (defined(__STK_REALTIME_) && defined(__OSS_API_))
int audio_fd;
#elif (defined(__STK_REALTIME_) && defined(__ALSA_API_))
snd_pcm_t *ohandle;
snd_pcm_t *ihandle;
int stk_chans; // the number of channels we want to use
int dev_ichans; // the number of input channels the device needs
int dev_ochans; // the number of output channels the device needs
int ifragsize;
int ofragsize;
int bytes_per_sample;
unsigned int direction;
unsigned char *outbuf;
unsigned char *inbuf;
#elif (defined(__STK_REALTIME_) && defined(__OS_Win_) )
DeviceInfo devices[MAX_DEVICES];
int numDevices;
char errormsg[256];
long inputBufferSize;
BYTE *inputBuffer;
UINT nextRecordRead, nextRecordWrite;
MY_FLOAT sampleRate;
//these are the variable relating to direct sound output
LPDIRECTSOUND directSoundObject;
LPDIRECTSOUNDBUFFER directSoundBuffer;
DWORD directSoundBufferSize;
UINT nextWritePos;
//direct sound input
LPDIRECTSOUNDCAPTURE directSoundCaptureObject;
LPDIRECTSOUNDCAPTUREBUFFER directSoundCaptureBuffer;
DWORD directSoundCaptureBufferSize;
// our periodic function will set this flag if something goes wrong
bool internalError;
bool playing, recording;
UINT timerID;
static void CALLBACK PeriodicCallbackFn(UINT uID, UINT uMsg, DWORD dwUser,
DWORD dw1, DWORD dw2);
static bool CALLBACK SoundDeviceEnumCallback(LPGUID lpguid,
LPCSTR lpcstrDescription,
LPCSTR lpcstrModule,
LPVOID lpContext);
void addDevice(LPGUID guid, char* description, char* moduleName);
void getInputSamples();
static char* getErrorMessage(int code);
#endif
char error_message[256];
TYPE type;
public:
RtAudio(int channels, MY_FLOAT srate, const char *mode, int device = -1);
~RtAudio();
int playBuffer(INT16 *buf, int bufsize);
int recordBuffer(INT16 *buf, int bufsize);
//! The constructor.
RtError(const char *p, TYPE tipe = RtError::UNSPECIFIED);
#if (defined(__STK_REALTIME_) && defined(__OS_Win_) )
// Sets the pointer to its own internal buffer, returning
// amount of data available ... slightly more efficient.
int recordBuffer(INT16**);
void stopPlay();
void startPlay();
void stopRecord();
void startRecord();
#endif
//! The destructor.
virtual ~RtError(void);
//! Prints "thrown" error message to stdout.
virtual void printMessage(void);
//! Returns the "thrown" error message TYPE.
virtual const TYPE& getType(void) { return type; }
//! Returns the "thrown" error message string.
virtual const char *getMessage(void) { return error_message; }
};
// *************************************************** //
//
// RtAudio class declaration.
//
// *************************************************** //
class RtAudio
{
public:
// Support for signed integers and floats. Audio data fed to/from
// the tickStream() routine is assumed to ALWAYS be in host
// byte order. The internal routines will automatically take care of
// any necessary byte-swapping between the host format and the
// soundcard. Thus, endian-ness is not a concern in the following
// format definitions.
typedef unsigned long RTAUDIO_FORMAT;
static const RTAUDIO_FORMAT RTAUDIO_SINT8;
static const RTAUDIO_FORMAT RTAUDIO_SINT16;
static const RTAUDIO_FORMAT RTAUDIO_SINT24; /*!< Upper 3 bytes of 32-bit integer. */
static const RTAUDIO_FORMAT RTAUDIO_SINT32;
static const RTAUDIO_FORMAT RTAUDIO_FLOAT32; /*!< Normalized between plus/minus 1.0. */
static const RTAUDIO_FORMAT RTAUDIO_FLOAT64; /*!< Normalized between plus/minus 1.0. */
//static const int MAX_SAMPLE_RATES = 14;
enum { MAX_SAMPLE_RATES = 14 };
typedef int (*RTAUDIO_CALLBACK)(char *buffer, int bufferSize, void *userData);
typedef struct {
char name[128];
DEVICE_ID id[2]; /*!< No value reported by getDeviceInfo(). */
bool probed; /*!< true if the device capabilities were successfully probed. */
int maxOutputChannels;
int maxInputChannels;
int maxDuplexChannels;
int minOutputChannels;
int minInputChannels;
int minDuplexChannels;
bool hasDuplexSupport; /*!< true if device supports duplex mode. */
int nSampleRates; /*!< Number of discrete rates or -1 if range supported. */
int sampleRates[MAX_SAMPLE_RATES]; /*!< Supported rates or (min, max) if range. */
RTAUDIO_FORMAT nativeFormats; /*!< Bit mask of supported data formats. */
} RTAUDIO_DEVICE;
//! The default constructor.
/*!
Probes the system to make sure at least one audio
input/output device is available and determines
the api-specific identifier for each device found.
An RtError error can be thrown if no devices are
found or if a memory allocation error occurs.
*/
RtAudio();
//! A constructor which can be used to open a stream during instantiation.
/*!
The specified output and/or input device identifiers correspond
to those enumerated via the getDeviceInfo() method. If device =
0, the default or first available devices meeting the given
parameters is selected. If an output or input channel value is
zero, the corresponding device value is ignored. When a stream is
successfully opened, its identifier is returned via the "streamId"
pointer. An RtError can be thrown if no devices are found
for the given parameters, if a memory allocation error occurs, or
if a driver error occurs. \sa openStream()
*/
RtAudio(int *streamId,
int outputDevice, int outputChannels,
int inputDevice, int inputChannels,
RTAUDIO_FORMAT format, int sampleRate,
int *bufferSize, int numberOfBuffers);
//! The destructor.
/*!
Stops and closes any open streams and devices and deallocates
buffer and structure memory.
*/
~RtAudio();
//! A public method for opening a stream with the specified parameters.
/*!
If successful, the opened stream ID is returned. Otherwise, an
RtError is thrown.
\param outputDevice: If equal to 0, the default or first device
found meeting the given parameters is opened. Otherwise, the
device number should correspond to one of those enumerated via
the getDeviceInfo() method.
\param outputChannels: The desired number of output channels. If
equal to zero, the outputDevice identifier is ignored.
\param inputDevice: If equal to 0, the default or first device
found meeting the given parameters is opened. Otherwise, the
device number should correspond to one of those enumerated via
the getDeviceInfo() method.
\param inputChannels: The desired number of input channels. If
equal to zero, the inputDevice identifier is ignored.
\param format: An RTAUDIO_FORMAT specifying the desired sample data format.
\param sampleRate: The desired sample rate (sample frames per second).
\param *bufferSize: A pointer value indicating the desired internal buffer
size in sample frames. The actual value used by the device is
returned via the same pointer. A value of zero can be specified,
in which case the lowest allowable value is determined.
\param numberOfBuffers: A value which can be used to help control device
latency. More buffers typically result in more robust performance,
though at a cost of greater latency. A value of zero can be
specified, in which case the lowest allowable value is used.
*/
int openStream(int outputDevice, int outputChannels,
int inputDevice, int inputChannels,
RTAUDIO_FORMAT 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 specific,
previously opened stream for non-blocking stream functionality. A
separate process is initiated, though the user function is called
only when the stream is "running" (between calls to the
startStream() and stopStream() methods, respectively). The
callback process remains active for the duration of the stream and
is automatically shutdown when the stream is closed (via the
closeStream() method or by object destruction). The callback
process can also be shutdown and the user function de-referenced
through an explicit call to the cancelStreamCallback() method.
Note that a single stream can use only blocking or callback
functionality at the same time, though it is possible to alternate
modes on the same stream through the use of the
setStreamCallback() and cancelStreamCallback() methods (the
blocking tickStream() method can be used before a callback is set
and/or after a callback is cancelled). An RtError will be
thrown for an invalid device argument.
*/
void setStreamCallback(int streamId, RTAUDIO_CALLBACK callback, void *userData);
//! A public method which cancels a callback process and function for a given stream.
/*!
This method shuts down a callback process and de-references the
user function for a specific stream. Callback functionality can
subsequently be restarted on the stream via the
setStreamCallback() method. An RtError will be thrown for an
invalid device argument.
*/
void cancelStreamCallback(int streamId);
//! A public method which returns the number of audio devices found.
int getDeviceCount(void);
//! Fill a user-supplied RTAUDIO_DEVICE structure for a specified device.
/*!
Any device between 0 and getDeviceCount()-1 is valid. If a
device is busy or otherwise unavailable, the structure member
"probed" has a value of "false". The system default input and
output devices are referenced by device identifier = 0. On
systems which allow dynamic default device settings, the default
devices are not identified by name (specific device enumerations
are assigned device identifiers > 0). An RtError will be
thrown for an invalid device argument.
*/
void getDeviceInfo(int device, RTAUDIO_DEVICE *info);
//! A public method which returns a pointer to the buffer for an open stream.
/*!
The user should fill and/or read the buffer data in interleaved format
and then call the tickStream() method. An RtError will be
thrown for an invalid stream identifier.
*/
char * const getStreamBuffer(int streamId);
//! Public method used to trigger processing of input/output data for a stream.
/*!
This method blocks until all buffer data is read/written. An
RtError will be thrown for an invalid stream identifier or if
a driver error occurs.
*/
void tickStream(int streamId);
//! Public method which closes a stream and frees any associated buffers.
/*!
If an invalid stream identifier is specified, this method
issues a warning and returns (an RtError is not thrown).
*/
void closeStream(int streamId);
//! Public method which starts a stream.
/*!
An RtError will be thrown for an invalid stream identifier
or if a driver error occurs.
*/
void startStream(int streamId);
//! Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.
/*!
An RtError will be thrown for an invalid stream identifier
or if a driver error occurs.
*/
void stopStream(int streamId);
//! Stop a stream, discarding any samples remaining in the input/output queue.
/*!
An RtError will be thrown for an invalid stream identifier
or if a driver error occurs.
*/
void abortStream(int streamId);
//! Queries a stream to determine whether a call to the tickStream() method will block.
/*!
A return value of 0 indicates that the stream will NOT block. A positive
return value indicates the number of sample frames that cannot yet be
processed without blocking.
*/
int streamWillBlock(int streamId);
protected:
private:
static const unsigned int SAMPLE_RATES[MAX_SAMPLE_RATES];
enum { FAILURE, SUCCESS };
enum STREAM_MODE {
PLAYBACK,
RECORD,
DUPLEX,
UNINITIALIZED = -75
};
enum STREAM_STATE {
STREAM_STOPPED,
STREAM_RUNNING
};
typedef struct {
int device[2]; // Playback and record, respectively.
STREAM_MODE mode; // PLAYBACK, RECORD, or DUPLEX.
AUDIO_HANDLE handle[2]; // Playback and record handles, respectively.
STREAM_STATE state; // STOPPED or RUNNING
char *userBuffer;
char *deviceBuffer;
bool doConvertBuffer[2]; // Playback and record, respectively.
bool deInterleave[2]; // Playback and record, respectively.
bool doByteSwap[2]; // Playback and record, respectively.
int sampleRate;
int bufferSize;
int nBuffers;
int nUserChannels[2]; // Playback and record, respectively.
int nDeviceChannels[2]; // Playback and record channels, respectively.
RTAUDIO_FORMAT userFormat;
RTAUDIO_FORMAT deviceFormat[2]; // Playback and record, respectively.
bool usingCallback;
THREAD_HANDLE thread;
MUTEX mutex;
RTAUDIO_CALLBACK callback;
void *userData;
} RTAUDIO_STREAM;
typedef signed short INT16;
typedef signed int INT32;
typedef float FLOAT32;
typedef double FLOAT64;
char message[256];
int nDevices;
RTAUDIO_DEVICE *devices;
std::map<int, void *> streams;
//! Private error method to allow global control over error handling.
void error(RtError::TYPE type);
/*!
Private method to count the system audio devices, allocate the
RTAUDIO_DEVICE structures, and probe the device capabilities.
*/
void initialize(void);
//! Private method to clear an RTAUDIO_DEVICE structure.
void clearDeviceInfo(RTAUDIO_DEVICE *info);
/*!
Private method which attempts to fill an RTAUDIO_DEVICE
structure for a given device. If an error is encountered during
the probe, a "warning" message is reported and the value of
"probed" remains false (no exception is thrown). A successful
probe is indicated by probed = true.
*/
void probeDeviceInfo(RTAUDIO_DEVICE *info);
/*!
Private method which attempts to open a device with the given parameters.
If an error is encountered during the probe, a "warning" message is
reported and FAILURE is returned (no exception is thrown). A
successful probe is indicated by a return value of SUCCESS.
*/
bool probeDeviceOpen(int device, RTAUDIO_STREAM *stream,
STREAM_MODE mode, int channels,
int sampleRate, RTAUDIO_FORMAT format,
int *bufferSize, int numberOfBuffers);
/*!
Private common method used to check validity of a user-passed
stream ID. When the ID is valid, this method returns a pointer to
an RTAUDIO_STREAM structure (in the form of a void pointer).
Otherwise, an "invalid identifier" exception is thrown.
*/
void *verifyStream(int streamId);
/*!
Private method used to perform format, channel number, and/or interleaving
conversions between the user and device buffers.
*/
void convertStreamBuffer(RTAUDIO_STREAM *stream, STREAM_MODE mode);
//! Private method used to perform byte-swapping on buffers.
void byteSwapBuffer(char *buffer, int samples, RTAUDIO_FORMAT format);
//! Private method which returns the number of bytes for a given format.
int formatBytes(RTAUDIO_FORMAT format);
};
// Uncomment the following definition to have extra information spewed to stderr.
//#define RTAUDIO_DEBUG
#endif

Some files were not shown because too many files have changed in this diff Show More