⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 singwave.cpp

📁 Mobile STK for Symbian OS V0.1
💻 CPP
字号:
/***************************************************//*! \class SingWave    \brief STK "singing" looped soundfile class.    This class contains all that is needed to make    a pitched musical sound, like a simple voice    or violin.  In general, it will not be used    alone because of munchkinification effects    from pitch shifting.  It will be used as an    excitation source for other instruments.    by Perry R. Cook and Gary P. Scavone, 1995 - 2005.*//***************************************************/#include "SingWave.h"//#if !defined(SYMBIAN) #if !defined(SYMBIAN)SingWave :: SingWave( std::string fileName, bool raw)#elseSingWave :: SingWave( const char *fileName, bool raw)#endif{  // An exception could be thrown here.  wave_ = new WaveLoop( fileName, raw );	rate_ = 1.0;	sweepRate_ = 0.001;	modulator_.setVibratoRate( 6.0 );	modulator_.setVibratoGain( 0.04 );	modulator_.setRandomGain( 0.005 );	this->setFrequency( 75.0 );	pitchEnvelope_.setRate( 1.0 );	this->computeSample();	this->computeSample();	pitchEnvelope_.setRate( sweepRate_ * rate_ );}SingWave :: ~SingWave(){  delete wave_;}void SingWave :: reset(){  wave_->reset();	lastOutput_ = 0.0;}void SingWave :: normalize(){  wave_->normalize();}void SingWave :: normalize(StkFloat peak){  wave_->normalize( peak );}void SingWave :: setFrequency(StkFloat frequency){	StkFloat temp = rate_;	rate_ = wave_->getSize() * frequency / Stk::sampleRate();	temp -= rate_;	if ( temp < 0) temp = -temp;	pitchEnvelope_.setTarget( rate_ );	pitchEnvelope_.setRate( sweepRate_ * temp );}void SingWave :: setVibratoRate(StkFloat rate){	modulator_.setVibratoRate( rate );}void SingWave :: setVibratoGain(StkFloat gain){	modulator_.setVibratoGain(gain);}void SingWave :: setRandomGain(StkFloat gain){	modulator_.setRandomGain(gain);}void SingWave :: setSweepRate(StkFloat rate){	sweepRate_ = rate;}void SingWave :: setGainRate(StkFloat rate){	envelope_.setRate(rate);}void SingWave :: setGainTarget(StkFloat target){	envelope_.setTarget(target);}void SingWave :: noteOn(){	envelope_.keyOn();}void SingWave :: noteOff(){	envelope_.keyOff();}StkFloat SingWave :: computeSample(){  // Set the wave rate.  StkFloat newRate = pitchEnvelope_.tick();  newRate += newRate * modulator_.tick();  wave_->setRate( newRate );  lastOutput_ = wave_->tick();	lastOutput_ *= envelope_.tick();	return lastOutput_;             }//#endif // SYMBIAN

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -