mirror of
https://github.com/thestk/stk
synced 2026-01-18 07:01:53 +00:00
Bugfix in DelayL::setDelay(); Updated tick() functions in RtWvIn and InetWvIn to support channel offset
This commit is contained in:
@@ -52,30 +52,6 @@ void DelayL :: setMaximumDelay( unsigned long delay )
|
||||
inputs_.resize(delay + 1, 1, 0.0);
|
||||
}
|
||||
|
||||
void DelayL :: setDelay( StkFloat delay )
|
||||
{
|
||||
if ( delay + 1 > inputs_.size() ) { // The value is too big.
|
||||
oStream_ << "DelayL::setDelay: argument (" << delay << ") greater than maximum!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
if (delay < 0 ) {
|
||||
oStream_ << "DelayL::setDelay: argument (" << delay << ") less than zero!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
StkFloat outPointer = inPoint_ - delay; // read chases write
|
||||
delay_ = delay;
|
||||
|
||||
while ( outPointer < 0 )
|
||||
outPointer += inputs_.size(); // modulo maximum length
|
||||
|
||||
outPoint_ = (long) outPointer; // integer part
|
||||
if ( outPoint_ == inputs_.size() ) outPoint_ = 0;
|
||||
alpha_ = outPointer - outPoint_; // fractional part
|
||||
omAlpha_ = (StkFloat) 1.0 - alpha_;
|
||||
}
|
||||
|
||||
StkFloat DelayL :: tapOut( unsigned long tapDelay )
|
||||
{
|
||||
long tap = inPoint_ - tapDelay - 1;
|
||||
|
||||
@@ -245,14 +245,14 @@ StkFrames& FileWvIn :: tick( StkFrames& frames, unsigned int channel)
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@@ -288,11 +288,11 @@ StkFloat InetWvIn :: tick( unsigned int channel )
|
||||
return lastFrame_[channel];
|
||||
}
|
||||
|
||||
StkFrames& InetWvIn :: tick( StkFrames& frames )
|
||||
StkFrames& InetWvIn :: tick( StkFrames& frames, unsigned int channel )
|
||||
{
|
||||
#if defined(_STK_DEBUG_)
|
||||
if ( data_.channels() != frames.channels() ) {
|
||||
oStream_ << "InetWvIn::tick(): StkFrames argument is incompatible with streamed channels!";
|
||||
if ( channel > frames.channels() - data_.channels() ) {
|
||||
oStream_ << "InetWvIn::tick(): channel and StkFrames arguments are incompatible!";
|
||||
handleError( StkError::FUNCTION_ARGUMENT );
|
||||
}
|
||||
#endif
|
||||
@@ -306,11 +306,12 @@ StkFrames& InetWvIn :: tick( StkFrames& frames )
|
||||
return frames;
|
||||
}
|
||||
|
||||
unsigned int j, counter = 0;
|
||||
for ( unsigned int i=0; i<frames.frames(); i++ ) {
|
||||
StkFloat *samples = &frames[channel];
|
||||
unsigned int j, hop = frames.channels() - data_.channels();
|
||||
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
|
||||
this->tick();
|
||||
for ( j=0; j<lastFrame_.channels(); j++ )
|
||||
frames[counter++] = lastFrame_[j];
|
||||
*samples++ = lastFrame_[j];
|
||||
}
|
||||
|
||||
return frames;
|
||||
|
||||
@@ -145,12 +145,12 @@ StkFloat RtWvIn :: tick( unsigned int channel )
|
||||
return lastFrame_[channel];
|
||||
}
|
||||
|
||||
StkFrames& RtWvIn :: tick( StkFrames& frames )
|
||||
StkFrames& RtWvIn :: tick( StkFrames& frames, unsigned int channel )
|
||||
{
|
||||
unsigned int nChannels = lastFrame_.channels();
|
||||
#if defined(_STK_DEBUG_)
|
||||
if ( nChannels != frames.channels() ) {
|
||||
oStream_ << "RtWvIn::tick(): StkFrames argument is incompatible with adc channels!";
|
||||
if ( channel > frames.channels() - nChannels ) {
|
||||
oStream_ << "RtWvIn::tick(): channel and StkFrames arguments are incompatible!";
|
||||
handleError( StkError::FUNCTION_ARGUMENT );
|
||||
}
|
||||
#endif
|
||||
@@ -173,7 +173,17 @@ StkFrames& RtWvIn :: tick( StkFrames& frames )
|
||||
nFrames = frames.frames() - framesRead;
|
||||
bytes = nFrames * nChannels * sizeof( StkFloat );
|
||||
StkFloat *samples = &data_[readIndex_ * nChannels];
|
||||
memcpy( &frames[framesRead * nChannels], samples, bytes );
|
||||
unsigned int hop = frames.channels() - nChannels;
|
||||
if ( hop == 0 )
|
||||
memcpy( &frames[framesRead * nChannels], samples, bytes );
|
||||
else {
|
||||
StkFloat *fSamples = &frames[channel];
|
||||
unsigned int j;
|
||||
for ( unsigned int i=0; i<frames.frames(); i++, fSamples += hop ) {
|
||||
for ( j=1; j<nChannels; j++ )
|
||||
*fSamples++ = *samples++;
|
||||
}
|
||||
}
|
||||
|
||||
readIndex_ += nFrames;
|
||||
if ( readIndex_ == data_.frames() ) readIndex_ = 0;
|
||||
@@ -186,7 +196,7 @@ StkFrames& RtWvIn :: tick( StkFrames& frames )
|
||||
|
||||
unsigned long index = (frames.frames() - 1) * nChannels;
|
||||
for ( unsigned int i=0; i<lastFrame_.size(); i++ )
|
||||
lastFrame_[i] = frames[index++];
|
||||
lastFrame_[i] = frames[channel+index++];
|
||||
|
||||
return frames;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user