 
    
   
Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial
    1 #ifndef STK_BLITSQUARE_H 
    2 #define STK_BLITSQUARE_H 
   58   void setPhase( StkFloat phase ) { phase_ = PI * phase; };
 
   64   StkFloat 
getPhase()
 const { 
return phase_ / PI; };
 
   85   StkFloat 
lastOut( 
void )
 const { 
return lastFrame_[0]; };
 
   88   StkFloat 
tick( 
void );
 
  102   void updateHarmonics( 
void );
 
  104   unsigned int nHarmonics_;
 
  110   StkFloat lastBlitOutput_;
 
  116   StkFloat temp = lastBlitOutput_;
 
  126   StkFloat denominator = sin( phase_ );
 
  127   if ( fabs( denominator )  < std::numeric_limits<StkFloat>::epsilon() ) {
 
  129     if ( phase_ < 0.1f || phase_ > TWO_PI - 0.1f )
 
  130       lastBlitOutput_ = a_;
 
  132       lastBlitOutput_ = -a_;
 
  135     lastBlitOutput_ =  sin( m_ * phase_ );
 
  136     lastBlitOutput_ /= p_ * denominator;
 
  139   lastBlitOutput_ += temp;
 
  142   lastFrame_[0] = lastBlitOutput_ - dcbState_ + 0.999 * lastFrame_[0];
 
  143   dcbState_ = lastBlitOutput_;
 
  146   if ( phase_ >= TWO_PI ) phase_ -= TWO_PI;
 
  148          return lastFrame_[0];
 
  153 #if defined(_STK_DEBUG_) 
  154   if ( channel >= frames.
channels() ) {
 
  155     oStream_ << 
"BlitSquare::tick(): channel and StkFrames arguments are incompatible!";
 
  160   StkFloat *samples = &frames[channel];
 
  161   unsigned int hop = frames.
channels();
 
  162   for ( 
unsigned int i=0; i<frames.
frames(); i++, samples += hop )
 
 
StkFloat lastOut(void) const
Return the last computed output value.
Definition: BlitSquare.h:85
unsigned int frames(void) const
Return the number of sample frames represented by the data.
Definition: Stk.h:407
StkFloat tick(void)
Compute and return one output sample.
Definition: BlitSquare.h:114
STK abstract unit generator parent class.
Definition: Generator.h:20
An STK class to handle vectorized audio data.
Definition: Stk.h:275
StkFloat getPhase() const
Get the current phase of the signal.
Definition: BlitSquare.h:64
~BlitSquare()
Class destructor.
void setFrequency(StkFloat frequency)
Set the impulse train rate in terms of a frequency in Hz.
void setPhase(StkFloat phase)
Set the phase of the signal.
Definition: BlitSquare.h:58
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:404
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
BlitSquare(StkFloat frequency=220.0)
Default constructor that initializes BLIT frequency to 220 Hz.
The STK namespace.
Definition: ADSR.h:6
STK band-limited square wave class.
Definition: BlitSquare.h:42
void setHarmonics(unsigned int nHarmonics=0)
Set the number of harmonics generated in the signal.
void reset()
Resets the oscillator state and phase to 0.