The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

Whistle.h
1#ifndef STK_WHISTLE_H
2#define STK_WHISTLE_H
3
4#include "Instrmnt.h"
5#include "Sphere.h"
6#include "Vector3D.h"
7#include "Noise.h"
8#include "SineWave.h"
9#include "OnePole.h"
10#include "Envelope.h"
11
12namespace stk {
13
14/***************************************************/
30/***************************************************/
31
32 class Whistle : public Instrmnt
33{
34public:
36
39 Whistle( void );
40
42 ~Whistle( void );
43
45 void clear( void );
46
48 void setFrequency( StkFloat frequency );
49
51 void startBlowing( StkFloat amplitude, StkFloat rate );
52
54 void stopBlowing( StkFloat rate );
55
57 void noteOn( StkFloat frequency, StkFloat amplitude );
58
60 void noteOff( StkFloat amplitude );
61
63 void controlChange( int number, StkFloat value );
64
66 StkFloat tick( unsigned int channel = 0 );
67
69
76 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
77
78protected:
79
80 Vector3D *tempVectorP_;
81 Vector3D tempVector_;
82 OnePole onepole_;
83 Noise noise_;
84 Envelope envelope_;
85 Sphere can_; // Declare a Spherical "can".
86 Sphere pea_, bumper_; // One spherical "pea", and a spherical "bumper".
87
88 SineWave sine_;
89
90 StkFloat baseFrequency_;
91 StkFloat noiseGain_;
92 StkFloat fippleFreqMod_;
93 StkFloat fippleGainMod_;
94 StkFloat blowFreqMod_;
95 StkFloat tickSize_;
96 StkFloat canLoss_;
97 int subSample_, subSampCount_;
98};
99
100 inline StkFrames& Whistle :: tick( StkFrames& frames, unsigned int channel )
101{
102 unsigned int nChannels = lastFrame_.channels();
103#if defined(_STK_DEBUG_)
104 if ( channel > frames.channels() - nChannels ) {
105 oStream_ << "Whistle::tick(): channel and StkFrames arguments are incompatible!";
106 handleError( StkError::FUNCTION_ARGUMENT );
107 }
108#endif
109
110 StkFloat *samples = &frames[channel];
111 unsigned int j, hop = frames.channels() - nChannels;
112 if ( nChannels == 1 ) {
113 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
114 *samples++ = tick();
115 }
116 else {
117 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
118 *samples++ = tick();
119 for ( j=1; j<nChannels; j++ )
120 *samples++ = lastFrame_[j];
121 }
122 }
123
124 return frames;
125}
126
127} // stk namespace
128#endif
stk::Envelope
STK linear line envelope class.
Definition Envelope.h:23
stk::Instrmnt::Instrmnt
Instrmnt(void)
Class constructor.
Definition Instrmnt.h:23
stk::Noise
STK noise generator.
Definition Noise.h:22
stk::OnePole
STK one-pole filter class.
Definition OnePole.h:21
stk::SineWave
STK sinusoid oscillator class.
Definition SineWave.h:26
stk::Sphere
STK sphere class.
Definition Sphere.h:21
stk::StkFrames
An STK class to handle vectorized audio data.
Definition Stk.h:279
stk::StkFrames::channels
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition Stk.h:416
stk::StkFrames::frames
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition Stk.h:419
stk::Stk::handleError
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
stk::Vector3D
STK 3D vector class.
Definition Vector3D.h:20
stk::Whistle::tick
StkFloat tick(unsigned int channel=0)
Compute and return one output sample.
stk::Whistle::noteOff
void noteOff(StkFloat amplitude)
Stop a note with the given amplitude (speed of decay).
stk::Whistle::stopBlowing
void stopBlowing(StkFloat rate)
Decrease breath velocity with given rate of decrease.
stk::Whistle::setFrequency
void setFrequency(StkFloat frequency)
Set instrument parameters for a particular frequency.
stk::Whistle::controlChange
void controlChange(int number, StkFloat value)
Perform the control change specified by number and value (0.0 - 128.0).
stk::Whistle::clear
void clear(void)
Reset and clear all internal state.
stk::Whistle::~Whistle
~Whistle(void)
Class destructor.
stk::Whistle::noteOn
void noteOn(StkFloat frequency, StkFloat amplitude)
Start a note with the given frequency and amplitude.
stk::Whistle::startBlowing
void startBlowing(StkFloat amplitude, StkFloat rate)
Apply breath velocity to instrument with given amplitude and rate of increase.
stk::Whistle::Whistle
Whistle(void)
Class constructor.
stk
The STK namespace.
Definition ADSR.h:6

The Synthesis ToolKit in C++ (STK)
©1995--2023 Perry R. Cook and Gary P. Scavone. All Rights Reserved.