| 1 |
/***************************************************/ |
| 2 |
/*! \class Saxofony |
| 3 |
\brief STK faux conical bore reed instrument class. |
| 4 |
|
| 5 |
This class implements a "hybrid" digital |
| 6 |
waveguide instrument that can generate a |
| 7 |
variety of wind-like sounds. It has also been |
| 8 |
referred to as the "blowed string" model. The |
| 9 |
waveguide section is essentially that of a |
| 10 |
string, with one rigid and one lossy |
| 11 |
termination. The non-linear function is a |
| 12 |
reed table. The string can be "blown" at any |
| 13 |
point between the terminations, though just as |
| 14 |
with strings, it is impossible to excite the |
| 15 |
system at either end. If the excitation is |
| 16 |
placed at the string mid-point, the sound is |
| 17 |
that of a clarinet. At points closer to the |
| 18 |
"bridge", the sound is closer to that of a |
| 19 |
saxophone. See Scavone (2002) for more details. |
| 20 |
|
| 21 |
This is a digital waveguide model, making its |
| 22 |
use possibly subject to patents held by Stanford |
| 23 |
University, Yamaha, and others. |
| 24 |
|
| 25 |
Control Change Numbers: |
| 26 |
- Reed Stiffness = 2 |
| 27 |
- Reed Aperture = 26 |
| 28 |
- Noise Gain = 4 |
| 29 |
- Blow Position = 11 |
| 30 |
- Vibrato Frequency = 29 |
| 31 |
- Vibrato Gain = 1 |
| 32 |
- Breath Pressure = 128 |
| 33 |
|
| 34 |
by Perry R. Cook and Gary P. Scavone, 1995 - 2005. |
| 35 |
*/ |
| 36 |
/***************************************************/ |
| 37 |
|
| 38 |
#ifndef STK_SAXOFONY_H |
| 39 |
#define STK_SAXOFONY_H |
| 40 |
|
| 41 |
#include "Instrmnt.h" |
| 42 |
#include "DelayL.h" |
| 43 |
#include "ReedTable.h" |
| 44 |
#include "OneZero.h" |
| 45 |
#include "Envelope.h" |
| 46 |
#include "Noise.h" |
| 47 |
#include "SineWave.h" |
| 48 |
|
| 49 |
namespace Nyq |
| 50 |
{ |
| 51 |
|
| 52 |
class Saxofony : public Instrmnt |
| 53 |
{ |
| 54 |
public: |
| 55 |
//! Class constructor, taking the lowest desired playing frequency. |
| 56 |
/*! |
| 57 |
An StkError will be thrown if the rawwave path is incorrectly set. |
| 58 |
*/ |
| 59 |
Saxofony(StkFloat lowestFrequency); |
| 60 |
|
| 61 |
//! Class destructor. |
| 62 |
~Saxofony(); |
| 63 |
|
| 64 |
//! Reset and clear all internal state. |
| 65 |
void clear(); |
| 66 |
|
| 67 |
//! Set instrument parameters for a particular frequency. |
| 68 |
void setFrequency(StkFloat frequency); |
| 69 |
|
| 70 |
//! Set the "blowing" position between the air column terminations (0.0 - 1.0). |
| 71 |
void setBlowPosition(StkFloat aPosition); |
| 72 |
|
| 73 |
//! Apply breath pressure to instrument with given amplitude and rate of increase. |
| 74 |
void startBlowing(StkFloat amplitude, StkFloat rate); |
| 75 |
|
| 76 |
//! Decrease breath pressure with given rate of decrease. |
| 77 |
void stopBlowing(StkFloat rate); |
| 78 |
|
| 79 |
//! Start a note with the given frequency and amplitude. |
| 80 |
void noteOn(StkFloat frequency, StkFloat amplitude); |
| 81 |
|
| 82 |
//! Stop a note with the given amplitude (speed of decay). |
| 83 |
void noteOff(StkFloat amplitude); |
| 84 |
|
| 85 |
//! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 86 |
void controlChange(int number, StkFloat value); |
| 87 |
|
| 88 |
protected: |
| 89 |
|
| 90 |
StkFloat computeSample( void ); |
| 91 |
|
| 92 |
DelayL delays_[2]; |
| 93 |
ReedTable reedTable_; |
| 94 |
OneZero filter_; |
| 95 |
Envelope envelope_; |
| 96 |
Noise noise_; |
| 97 |
SineWave vibrato_; |
| 98 |
unsigned long length_; |
| 99 |
StkFloat outputGain_; |
| 100 |
StkFloat noiseGain_; |
| 101 |
StkFloat vibratoGain_; |
| 102 |
StkFloat position_; |
| 103 |
|
| 104 |
}; |
| 105 |
|
| 106 |
} // namespace Nyq |
| 107 |
|
| 108 |
#endif |