00001
00002
00003
00004
00005
00006 #include "dline.h"
00007 namespace dline{
00008 CShifter::CShifter( int aMaxDelay )
00009 {
00010 head = 0;
00011 maxDelay = aMaxDelay;
00012 state = new shortfract[maxDelay];
00013
00014 if ( state ){
00015 for ( unsigned int i=0; i < maxDelay; i++ )
00016 state[i] = 0.0r;
00017 }
00018 }
00019
00020 CShifter::~CShifter(void)
00021 {
00022 if ( state )
00023 delete[] state;
00024 }
00025
00026 void CShifter::run( const shortfract in[], shortfract out[], int count, int delay )
00027 {
00028 int delayIndex;
00029
00030 if ( delay >= maxDelay )
00031 delay = maxDelay - 1;
00032
00033 if ( state ){
00034 for( int i = 0; i<count; i++ ){
00035 state[head] = in[i];
00036 delayIndex = head + delay;
00037 if ( delayIndex >= maxDelay )
00038 delayIndex -= maxDelay;
00039 out[i] = state[delayIndex];
00040 head --;
00041 if ( head < 0 )
00042 head = maxDelay - 1;
00043 }
00044 }
00045 else
00046 for( int i = 0; i<count; i++ )
00047 out[i] = in[i];
00048 }
00049 };