The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

BandedWG.h
1#ifndef STK_BANDEDWG_H
2#define STK_BANDEDWG_H
3
4#include "Instrmnt.h"
5#include "DelayL.h"
6#include "BowTable.h"
7#include "ADSR.h"
8#include "BiQuad.h"
9
10namespace stk {
11
12/***************************************************/
41/***************************************************/
42
43const int MAX_BANDED_MODES = 20;
44
45 class BandedWG : public Instrmnt
46{
47 public:
49 BandedWG( void );
50
52 ~BandedWG( void );
53
55 void clear( void );
56
58 void setStrikePosition( StkFloat position );
59
61 void setPreset( int preset );
62
64 void setFrequency( StkFloat frequency );
65
67 void startBowing( StkFloat amplitude, StkFloat rate );
68
70 void stopBowing( StkFloat rate );
71
73 void pluck( StkFloat amp );
74
76 void noteOn( StkFloat frequency, StkFloat amplitude );
77
79 void noteOff( StkFloat amplitude );
80
82 void controlChange( int number, StkFloat value );
83
85 StkFloat tick( unsigned int channel = 0 );
86
88
95 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
96
97 protected:
98
99 bool doPluck_;
100 bool trackVelocity_;
101 int nModes_;
102 int presetModes_;
103 BowTable bowTable_;
104 ADSR adsr_;
105 BiQuad bandpass_[MAX_BANDED_MODES];
106 DelayL delay_[MAX_BANDED_MODES];
107 StkFloat maxVelocity_;
108 StkFloat modes_[MAX_BANDED_MODES];
109 StkFloat frequency_;
110 StkFloat baseGain_;
111 StkFloat gains_[MAX_BANDED_MODES];
112 StkFloat basegains_[MAX_BANDED_MODES];
113 StkFloat excitation_[MAX_BANDED_MODES];
114 StkFloat integrationConstant_;
115 StkFloat velocityInput_;
116 StkFloat bowVelocity_;
117 StkFloat bowTarget_;
118 StkFloat bowPosition_;
119 StkFloat strikeAmp_;
120 int strikePosition_;
121
122};
123
124 inline StkFrames& BandedWG :: tick( StkFrames& frames, unsigned int channel )
125{
126 unsigned int nChannels = lastFrame_.channels();
127#if defined(_STK_DEBUG_)
128 if ( channel > frames.channels() - nChannels ) {
129 oStream_ << "BandedWG::tick(): channel and StkFrames arguments are incompatible!";
130 handleError( StkError::FUNCTION_ARGUMENT );
131 }
132#endif
133
134 StkFloat *samples = &frames[channel];
135 unsigned int j, hop = frames.channels() - nChannels;
136 if ( nChannels == 1 ) {
137 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
138 *samples++ = tick();
139 }
140 else {
141 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
142 *samples++ = tick();
143 for ( j=1; j<nChannels; j++ )
144 *samples++ = lastFrame_[j];
145 }
146 }
147
148 return frames;
149}
150
151} // stk namespace
152
153#endif
stk::ADSR
STK ADSR envelope class.
Definition: ADSR.h:25
stk::BandedWG
Banded waveguide modeling class.
Definition: BandedWG.h:46
stk::BandedWG::controlChange
void controlChange(int number, StkFloat value)
Perform the control change specified by number and value (0.0 - 128.0).
stk::BandedWG::clear
void clear(void)
Reset and clear all internal state.
stk::BandedWG::pluck
void pluck(StkFloat amp)
Pluck the instrument with given amplitude.
stk::BandedWG::startBowing
void startBowing(StkFloat amplitude, StkFloat rate)
Apply bow velocity/pressure to instrument with given amplitude and rate of increase.
stk::BandedWG::setStrikePosition
void setStrikePosition(StkFloat position)
Set strike position (0.0 - 1.0).
stk::BandedWG::tick
StkFloat tick(unsigned int channel=0)
Compute and return one output sample.
stk::BandedWG::noteOn
void noteOn(StkFloat frequency, StkFloat amplitude)
Start a note with the given frequency and amplitude.
stk::BandedWG::stopBowing
void stopBowing(StkFloat rate)
Decrease bow velocity/breath pressure with given rate of decrease.
stk::BandedWG::setPreset
void setPreset(int preset)
Select a preset.
stk::BandedWG::~BandedWG
~BandedWG(void)
Class destructor.
stk::BandedWG::noteOff
void noteOff(StkFloat amplitude)
Stop a note with the given amplitude (speed of decay).
stk::BandedWG::setFrequency
void setFrequency(StkFloat frequency)
Set instrument parameters for a particular frequency.
stk::BandedWG::BandedWG
BandedWG(void)
Class constructor.
stk::BiQuad
STK biquad (two-pole, two-zero) filter class.
Definition: BiQuad.h:21
stk::BowTable
STK bowed string table class.
Definition: BowTable.h:23
stk::DelayL
STK linear interpolating delay line class.
Definition: DelayL.h:28
stk::Instrmnt
STK instrument abstract base class.
Definition: Instrmnt.h:20
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--2021 Perry R. Cook and Gary P. Scavone. All Rights Reserved.