Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Help with delay effect

  1. #1

    Help with delay effect

    Hi everyone,
    I am trying to create a simple delay effect on a signal
    however I am not getting a clean delay sound but rather
    some kind of white noise instead of the delay. Can anyone reproduce this ?
    There does not seem to be a hardware problem since I can compile
    and listen to the examples just fine. There seems to be some kind
    of clipping or overloading in my code but I cannot figure out where.
    Any help would be appreciated.

    Here's the code, you have to attach a button on pin 15 (A1)


    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    #include <Bounce.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveform       waveform1;      //xy=293,163
    AudioMixer4              mixer2;         //xy=468,194
    AudioSynthWaveformDc     dc1;            //xy=538,376
    AudioEffectEnvelope      envelope1;      //xy=707,215
    AudioEffectMultiply      multiply1;      //xy=741,351
    AudioEffectDelay         delay1;         //xy=866,495
    AudioMixer4              mixer1;         //xy=876,280
    AudioOutputI2S           i2s1;           //xy=1205,219
    AudioConnection          patchCord1(waveform1, 0, mixer2, 0);
    AudioConnection          patchCord2(mixer2, envelope1);
    AudioConnection          patchCord3(dc1, 0, multiply1, 1);
    AudioConnection          patchCord4(envelope1, 0, mixer1, 0);
    AudioConnection          patchCord5(multiply1, 0, mixer1, 1);
    AudioConnection          patchCord6(delay1, 0, multiply1, 0);
    AudioConnection          patchCord7(mixer1, delay1);
    AudioConnection          patchCord8(mixer1, 0, i2s1, 0);
    AudioConnection          patchCord9(mixer1, 0, i2s1, 1);
    AudioControlSGTL5000     sgtl5000_1;     //xy=368,724
    // GUItool: end automatically generated code
    
    Bounce button0=Bounce(15,15);
    
    void setup() {
      AudioMemory(20);
    
      waveform1.begin(0.2,660, WAVEFORM_TRIANGLE);
    
      mixer1.gain(0,0.3);
      mixer1.gain(1,0.6);
      mixer2.gain(0,1);
    
      pinMode(15, INPUT_PULLUP);
      button0.update();
    
      Serial.begin(9600);
    
      dc1.amplitude(0.8);
      delay1.delay(0,300);
    
      envelope1.delay(2);
      envelope1.attack(9.2);
      envelope1.hold(2.1);
      envelope1.decay(31.4);
      envelope1.sustain(0.6);
      envelope1.release(84.5);
    
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.5);
    
    }
    
    void loop() {
      button0.update();
      if (button0.fallingEdge()) {
        Serial.println("Button (pin 0) Press");
        envelope1.noteOn();
      }
      if (button0.risingEdge()) {
        Serial.println("Button (pin 0) Release");
        envelope1.noteOff();
      }
    }
    
    float map(float x, float in_min, float in_max, float out_min, float out_max)
    {
      return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
    }
    Click image for larger version. 

Name:	Capture.JPG 
Views:	72 
Size:	33.1 KB 
ID:	6282

  2. #2
    ...Ok, found it : The problem was in AudioMemory(20)
    I should have allocated more memory (around 100 seems fine)
    hope this helps someone in the same situation

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,922
    Oh, yeah, you need memory for the delay to work.

    100 might be cutting it very close. Each block gives you 2.9 ms. So 100 is only about 290 ms of data storage.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •