Version 4.4.3

This commit is contained in:
Gary Scavone
2013-09-29 23:21:29 +02:00
committed by Stephen Sinclair
parent baca57040b
commit 0aec39260a
223 changed files with 26190 additions and 11130 deletions

View File

@@ -13,20 +13,26 @@
Stanford, bearing the names of Karplus and/or
Strong.
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
by Perry R. Cook and Gary P. Scavone, 1995-2011.
*/
/***************************************************/
#include "Drone.h"
#include <sstream>
namespace stk {
Drone :: Drone( StkFloat lowestFrequency )
{
length_ = (unsigned long) ( Stk::sampleRate() / lowestFrequency + 1 );
loopGain_ = 0.999;
delayLine_.setMaximumDelay( length_ );
delayLine_.setDelay( 0.5 * length_ );
if ( lowestFrequency <= 0.0 ) {
oStream_ << "Drone::Drone: argument is less than or equal to zero!";
handleError( StkError::FUNCTION_ARGUMENT );
}
unsigned long delays = (unsigned long) ( Stk::sampleRate() / lowestFrequency );
delayLine_.setMaximumDelay( delays + 1 );
this->setFrequency( 220.0 );
envelope_.setAllTimes( 2.0, 0.5, 0.0, 0.5 );
this->clear();
}
@@ -43,21 +49,18 @@ void Drone :: clear( void )
void Drone :: setFrequency( StkFloat frequency )
{
StkFloat freakency = frequency;
#if defined(_STK_DEBUG_)
if ( frequency <= 0.0 ) {
errorString_ << "Drone::setFrequency: parameter is less than or equal to zero!";
handleError( StkError::WARNING );
freakency = 220.0;
oStream_ << "Drone::setFrequency: argument is less than or equal to zero!";
handleError( StkError::WARNING ); return;
}
#endif
// Delay = length - approximate filter delay.
StkFloat delay = (Stk::sampleRate() / freakency) - 0.5;
if ( delay <= 0.0 )
delay = 0.3;
else if (delay > length_)
delay = length_;
StkFloat delay = (Stk::sampleRate() / frequency) - 0.5;
delayLine_.setDelay( delay );
loopGain_ = 0.997 + (freakency * 0.000002);
loopGain_ = 0.997 + (frequency * 0.000002);
if ( loopGain_ >= 1.0 ) loopGain_ = 0.99999;
}
@@ -70,31 +73,16 @@ void Drone :: noteOn( StkFloat frequency, StkFloat amplitude )
{
this->setFrequency( frequency );
this->pluck( amplitude );
#if defined(_STK_DEBUG_)
errorString_ << "Drone::NoteOn: frequency = " << frequency << ", amplitude = " << amplitude << ".";
handleError( StkError::DEBUG_WARNING );
#endif
}
void Drone :: noteOff( StkFloat amplitude )
{
loopGain_ = 1.0 - amplitude;
if ( loopGain_ < 0.0 ) {
errorString_ << "Drone::noteOff: amplitude is greater than 1.0 ... setting to 1.0!";
handleError( StkError::WARNING );
loopGain_ = 0.0;
}
else if ( loopGain_ > 1.0 ) {
errorString_ << "Drone::noteOff: amplitude is < 0.0 ... setting to 0.0!";
handleError( StkError::WARNING );
loopGain_ = 0.99999;
if ( amplitude < 0.0 || amplitude > 1.0 ) {
oStream_ << "Plucked::noteOff: amplitude is out of range!";
handleError( StkError::WARNING ); return;
}
#if defined(_STK_DEBUG_)
errorString_ << "Drone::noteOff: amplitude = " << amplitude << ".";
handleError( StkError::DEBUG_WARNING );
#endif
loopGain_ = 1.0 - amplitude;
}
} // stk namespace

View File

@@ -24,7 +24,7 @@ namespace stk {
Stanford, bearing the names of Karplus and/or
Strong.
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
by Perry R. Cook and Gary P. Scavone, 1995-2011.
*/
/***************************************************/
@@ -55,6 +55,16 @@ class Drone : public Instrmnt
//! Compute and return one output sample.
StkFloat tick( unsigned int channel = 0 );
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument must be less than the number of
channels in the StkFrames argument (the first channel is specified
by 0). However, range checking is only performed if _STK_DEBUG_
is defined during compilation, in which case an out-of-range value
will trigger an StkError exception.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
protected:
DelayA delayLine_;
@@ -74,6 +84,33 @@ inline StkFloat Drone :: tick( unsigned int )
return lastFrame_[0];
}
inline StkFrames& Drone :: tick( StkFrames& frames, unsigned int channel )
{
unsigned int nChannels = lastFrame_.channels();
#if defined(_STK_DEBUG_)
if ( channel > frames.channels() - nChannels ) {
oStream_ << "Drone::tick(): channel and StkFrames arguments are incompatible!";
handleError( StkError::FUNCTION_ARGUMENT );
}
#endif
StkFloat *samples = &frames[channel];
unsigned int j, hop = frames.channels() - nChannels;
if ( nChannels == 1 ) {
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
*samples++ = tick();
}
else {
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
*samples++ = tick();
for ( j=1; j<nChannels; j++ )
*samples++ = lastFrame_[j];
}
}
return frames;
}
} // stk namespace
#endif

View File

@@ -30,7 +30,7 @@ LIBRARY = @LIBS@
REALTIME = @realtime@
ifeq ($(REALTIME),yes)
PROGRAMS = ragamat
OBJECTS += RtMidi.o RtAudio.o RtWvOut.o Thread.o Mutex.o Socket.o TcpServer.o @objects@
OBJECTS += RtMidi.o RtAudio.o Thread.o Mutex.o Socket.o TcpServer.o @objects@
endif
RAWWAVES = @rawwaves@
@@ -51,7 +51,7 @@ ragamat: ragamat.cpp $(OBJECTS)
$(CC) $(LDFLAGS) $(CFLAGS) $(DEFS) -o ragamat ragamat.cpp $(OBJECT_PATH)/*.o $(LIBRARY)
libragamat: ragamat.cpp Tabla.cpp Drone.cpp VoicDrum.cpp
$(CC) $(LDFLAGS) $(CFLAGS) $(DEFS) -o ragamat Tabla.cpp Drone.cpp VoicDrum.cpp ragamat.cpp -L../../src $(LIBRARY) -lstk
$(CC) $(LDFLAGS) $(CFLAGS) $(DEFS) -o ragamat Tabla.cpp Drone.cpp VoicDrum.cpp ragamat.cpp -L../../src -lstk $(LIBRARY)
$(OBJECTS) : Stk.h

View File

@@ -8,12 +8,13 @@
sample rates. You can specify the maximum polyphony (maximum
number of simultaneous voices) in Tabla.h.
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
by Perry R. Cook and Gary P. Scavone, 1995-2011.
*/
/***************************************************/
#include "Tabla.h"
#include <cmath>
#include <sstream>
namespace stk {
@@ -49,21 +50,9 @@ static char tablaWaves[TABLA_NUMWAVES][16] =
void Tabla :: noteOn( StkFloat instrument, StkFloat amplitude )
{
#if defined(_STK_DEBUG_)
errorString_ << "Tabla::noteOn: instrument = " << instrument << ", amplitude = " << amplitude << '.';
handleError( StkError::DEBUG_WARNING );
#endif
StkFloat gain = amplitude;
if ( amplitude > 1.0 ) {
errorString_ << "Tabla::noteOn: amplitude parameter is greater than 1.0 ... setting to 1.0.";
handleError( StkError::WARNING );
gain = 1.0;
}
else if ( amplitude < 0.0 ) {
errorString_ << "Tabla::noteOn: amplitude parameter is less than 0.0 ... doing nothing.";
handleError( StkError::WARNING );
return;
if ( amplitude < 0.0 || amplitude > 1.0 ) {
oStream_ << "Tabla::noteOn: amplitude parameter is out of bounds!";
handleError( StkError::WARNING ); return;
}
int noteNumber = ( (int) instrument ) % 16;
@@ -79,8 +68,8 @@ void Tabla :: noteOn( StkFloat instrument, StkFloat amplitude )
nSounding_++;
}
waves_[iWave].reset();
filters_[iWave].setPole( 0.999 - (gain * 0.6) );
filters_[iWave].setGain( gain );
filters_[iWave].setPole( 0.999 - (amplitude * 0.6) );
filters_[iWave].setGain( amplitude );
break;
}
}
@@ -107,16 +96,18 @@ void Tabla :: noteOn( StkFloat instrument, StkFloat amplitude )
waves_[iWave].openFile( (std::string("rawwaves/") + tablaWaves[ noteNumber ]).c_str(), true );
if ( Stk::sampleRate() != 22050.0 )
waves_[iWave].setRate( 22050.0 / Stk::sampleRate() );
filters_[iWave].setPole( 0.999 - (gain * 0.6) );
filters_[iWave].setGain( gain );
filters_[iWave].setPole( 0.999 - (amplitude * 0.6) );
filters_[iWave].setGain( amplitude );
}
/*
#if defined(_STK_DEBUG_)
errorString_ << "Tabla::noteOn: number sounding = " << nSounding_ << '\n';
for (int i=0; i<nSounding_; i++) errorString_ << soundNumber_[i] << " ";
errorString_ << '\n';
oStream; errorStream << "Tabla::noteOn: number sounding = " << nSounding_ << '\n';
for (int i=0; i<nSounding_; i++) oStream << soundNumber_[i] << " ";
oStream << '\n'; errorString_ = oStream.str();
handleError( StkError::DEBUG_WARNING );
#endif
*/
}
void Tabla :: noteOff( StkFloat amplitude )

