Version 4.4.0

This commit is contained in:
Gary Scavone
2013-09-29 23:11:39 +02:00
committed by Stephen Sinclair
parent d199342e86
commit eccd8c9981
287 changed files with 11712 additions and 7676 deletions

View File

@@ -2,36 +2,23 @@
/*! \class Delay
\brief STK non-interpolating delay line class.
This protected Filter subclass implements
a non-interpolating digital delay-line.
A fixed maximum length of 4095 and a delay
of zero is set using the default constructor.
Alternatively, the delay and maximum length
can be set during instantiation with an
overloaded constructor.
This class implements a non-interpolating digital delay-line. If
the delay and maximum length are not specified during
instantiation, a fixed maximum length of 4095 and a delay of zero
is set.
A non-interpolating delay line is typically
used in fixed delay-length applications, such
as for reverberation.
A non-interpolating delay line is typically used in fixed
delay-length applications, such as for reverberation.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
by Perry R. Cook and Gary P. Scavone, 1995 - 2009.
*/
/***************************************************/
#include "Delay.h"
Delay :: Delay() : Filter()
{
// Default maximum delay length set to 4095.
inputs_.resize( 4096 );
this->clear();
namespace stk {
inPoint_ = 0;
outPoint_ = 0;
delay_ = 0;
}
Delay :: Delay(unsigned long delay, unsigned long maxDelay)
Delay :: Delay( unsigned long delay, unsigned long maxDelay )
{
// Writing before reading allows delays from 0 to length-1.
// If we want to allow a delay of maxDelay, we need a
@@ -46,10 +33,8 @@ Delay :: Delay(unsigned long delay, unsigned long maxDelay)
handleError( StkError::FUNCTION_ARGUMENT );
}
if ( maxDelay > inputs_.size()-1 ) {
inputs_.resize( maxDelay+1 );
this->clear();
}
if ( ( maxDelay + 1 ) > inputs_.size() )
inputs_.resize( maxDelay + 1, 1, 0.0 );
inPoint_ = 0;
this->setDelay( delay );
@@ -59,14 +44,7 @@ Delay :: ~Delay()
{
}
void Delay :: clear(void)
{
for (unsigned int i=0; i<inputs_.size(); i++)
inputs_[i] = 0.0;
outputs_[0] = 0.0;
}
void Delay :: setMaximumDelay(unsigned long delay)
void Delay :: setMaximumDelay( unsigned long delay )
{
if ( delay < inputs_.size() ) return;
@@ -75,7 +53,7 @@ void Delay :: setMaximumDelay(unsigned long delay)
handleError( StkError::WARNING );
return;
}
else if (delay < delay_ ) {
else if ( delay < delay_ ) {
errorString_ << "Delay::setMaximumDelay: argument (" << delay << ") less than current delay setting (" << delay_ << ")!\n";
handleError( StkError::WARNING );
return;
@@ -84,7 +62,7 @@ void Delay :: setMaximumDelay(unsigned long delay)
inputs_.resize( delay + 1 );
}
void Delay :: setDelay(unsigned long delay)
void Delay :: setDelay( unsigned long delay )
{
if ( delay > inputs_.size() - 1 ) { // The value is too big.
errorString_ << "Delay::setDelay: argument (" << delay << ") too big ... setting to maximum!\n";
@@ -109,26 +87,21 @@ void Delay :: setDelay(unsigned long delay)
}
}
unsigned long Delay :: getDelay(void) const
{
return (unsigned long) delay_;
}
StkFloat Delay :: energy(void) const
StkFloat Delay :: energy( void ) const
{
unsigned long i;
register StkFloat e = 0;
if (inPoint_ >= outPoint_) {
for (i=outPoint_; i<inPoint_; i++) {
if ( inPoint_ >= outPoint_ ) {
for ( i=outPoint_; i<inPoint_; i++ ) {
register StkFloat t = inputs_[i];
e += t*t;
}
} else {
for (i=outPoint_; i<inputs_.size(); i++) {
for ( i=outPoint_; i<inputs_.size(); i++ ) {
register StkFloat t = inputs_[i];
e += t*t;
}
for (i=0; i<inPoint_; i++) {
for ( i=0; i<inPoint_; i++ ) {
register StkFloat t = inputs_[i];
e += t*t;
}
@@ -136,60 +109,13 @@ StkFloat Delay :: energy(void) const
return e;
}
StkFloat Delay :: contentsAt(unsigned long tapDelay)
StkFloat Delay :: contentsAt( unsigned long tapDelay )
{
unsigned long i = tapDelay;
if (i < 1) {
errorString_ << "Delay::contentsAt: argument (" << tapDelay << ") too small!";
handleError( StkError::WARNING );
return 0.0;
}
else if (i > delay_) {
errorString_ << "Delay::contentsAt: argument (" << tapDelay << ") too big!";
handleError( StkError::WARNING );
return 0.0;
}
long tap = inPoint_ - i;
if (tap < 0) // Check for wraparound.
long tap = inPoint_ - tapDelay - 1;
while ( tap < 0 ) // Check for wraparound.
tap += inputs_.size();
return inputs_[tap];
}
StkFloat Delay :: lastOut(void) const
{
return Filter::lastOut();
}
StkFloat Delay :: nextOut(void)
{
return inputs_[outPoint_];
}
StkFloat Delay :: computeSample( StkFloat input )
{
inputs_[inPoint_++] = input;
// Check for end condition
if (inPoint_ == inputs_.size())
inPoint_ = 0;
// Read out next value
outputs_[0] = inputs_[outPoint_++];
if (outPoint_ == inputs_.size())
outPoint_ = 0;
return outputs_[0];
}
StkFloat Delay :: tick( StkFloat input )
{
return computeSample( input );
}
StkFrames& Delay :: tick( StkFrames& frames, unsigned int channel )
{
return Filter::tick( frames, channel );
}
} // stk namespace