mirror of
https://github.com/thestk/stk
synced 2026-04-23 23:58:38 +00:00
Version 4.4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
d199342e86
commit
eccd8c9981
@@ -1,3 +1,15 @@
|
||||
#ifndef STK_BRASS_H
|
||||
#define STK_BRASS_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayA.h"
|
||||
#include "BiQuad.h"
|
||||
#include "PoleZero.h"
|
||||
#include "ADSR.h"
|
||||
#include "SineWave.h"
|
||||
|
||||
namespace stk {
|
||||
|
||||
/***************************************************/
|
||||
/*! \class Brass
|
||||
\brief STK simple brass instrument class.
|
||||
@@ -16,20 +28,10 @@
|
||||
- Vibrato Gain = 1
|
||||
- Volume = 128
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#ifndef STK_BRASS_H
|
||||
#define STK_BRASS_H
|
||||
|
||||
#include "Instrmnt.h"
|
||||
#include "DelayA.h"
|
||||
#include "BiQuad.h"
|
||||
#include "PoleZero.h"
|
||||
#include "ADSR.h"
|
||||
#include "SineWave.h"
|
||||
|
||||
class Brass: public Instrmnt
|
||||
{
|
||||
public:
|
||||
@@ -37,39 +39,40 @@ class Brass: public Instrmnt
|
||||
/*!
|
||||
An StkError will be thrown if the rawwave path is incorrectly set.
|
||||
*/
|
||||
Brass(StkFloat lowestFrequency);
|
||||
Brass( StkFloat lowestFrequency );
|
||||
|
||||
//! Class destructor.
|
||||
~Brass();
|
||||
~Brass( );
|
||||
|
||||
//! Reset and clear all internal state.
|
||||
void clear();
|
||||
void clear( );
|
||||
|
||||
//! Set instrument parameters for a particular frequency.
|
||||
void setFrequency(StkFloat frequency);
|
||||
void setFrequency( StkFloat frequency );
|
||||
|
||||
//! Set the lips frequency.
|
||||
void setLip(StkFloat frequency);
|
||||
void setLip( StkFloat frequency );
|
||||
|
||||
//! Apply breath pressure to instrument with given amplitude and rate of increase.
|
||||
void startBlowing(StkFloat amplitude, StkFloat rate);
|
||||
void startBlowing( StkFloat amplitude, StkFloat rate );
|
||||
|
||||
//! Decrease breath pressure with given rate of decrease.
|
||||
void stopBlowing(StkFloat rate);
|
||||
void stopBlowing( StkFloat rate );
|
||||
|
||||
//! Start a note with the given frequency and amplitude.
|
||||
void noteOn(StkFloat frequency, StkFloat amplitude);
|
||||
void noteOn( StkFloat frequency, StkFloat amplitude );
|
||||
|
||||
//! Stop a note with the given amplitude (speed of decay).
|
||||
void noteOff(StkFloat amplitude);
|
||||
void noteOff( StkFloat amplitude );
|
||||
|
||||
//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
|
||||
void controlChange(int number, StkFloat value);
|
||||
void controlChange( int number, StkFloat value );
|
||||
|
||||
//! Compute and return one output sample.
|
||||
StkFloat tick( unsigned int channel = 0 );
|
||||
|
||||
protected:
|
||||
|
||||
StkFloat computeSample( void );
|
||||
|
||||
DelayA delayLine_;
|
||||
BiQuad lipFilter_;
|
||||
PoleZero dcBlock_;
|
||||
@@ -83,4 +86,25 @@ class Brass: public Instrmnt
|
||||
|
||||
};
|
||||
|
||||
inline StkFloat Brass :: tick( unsigned int )
|
||||
{
|
||||
StkFloat breathPressure = maxPressure_ * adsr_.tick();
|
||||
breathPressure += vibratoGain_ * vibrato_.tick();
|
||||
|
||||
StkFloat mouthPressure = 0.3 * breathPressure;
|
||||
StkFloat borePressure = 0.85 * delayLine_.lastOut();
|
||||
StkFloat deltaPressure = mouthPressure - borePressure; // Differential pressure.
|
||||
deltaPressure = lipFilter_.tick( deltaPressure ); // Force - > position.
|
||||
deltaPressure *= deltaPressure; // Basic position to area mapping.
|
||||
if ( deltaPressure > 1.0 ) deltaPressure = 1.0; // Non-linear saturation.
|
||||
|
||||
// The following input scattering assumes the mouthPressure = area.
|
||||
lastFrame_[0] = deltaPressure * mouthPressure + ( 1.0 - deltaPressure) * borePressure;
|
||||
lastFrame_[0] = delayLine_.tick( dcBlock_.tick( lastFrame_[0] ) );
|
||||
|
||||
return lastFrame_[0];
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user