Browse Source

Merge pull request #9 from el-supremo/master

Cosmetic fixes to chorus and flange examples and synth_tonesweep (ignore AudioSynthToneSweep changes)
dds
Paul Stoffregen 11 years ago
parent
commit
d086aeed23
4 changed files with 46 additions and 238 deletions
  1. +10
    -108
      examples/effect_chorus/effect_chorus.ino
  2. +33
    -126
      examples/effect_flange/effect_flange.ino
  3. +2
    -3
      synth_tonesweep.cpp
  4. +1
    -1
      synth_tonesweep.h

+ 10
- 108
examples/effect_chorus/effect_chorus.ino View File

/* /*
PROC/MEM 9/4 PROC/MEM 9/4
Modify filter_test_f to try out a chorus effect.
TODO:



140203
o
I have mixed up the names "chorus" and flange". The sketches named
chorus have, up to version 'm', actually implemented a flanger.
From version 'o' onwards the sketches named chorus will implement
a real chorus effect and flange will do a flanging effect.

n only changed the effect parameters
m

140201
l - found the problem at last using my_flange_cd_usd_c
YES! Way back when I found I hadn't been using d_depth. Now I
have just discovered that I haven't been using delay_offset!!!!!
140201
k
interpolation doesn't remove the ticking
140131
j
>>> The lower the frequency, the less ticking.
- try interpolation
140201
- got this restored to the way it was last night
and then reinstated the changes. I had a couple of
changes to the right channel that were incorrect or
weren't carried over from the left channel changes
i
- don't know why but this version seems to have more "presence"
than previous versions.
The presence occurred when "sign = 1" was put in front of the left.
It essentially makes it a passthrough.
If both have "sign=1" then it is identical to passthrough
Ticking is still not fixed
h
- add sign reversal. It seems to make audio much clearer
BUT it hasn't got rid of the ticking noise
g
- I wasn't even using delay_depth!!!!
140131
f
- added code to print the processor and memory usage every 5 seconds
NOW the problem is to try to remove the ticking

e
FOUND the problem with the right channel. It was also in the left channel
but the placement of the delay line arrays made it more noticeable in the
right channel. I was not calculating idx properly. In particular, the
resuling index could be negative.

I have shortened the delay line to only 2*AUDIO_BLOCK_SAMPLES

- removed redundancies in the update code. rewrite the block
instead of getting a new one
Haven't solved the noise in the right channel yet.
Tried duplicating right channel code to left but noise stays on the right

140130
d
The noise stays in the right channel even if it is calculated first
Switching the L/R inputs doesn't switch the noise to the left channel
c
>> Now add a sinusoidal modulation to the offset
There's an awful noise in both channels but it is much louder in
the right channel. NOPE - it is ONLY in the right channel
but the audio does sound like it is working (sort of) except that it
is rather tinny. Maybe it needs to have the interpolation added.

b
- this works with clip16_6s.wav.
The original of this audio file was from http://www.donreiman.com/Chorus/Chorus.htm
I reworked it with Goldwave to make it a stereo WAV file
But with Rick Wakewan's Jane Seymour it seems to act more like
a high-pass filter.
a
- removed FIR stuff and changed the name to AudioEffectChorus
it's basically a blank template and compiles.

From: http://www.cs.cf.ac.uk/Dave/CM0268/PDF/10_CM0268_Audio_FX.pdf
about Comb filter effects
Effect Delay range (ms) Modulation
Resonator 0 - 20 None
Flanger 0 - 15 Sinusoidal (approx 1Hz)
Chorus 25 - 50 None
Echo >50 None
140219
p


FMI: FMI:
The audio board uses the following pins. The audio board uses the following pins.
// The delay line for left and right channels // The delay line for left and right channels
short delayline[CHORUS_DELAYLINE]; short delayline[CHORUS_DELAYLINE];


// If this pin is grounded the FIR filter is turned which
// makes just pass through the audio
// If this pin is grounded the chorus is turned off
// which makes it just pass through the audio
// Don't use any of the pins listed above // Don't use any of the pins listed above
#define PASSTHRU_PIN 1 #define PASSTHRU_PIN 1


AudioOutputI2S audioOutput; // audio shield: headphones & line-out AudioOutputI2S audioOutput; // audio shield: headphones & line-out


// Create Audio connections between the components // Create Audio connections between the components
// Both channels of the audio input go to the FIR filter
// Both channels of the audio input go to the chorus effect
AudioConnection c1(audioInput, 0, myEffect, 0); AudioConnection c1(audioInput, 0, myEffect, 0);
AudioConnection c2(audioInput, 1, myEffect, 1); AudioConnection c2(audioInput, 1, myEffect, 1);
// both channels from the FIR filter go to the audio output
// both channels from the chorus effect go to the audio output
AudioConnection c3(myEffect, 0, audioOutput, 0); AudioConnection c3(myEffect, 0, audioOutput, 0);
AudioConnection c4(myEffect, 1, audioOutput, 1); AudioConnection c4(myEffect, 1, audioOutput, 1);


} }


// Initialize the effect // Initialize the effect
// address of delayline
// total number of samples (left AND right) in the delay line
// number of voices in the chorus INCLUDING the original voice
// - address of delayline
// - total number of samples (left AND right) in the delay line
// - number of voices in the chorus INCLUDING the original voice
if(!myEffect.begin(delayline,CHORUS_DELAYLINE,n_chorus)) { if(!myEffect.begin(delayline,CHORUS_DELAYLINE,n_chorus)) {
Serial.println("AudioEffectChorus - begin failed"); Serial.println("AudioEffectChorus - begin failed");
while(1); while(1);
volume = n; volume = n;
audioShield.volume((float)n / 10.23); audioShield.volume((float)n / 10.23);
} }
if(1) {
if(0) {
if(millis() - last_time >= 5000) { if(millis() - last_time >= 5000) {
Serial.print("Proc = "); Serial.print("Proc = ");
Serial.print(AudioProcessorUsage()); Serial.print(AudioProcessorUsage());
} }


} }




+ 33
- 126
examples/effect_flange/effect_flange.ino View File

/* /*
Change the chorus code to produce a flange effect Change the chorus code to produce a flange effect

PROC/MEM 25/4
140204
d
- fixed the problem with user-supplied delay line

140203
c
140203
b
- when switching to/from passthru, keep the delay line filled
BUT to be effective must also fix up begin and add another
function to allow changing to/from passthru without
reinitialing everything.
I have mixed up the names "chorus" and flange". The sketches named
chorus have, up to version 'm', actually implemented a flanger.
From version 'o' onwards the sketches named chorus will implement
a real chorus effect and flange will do a flanging effect.

140202
a
Modify filter_test_f to try out a chorus effect

m + n only changed the effect parameters
-
140201
l - found the problem at last using my_flange_cd_usd_c
YES! Way back when I found I hadn't been using d_depth. Now I
have just discovered that I haven't been using delay_offset!!!!!
140201
k
interpolation doesn't remove the ticking
140131
j
>>> The lower the frequency, the less ticking.
- try interpolation
140201
- got this restored to the way it was last night
and then reinstated the changes. I had a couple of
changes to the right channel that were incorrect or
weren't carried over from the left channel changes
i
- don't know why but this version seems to have more "presence"
than previous versions.
The presence occurred when "sign = 1" was put in front of the left.
It essentially makes it a passthrough.
If both have "sign=1" then it is identical to passthrough
Ticking is still not fixed
h
- add sign reversal. It seems to make audio much clearer
BUT it hasn't got rid of the ticking noise
g
- I wasn't even using delay_depth!!!!
140131
f
- added code to print the processor and memory usage every 5 seconds
NOW the problem is to try to remove the ticking

140219
e e
FOUND the problem with the right channel. It was also in the left channel
but the placement of the delay line arrays made it more noticeable in the
right channel. I was not calculating idx properly. In particular, the
resuling index could be negative.

I have shortened the delay line to only 2*AUDIO_BLOCK_SAMPLES

- removed redundancies in the update code. rewrite the block
instead of getting a new one
Haven't solved the noise in the right channel yet.
Tried duplicating right channel code to left but noise stays on the right

140130
d
The noise stays in the right channel even if it is calculated first
Switching the L/R inputs doesn't switch the noise to the left channel
c
>> Now add a sinusoidal modulation to the offset
There's an awful noise in both channels but it is much louder in
the right channel. NOPE - it is ONLY in the right channel
but the audio does sound like it is working (sort of) except that it
is rather tinny. Maybe it needs to have the interpolation added.

b
- this works with clip16_6s.wav.
The original of this audio file was from http://www.donreiman.com/Chorus/Chorus.htm
I reworked it with Goldwave to make it a stereo WAV file
But with Rick Wakewan's Jane Seymour it seems to act more like
a high-pass filter.
a
- removed FIR stuff and changed the name to AudioEffectChorus
it's basically a blank template and compiles.

From: http://www.cs.cf.ac.uk/Dave/CM0268/PDF/10_CM0268_Audio_FX.pdf
about Comb filter effects
Effect Delay range (ms) Modulation
Resonator 0 - 20 None
Flanger 0 - 15 Sinusoidal (approx 1Hz)
Chorus 25 - 50 None
Echo >50 None


FMI: FMI:
The audio board uses the following pins. The audio board uses the following pins.
// The delay line for left and right channels // The delay line for left and right channels
short delayline[FLANGE_DELAYLINE]; short delayline[FLANGE_DELAYLINE];


// If this pin is grounded the FIR filter is turned which
// makes just pass through the audio
// If this pin is grounded the effect is turned off,
// which makes it just pass through the audio
// Don't use any of the pins listed above // Don't use any of the pins listed above
#define PASSTHRU_PIN 1 #define PASSTHRU_PIN 1


AudioOutputI2S audioOutput; // audio shield: headphones & line-out AudioOutputI2S audioOutput; // audio shield: headphones & line-out


// Create Audio connections between the components // Create Audio connections between the components
// Both channels of the audio input go to the FIR filter
// Both channels of the audio input go to the flange effect
AudioConnection c1(audioInput, 0, myEffect, 0); AudioConnection c1(audioInput, 0, myEffect, 0);
AudioConnection c2(audioInput, 1, myEffect, 1); AudioConnection c2(audioInput, 1, myEffect, 1);
// both channels from the FIR filter go to the audio output
// both channels from the flange effect go to the audio output
AudioConnection c3(myEffect, 0, audioOutput, 0); AudioConnection c3(myEffect, 0, audioOutput, 0);
AudioConnection c4(myEffect, 1, audioOutput, 1); AudioConnection c4(myEffect, 1, audioOutput, 1);


double s_freq = .0625; double s_freq = .0625;
*/ */


//12 - good with Eric Clapton Unplugged
/* /*
//12 - good with Eric Clapton Unplugged
int s_idx = 3*FLANGE_DELAY_LENGTH/4; int s_idx = 3*FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/8; int s_depth = FLANGE_DELAY_LENGTH/8;
double s_freq = .0625; double s_freq = .0625;
*/ */

/*
// Real flange effect! delay line is 2*
int s_idx = 2*FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/4;
double s_freq = 2;
*/

/* 2 -
int s_idx = 2*FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/8;
double s_freq = 4;
*/
/*
// 4
int s_idx = FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/4;
double s_freq = .25;
*/
// 4
int s_idx = FLANGE_DELAY_LENGTH/4; int s_idx = FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/4; int s_depth = FLANGE_DELAY_LENGTH/4;
double s_freq = .5; double s_freq = .5;

void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
} }


// Set up the flange effect // Set up the flange effect
// address of delayline
// total number of samples (left AND right) in the delay line
// Index (in samples) into the delay line for the added voice
// Depth of the flange effect
// frequency of the flange effect
// - address of delayline
// - total number of samples (left AND right) in the delay line
// - Index (in samples) into the delay line for the added voice
// - Depth of the flange effect
// - frequency of the flange effect
myEffect.begin(delayline,FLANGE_DELAYLINE,s_idx,s_depth,s_freq); myEffect.begin(delayline,FLANGE_DELAYLINE,s_idx,s_depth,s_freq);


