The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

HevyMetl.h
1#ifndef STK_HEVYMETL_H
2#define STK_HEVYMETL_H
3
4#include "FM.h"
5
6namespace stk {
7
8/***************************************************/
36/***************************************************/
37
38 class HevyMetl : public FM
39{
40 public:
42
45 HevyMetl( void );
46
48 ~HevyMetl( void );
49
51 void noteOn( StkFloat frequency, StkFloat amplitude );
52
54 StkFloat tick( unsigned int channel = 0 );
55
57
64 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
65
66 protected:
67
68};
69
70 inline StkFloat HevyMetl :: tick( unsigned int )
71{
72 StkFloat temp;
73
74 temp = vibrato_.tick() * modDepth_ * 0.2;
75 waves_[0]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[0]);
76 waves_[1]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[1]);
77 waves_[2]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[2]);
78 waves_[3]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[3]);
79
80 temp = gains_[2] * adsr_[2]->tick() * waves_[2]->tick();
81 waves_[1]->addPhaseOffset( temp );
82
83 waves_[3]->addPhaseOffset( twozero_.lastOut() );
84 temp = (1.0 - (control2_ * 0.5)) * gains_[3] * adsr_[3]->tick() * waves_[3]->tick();
85 twozero_.tick(temp);
86
87 temp += control2_ * 0.5 * gains_[1] * adsr_[1]->tick() * waves_[1]->tick();
88 temp = temp * control1_;
89
90 waves_[0]->addPhaseOffset( temp );
91 temp = gains_[0] * adsr_[0]->tick() * waves_[0]->tick();
92
93 lastFrame_[0] = temp * 0.5;
94 return lastFrame_[0];
95}
96
97 inline StkFrames& HevyMetl :: tick( StkFrames& frames, unsigned int channel )
98{
99 unsigned int nChannels = lastFrame_.channels();
100#if defined(_STK_DEBUG_)
101 if ( channel > frames.channels() - nChannels ) {
102 oStream_ << "HevyMetl::tick(): channel and StkFrames arguments are incompatible!";
103 handleError( StkError::FUNCTION_ARGUMENT );
104 }
105#endif
106
107 StkFloat *samples = &frames[channel];
108 unsigned int j, hop = frames.channels() - nChannels;
109 if ( nChannels == 1 ) {
110 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
111 *samples++ = tick();
112 }
113 else {
114 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
115 *samples++ = tick();
116 for ( j=1; j<nChannels; j++ )
117 *samples++ = lastFrame_[j];
118 }
119 }
120
121 return frames;
122}
123
124} // stk namespace
125
126#endif
stk::FM
STK abstract FM synthesis base class.
Definition: FM.h:38
stk::HevyMetl
STK heavy metal FM synthesis instrument.
Definition: HevyMetl.h:39
stk::HevyMetl::tick
StkFloat tick(unsigned int channel=0)
Compute and return one output sample.
Definition: HevyMetl.h:70
stk::HevyMetl::~HevyMetl
~HevyMetl(void)
Class destructor.
stk::HevyMetl::HevyMetl
HevyMetl(void)
Class constructor.
stk::HevyMetl::noteOn
void noteOn(StkFloat frequency, StkFloat amplitude)
Start a note with the given frequency and amplitude.
stk::SineWave::tick
StkFloat tick(void)
Compute and return one output sample.
Definition: SineWave.h:99
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::TwoZero::lastOut
StkFloat lastOut(void) const
Return the last computed output value.
Definition: TwoZero.h:60
stk::TwoZero::tick
StkFloat tick(StkFloat input)
Input one sample to the filter and return one output.
Definition: TwoZero.h:92
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.