56 void noteOn( StkFloat frequency, StkFloat amplitude );
62 StkFloat
tick(
unsigned int channel = 0 );
81inline StkFloat FMVoices :: tick(
unsigned int )
85 temp = gains_[3] * adsr_[3]->tick() * waves_[3]->tick();
86 temp2 = vibrato_.tick() * modDepth_ * 0.1;
88 waves_[0]->setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[0]);
89 waves_[1]->setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[1]);
90 waves_[2]->setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[2]);
91 waves_[3]->setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[3]);
93 waves_[0]->addPhaseOffset(temp * mods_[0]);
94 waves_[1]->addPhaseOffset(temp * mods_[1]);
95 waves_[2]->addPhaseOffset(temp * mods_[2]);
96 waves_[3]->addPhaseOffset( twozero_.lastOut() );
97 twozero_.tick( temp );
98 temp = gains_[0] * tilt_[0] * adsr_[0]->tick() * waves_[0]->tick();
99 temp += gains_[1] * tilt_[1] * adsr_[1]->tick() * waves_[1]->tick();
100 temp += gains_[2] * tilt_[2] * adsr_[2]->tick() * waves_[2]->tick();
102 lastFrame_[0] = temp * 0.33;
103 return lastFrame_[0];
108 unsigned int nChannels = lastFrame_.
channels();
109#if defined(_STK_DEBUG_)
110 if ( channel > frames.
channels() - nChannels ) {
111 oStream_ <<
"FMVoices::tick(): channel and StkFrames arguments are incompatible!";
112 handleError( StkError::FUNCTION_ARGUMENT );
116 StkFloat *samples = &frames[channel];
117 unsigned int j, hop = frames.
channels() - nChannels;
118 if ( nChannels == 1 ) {
119 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop )
123 for (
unsigned int i=0; i<frames.
frames(); i++, samples += hop ) {
125 for ( j=1; j<nChannels; j++ )
126 *samples++ = lastFrame_[j];
STK singing FM synthesis instrument.
Definition FMVoices.h:41
void controlChange(int number, StkFloat value)
Perform the control change specified by number and value (0.0 - 128.0).
FMVoices(void)
Class constructor.
StkFloat tick(unsigned int channel=0)
Compute and return one output sample.
Definition FMVoices.h:81
~FMVoices(void)
Class destructor.
void noteOn(StkFloat frequency, StkFloat amplitude)
Start a note with the given frequency and amplitude.
void setFrequency(StkFloat frequency)
Set instrument parameters for a particular frequency.
STK abstract FM synthesis base class.
Definition FM.h:38
An STK class to handle vectorized audio data.
Definition Stk.h:279
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition Stk.h:416
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition Stk.h:419
The STK namespace.
Definition ADSR.h:6