// I want output on the line out too // I want output on the line out too
volume = n; volume = n;
audioShield.volume((float)n / 10.23); audioShield.volume((float)n / 10.23);
} }
if(1) {
if(0) {
if(millis() - last_time >= 5000) { if(millis() - last_time >= 5000) {
Serial.print("Proc = "); Serial.print("Proc = ");
Serial.print(AudioProcessorUsage()); Serial.print(AudioProcessorUsage());
b_passthru.update(); b_passthru.update();
// If the passthru button is pushed, save the current // If the passthru button is pushed, save the current
// filter index and then switch the filter to passthru
// filter index and then switch the effect to passthru
if(b_passthru.fallingEdge()) { if(b_passthru.fallingEdge()) {
myEffect.modify(DELAY_PASSTHRU,0,0); myEffect.modify(DELAY_PASSTHRU,0,0);
} }
} }


} }





+ 2
- 3
synth_tonesweep.cpp View File

#include "arm_math.h" #include "arm_math.h"




// TODO: this object should be renamed to AudioSynthToneSweep


/******************************************************************/ /******************************************************************/


// A u d i o T o n e S w e e p
// A u d i o S y n t h T o n e S w e e p
// Written by Pete (El Supremo) Feb 2014 // Written by Pete (El Supremo) Feb 2014




return(sweep_busy); return(sweep_busy);
} }


static int b_count = 0; // TODO: what's this for?


void AudioSynthToneSweep::update(void) void AudioSynthToneSweep::update(void)
{ {

+ 1
- 1
synth_tonesweep.h View File



#include "AudioStream.h" #include "AudioStream.h"


// A u d i o T o n e S w e e p
// A u d i o S y n t h T o n e S w e e p
// Written by Pete (El Supremo) Feb 2014 // Written by Pete (El Supremo) Feb 2014


class AudioSynthToneSweep : public AudioStream class AudioSynthToneSweep : public AudioStream

Loading…
Cancel
Save