//----------------------------------------------------------------------------- // name: ksvoice.h // desc: sample class for Karplus Strong // // Music 256a, Fall 2009, Stanford University // http://ccrma.stanford.edu/courses/256a-fall-2009/ //----------------------------------------------------------------------------- #ifndef __KS_VOICE_H__ #define __KS_VOICE_H__ #define SAMPLE double struct KSVoice { public: KSVoice(); bool init( long delayLen ); void pluck(); void synthesize( SAMPLE * buffy, long numFrames ); protected: // delay buffer SAMPLE * m_delay; // max delay length long m_delayMax; // delay length long m_delayLen; // attenuation factor SAMPLE m_factor; // previous input SAMPLE m_prev; // read and write indices long m_reader; long m_writer; // pluck in progress long m_pluck; }; #endif