View File

@@ -17,7 +17,7 @@ namespace stk {
sample rates. You can specify the maximum polyphony (maximum
number of simultaneous voices) in Tabla.h.
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
by Perry R. Cook and Gary P. Scavone, 1995-2011.
*/
/***************************************************/
@@ -42,6 +42,16 @@ class Tabla : public Instrmnt
//! Compute and return one output sample.
StkFloat tick( unsigned int channel = 0 );
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument must be less than the number of
channels in the StkFrames argument (the first channel is specified
by 0). However, range checking is only performed if _STK_DEBUG_
is defined during compilation, in which case an out-of-range value
will trigger an StkError exception.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
protected:
FileWvIn waves_[TABLA_POLYPHONY];
@@ -76,6 +86,33 @@ inline StkFloat Tabla :: tick( unsigned int )
return lastFrame_[0];
}
inline StkFrames& Tabla :: tick( StkFrames& frames, unsigned int channel )
{
unsigned int nChannels = lastFrame_.channels();
#if defined(_STK_DEBUG_)
if ( channel > frames.channels() - nChannels ) {
oStream_ << "Tabla::tick(): channel and StkFrames arguments are incompatible!";
handleError( StkError::FUNCTION_ARGUMENT );
}
#endif
StkFloat *samples = &frames[channel];
unsigned int j, hop = frames.channels() - nChannels;
if ( nChannels == 1 ) {
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
*samples++ = tick();
}
else {
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
*samples++ = tick();
for ( j=1; j<nChannels; j++ )
*samples++ = lastFrame_[j];
}
}
return frames;
}
} // stk namespace
#endif

View File

