Logo Search packages:      
Sourcecode: csound version File versions  Download package

Instrmnt.cpp

/***************************************************/
/*! \class Instrmnt
    \brief STK instrument abstract base class.

    This class provides a common interface for
    all STK instruments.

    by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
*/
/***************************************************/

#include "Instrmnt.h"

00014 Instrmnt :: Instrmnt()
{
}

00018 Instrmnt :: ~Instrmnt()
{
}

00022 void Instrmnt :: setFrequency(StkFloat frequency)
{
  errorString_ << "Instrmnt::setFrequency: virtual setFrequency function call!";
  handleError( StkError::WARNING );
}

00028 StkFloat Instrmnt :: lastOut() const
{
  return lastOutput_;
}

// Support for stereo output:
00034 StkFloat Instrmnt :: lastOutLeft(void) const
{
  return 0.5 * lastOutput_;
}
                                                                                
00039 StkFloat Instrmnt :: lastOutRight(void) const
{
  return 0.5 * lastOutput_;
}

00044 StkFloat Instrmnt :: tick( void )
{
  return computeSample();
}

00049 StkFrames& Instrmnt :: tick( StkFrames& frames, unsigned int channel )
{
  if ( channel >= frames.channels() ) {
    errorString_ << "Instrmnt::tick(): channel and StkFrames arguments are incompatible!";
    handleError( StkError::FUNCTION_ARGUMENT );
  }

  if ( frames.channels() == 1 ) {
    for ( unsigned int i=0; i<frames.frames(); i++ )
      frames[i] = tick();
  }
  else if ( frames.interleaved() ) {
    unsigned int hop = frames.channels();
    unsigned int index = channel;
    for ( unsigned int i=0; i<frames.frames(); i++ ) {
      frames[index] = tick();
      index += hop;
    }
  }
  else {
    unsigned int iStart = channel * frames.frames();
    for ( unsigned int i=0; i<frames.frames(); i++, iStart++ )
      frames[iStart] = tick();
  }

  return frames;
}

00077 void Instrmnt :: controlChange(int number, StkFloat value)
{
  errorString_ << "Instrmnt::controlChange: virtual function call!";
  handleError( StkError::WARNING );
}

Generated by  Doxygen 1.6.0   Back to index