The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

Recorder.h
1#ifndef STK_RECORDER_H
2#define STK_RECORDER_H
3
4#include "Instrmnt.h"
5#include "Iir.h"
6#include "DelayL.h"
7#include "Noise.h"
8#include "SineWave.h"
9#include "ADSR.h"
10
11namespace stk {
12
13/***************************************************/
34/***************************************************/
35
36 class Recorder : public Instrmnt
37{
38 public:
40 Recorder( void );
41
43 ~Recorder( void );
44
46 void clear( void );
47
49 void setFrequency( StkFloat val );
50
52 void startBlowing( StkFloat amplitude, StkFloat rate );
53
55 void stopBlowing( StkFloat rate );
56
58 void noteOn( StkFloat frequency, StkFloat amplitude );
59
61 void noteOff( StkFloat amplitude );
62
64 void controlChange( int number, StkFloat value );
65
67 StkFloat tick( unsigned int channel = 0 );
68
70
77 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
78
79 void setBlowPressure( StkFloat val );
80 void setVibratoGain( StkFloat val );
81 void setVibratoFrequency( StkFloat val );
82 void setNoiseGain( StkFloat val );
83 void setBreathCutoff( StkFloat val );
84 void setSoftness( StkFloat val );
85
86 private:
87 DelayL pinDelay_;
88 DelayL poutDelay_;
89 DelayL jetDelay_;
90 Iir radiation_filter_;
91 Iir visco_in_filter_;
92 Iir visco_out_filter_;
93 Iir jetFilter_;
94 Noise turb_;
95 Iir turbFilter_;
96 SineWave vibrato_;
97 ADSR adsr_;
98
99 //StkFloat M{ 0 };
100 //StkFloat maxPressure_( 0 );
101 double maxPressure_;
102 //StkFloat blow{ 0 };
103 StkFloat vibratoGain_;
104 StkFloat noiseGain_;
105 StkFloat breathCutoff_;
106 StkFloat outputGain_;
107 StkFloat psi_;
108
109 StkFloat poutL_;
110 StkFloat pout_;
111 StkFloat poutm1_;
112 StkFloat poutm2_;
113 StkFloat pin_;
114 StkFloat pinm1_;
115 StkFloat pinm2_;
116
117 StkFloat b1;
118 StkFloat b3;
119 StkFloat b4;
120
121 StkFloat Uj_;
122 StkFloat Ujm1_;
123
124 StkFloat Qj_;
125 StkFloat Qjm1_;
126 StkFloat Qjm2_;
127
128 StkFloat Q1_;
129 StkFloat Q1m1_;
130 StkFloat Q1m2_;
131
132 StkFloat Qp_;
133 StkFloat Qpm1_;
134
135 StkFloat pm_;
136};
137
138 inline StkFrames& Recorder :: tick( StkFrames& frames, unsigned int channel )
139{
140 unsigned int nChannels = lastFrame_.channels();
141#if defined(_STK_DEBUG_)
142 if ( channel > frames.channels() - nChannels ) {
143 oStream_ << "Recorder::tick(): channel and StkFrames arguments are incompatible!";
144 handleError( StkError::FUNCTION_ARGUMENT );
145 }
146#endif
147
148 StkFloat *samples = &frames[channel];
149 unsigned int j, hop = frames.channels() - nChannels;
150 if ( nChannels == 1 ) {
151 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
152 *samples++ = tick();
153 }
154 else {
155 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
156 *samples++ = tick();
157 for ( j=1; j<nChannels; j++ )
158 *samples++ = lastFrame_[j];
159 }
160 }
161
162 return frames;
163}
164
165} // stk namespace
166
167#endif
stk::ADSR
STK ADSR envelope class.
Definition ADSR.h:25
stk::DelayL
STK linear interpolating delay line class.
Definition DelayL.h:28
stk::Iir
STK general infinite impulse response filter class.
Definition Iir.h:35
stk::Instrmnt
STK instrument abstract base class.
Definition Instrmnt.h:20
stk::Noise
STK noise generator.
Definition Noise.h:22
stk::Recorder
A recorder / flute physical model.
Definition Recorder.h:37
stk::Recorder::tick
StkFloat tick(unsigned int channel=0)
Compute and return one output sample.
stk::Recorder::startBlowing
void startBlowing(StkFloat amplitude, StkFloat rate)
Apply breath velocity to instrument with given amplitude and rate of increase.
stk::Recorder::controlChange
void controlChange(int number, StkFloat value)
Perform the control change specified by number and value (0.0 - 128.0).
stk::Recorder::stopBlowing
void stopBlowing(StkFloat rate)
Decrease breath velocity with given rate of decrease.
stk::Recorder::Recorder
Recorder(void)
Class constructor.
stk::Recorder::setFrequency
void setFrequency(StkFloat val)
Set instrument parameters for a particular frequency.
stk::Recorder::noteOff
void noteOff(StkFloat amplitude)
Stop a note with the given amplitude (speed of decay).
stk::Recorder::noteOn
void noteOn(StkFloat frequency, StkFloat amplitude)
Start a note with the given frequency and amplitude.
stk::Recorder::~Recorder
~Recorder(void)
Class destructor.
stk::Recorder::clear
void clear(void)
Reset and clear all internal state.
stk::SineWave
STK sinusoid oscillator class.
Definition SineWave.h:26
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
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.