@@ -8,7 +8,7 @@
sample rates. You can specify the maximum polyphony (maximum
number of simultaneous voices) in VoicDrum.h.
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
by Perry R. Cook and Gary P. Scavone, 1995-2011.
*/
/***************************************************/
@@ -46,21 +46,9 @@ char voiceNames[VOICE_NUMWAVES][11] =
void VoicDrum :: noteOn( StkFloat instrument, StkFloat amplitude )
{
#if defined(_STK_DEBUG_)
errorString_ << "VoicDrum::noteOn: instrument = " << instrument << ", amplitude = " << amplitude << '.';
handleError( StkError::DEBUG_WARNING );
#endif
StkFloat gain = amplitude;
if ( amplitude > 1.0 ) {
errorString_ << "VoicDrum::noteOn: amplitude parameter is greater than 1.0 ... setting to 1.0.";
handleError( StkError::WARNING );
gain = 1.0;
}
else if ( amplitude < 0.0 ) {
errorString_ << "VoicDrum::noteOn: amplitude parameter is less than 0.0 ... doing nothing.";
handleError( StkError::WARNING );
return;
if ( amplitude < 0.0 || amplitude > 1.0 ) {
oStream_ << "VoicDrum::noteOn: amplitude parameter is out of bounds!";
handleError( StkError::WARNING ); return;
}
int noteNumber = ( (int) instrument ) % 11;
@@ -76,8 +64,8 @@ void VoicDrum :: noteOn( StkFloat instrument, StkFloat amplitude )
nSounding_++;
}
waves_[iWave].reset();
filters_[iWave].setPole( 0.999 - (gain * 0.6) );
filters_[iWave].setGain( gain );
filters_[iWave].setPole( 0.999 - (amplitude * 0.6) );
filters_[iWave].setGain( amplitude );
break;
}
}
@@ -104,16 +92,18 @@ void VoicDrum :: noteOn( StkFloat instrument, StkFloat amplitude )
waves_[iWave].openFile( (std::string("rawwaves/") + voiceNames[ noteNumber ]).c_str(), true );
if ( Stk::sampleRate() != 22050.0 )
waves_[iWave].setRate( 22050.0 / Stk::sampleRate() );
filters_[iWave].setPole( 0.999 - (gain * 0.6) );
filters_[iWave].setGain( gain );
filters_[iWave].setPole( 0.999 - (amplitude * 0.6) );
filters_[iWave].setGain( amplitude );
}
/*
#if defined(_STK_DEBUG_)
errorString_ << "VoicDrum::noteOn: number sounding = " << nSounding_ << '\n';
for (int i=0; i<nSounding_; i++) errorString_ << soundNumber_[i] << " ";
errorString_ << '\n';
handleError( StkError::DEBUG_WARNING );
oStream << "VoicDrum::noteOn: number sounding = " << nSounding_ << '\n';
for (int i=0; i<nSounding_; i++) oStream << soundNumber_[i] << " ";
oStream << '\n';
handleError( StkError::WARNING );
#endif
*/
}
void VoicDrum :: noteOff( StkFloat amplitude )

View File

@@ -17,7 +17,7 @@ namespace stk {
sample rates. You can specify the maximum polyphony (maximum
number of simultaneous voices) in VoicDrum.h.
by Perry R. Cook and Gary P. Scavone, 1995 - 2010.
by Perry R. Cook and Gary P. Scavone, 1995-2011.
*/
/***************************************************/
@@ -42,6 +42,16 @@ class VoicDrum : public Instrmnt
//! Compute and return one output sample.
StkFloat tick( unsigned int channel = 0 );
//! Fill a channel of the StkFrames object with computed outputs.
/*!
The \c channel argument must be less than the number of
channels in the StkFrames argument (the first channel is specified
by 0). However, range checking is only performed if _STK_DEBUG_
is defined during compilation, in which case an out-of-range value
will trigger an StkError exception.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
protected:
FileWvIn waves_[VOICE_POLYPHONY];
@@ -76,6 +86,33 @@ inline StkFloat VoicDrum :: tick( unsigned int )
return lastFrame_[0];
}
inline StkFrames& VoicDrum :: tick( StkFrames& frames, unsigned int channel )
{
unsigned int nChannels = lastFrame_.channels();
#if defined(_STK_DEBUG_)
if ( channel > frames.channels() - nChannels ) {
oStream_ << "VoicDrum::tick(): channel and StkFrames arguments are incompatible!";
handleError( StkError::FUNCTION_ARGUMENT );
}
#endif
StkFloat *samples = &frames[channel];
unsigned int j, hop = frames.channels() - nChannels;
if ( nChannels == 1 ) {
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
*samples++ = tick();
}
else {
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
*samples++ = tick();
for ( j=1; j<nChannels; j++ )
*samples++ = lastFrame_[j];
}
}
return frames;
}
} // stk namespace
#endif