Browse Source

Correct the calculation of delay_rate_incr

dds
Pete (El Supremo) 10 years ago
parent
commit
2f0383f501
1 changed files with 15 additions and 17 deletions
  1. +15
    -17
      Audio.cpp

+ 15
- 17
Audio.cpp View File

/******************************************************************/ /******************************************************************/
// A u d i o E f f e c t F l a n g e // A u d i o E f f e c t F l a n g e
// Written by Pete (El Supremo) Jan 2014 // Written by Pete (El Supremo) Jan 2014
// 140207 - fix calculation of delay_rate_incr which is expressed as
// a fraction of 2*PI
// 140207 - cosmetic fix to begin()


// circular addressing indices for left and right channels // circular addressing indices for left and right channels
short AudioEffectFlange::l_circ_idx; short AudioEffectFlange::l_circ_idx;
boolean all_ok = true; boolean all_ok = true;


if(0) { if(0) {
Serial.print("AudioEffectFlange.begin(offset = ");
Serial.print(delay_offset);
Serial.print(", depth = ");
Serial.print(d_depth);
Serial.print(", rate = ");
Serial.print(delay_rate,3);
Serial.println(")");
Serial.print(" FLANGE_DELAY_LENGTH = ");
Serial.println(d_length);
Serial.print("AudioEffectFlange.begin(offset = ");
Serial.print(delay_offset);
Serial.print(", depth = ");
Serial.print(d_depth);
Serial.print(", rate = ");
Serial.print(delay_rate,3);
Serial.println(")");
Serial.print(" FLANGE_DELAY_LENGTH = ");
Serial.println(d_length);
} }

delay_length = d_length/2; delay_length = d_length/2;
l_delayline = delayline; l_delayline = delayline;
r_delayline = delayline + delay_length; r_delayline = delayline + delay_length;
r_delay_rate_index = 0; r_delay_rate_index = 0;
l_circ_idx = 0; l_circ_idx = 0;
r_circ_idx = 0; r_circ_idx = 0;
delay_rate_incr = 2*PI*delay_rate/44100.*2147483648.;
delay_rate_incr = delay_rate/44100.*2147483648.;
//Serial.println(delay_rate_incr,HEX); //Serial.println(delay_rate_incr,HEX);


delay_offset_idx = delay_offset; delay_offset_idx = delay_offset;
delay_depth = d_depth; delay_depth = d_depth;


delay_rate_incr = 2*PI*delay_rate/44100.*2147483648.;
delay_rate_incr = delay_rate/44100.*2147483648.;
delay_offset_idx = delay_offset; delay_offset_idx = delay_offset;
// Allow the passthru code to go through // Allow the passthru code to go through
frac = (l_delay_rate_index >> 1) &0x7fff; frac = (l_delay_rate_index >> 1) &0x7fff;
frac = (( (int)(l_delayline[idx1] - l_delayline[idx])*frac) >> 15); frac = (( (int)(l_delayline[idx1] - l_delayline[idx])*frac) >> 15);


//frac = 0;
*bp++ = (l_delayline[l_circ_idx] *bp++ = (l_delayline[l_circ_idx]
+ l_delayline[idx] + frac
// + l_delayline[(l_circ_idx + delay_length/2) % delay_length]
+ l_delayline[idx] + frac
)/2; )/2;


l_delay_rate_index += delay_rate_incr; l_delay_rate_index += delay_rate_incr;
frac = (r_delay_rate_index >> 1) &0x7fff; frac = (r_delay_rate_index >> 1) &0x7fff;
frac = (( (int)(r_delayline[idx1] - r_delayline[idx])*frac) >> 15); frac = (( (int)(r_delayline[idx1] - r_delayline[idx])*frac) >> 15);


//frac = 0;

*bp++ = (r_delayline[r_circ_idx] *bp++ = (r_delayline[r_circ_idx]
+ r_delayline[idx] + frac + r_delayline[idx] + frac
)/2; )/2;

Loading…
Cancel
Save