Fonepole() coeff affecting pitch of delay

TL; DR
I am hacking together a sketch based on the Delay in the MultiEffect Example for Daisy Pod.

  1. How is the coeff of fonepole working? It seems that the coeff seems to be causing unwanted pitch shifting. But I feel like a realtime calculation of coeff is what I might need.

  2. What is the role of variable m in this sketch?

Any help in understanding these would be very helpful!

After looking at fonepole in the dsp.h file in the DaisyDuino src and seeing that coeff = 1.0 / (time * sample_rate) , I successfully got rid of some adc noise by using fonepole(currentDelay, delayTarget, 1.0f/MAX_DELAY); however I notice now that the pitch of the delayed audio is shifted (presumably based on the relation of knob1 value to the MAX_DELAY.

Here is the sketch if you feel like running it to see what I mean. I commented the lines where I’m having trouble. Oh, and Thank You!

#include "DaisyDuino.h"

// Set max delay time to 0.75 of samplerate.
#define MAX_DELAY (48000 * 40)
#define DEL 1


static DaisyHardware pod;

static DelayLine<float, MAX_DELAY> DSY_SDRAM_BSS dell;
static DelayLine<float, MAX_DELAY> DSY_SDRAM_BSS delr;
int mode = DEL;

float sample_rate;
float currentDelay, feedback, delayTarget, cutoff;


float drywet;

// Helper functions
void Controls();

void GetDelaySample(float &outl, float &outr, float inl, float inr);

void AudioCallback(float **in, float **out, size_t size) {
  float outl, outr, inl, inr;

  Controls();

  // audio
  for (size_t i = 0; i < size; i ++) {
    inl = in[0][i];
    inr = in[1][i];

    GetDelaySample(outl, outr, inl, inr);

    // left out
    out[0][i] = outl;

    // right out
    out[1][i] = outr;
  }
}

void setup() {
  // Inits and sample rate
  pod = DAISY.init(DAISY_POD, AUDIO_SR_48K);
  sample_rate = DAISY.get_samplerate();

  dell.Init();
  delr.Init();

  // delay parameters
  currentDelay = delayTarget = sample_rate * 0.75f;

  dell.SetDelay(currentDelay);
  delr.SetDelay(currentDelay);

  // start callback
  DAISY.begin(AudioCallback);
}

void loop() {}

void UpdateKnobs(float &k1, float &k2) {
  k1 = analogRead(PIN_POD_POT_1) / 1023.f;
  k2 = analogRead(PIN_POD_POT_2) / 1023.f;

  float m = (float)MAX_DELAY - .05 * sample_rate; // >>>>> Not sure what the role of 'm' is in the sketch

  delayTarget = k1 * m + .05 * sample_rate;
  feedback = .17;

  Serial.println("current");
  Serial.println(currentDelay);
  Serial.println("target");
  Serial.println(delayTarget);

}

void UpdateLeds(float k1, float k2) {
  pod.leds[0].Set(mode == 2, mode == 1, mode == 0 || mode == 2);
  pod.leds[1].Set(mode == 2, mode == 1, mode == 0 || mode == 2);
}

void Controls() {
  float k1, k2;
  delayTarget = feedback = drywet = 0;
  pod.DebounceControls();
  UpdateKnobs(k1, k2);
  UpdateLeds(k1, k2);
}


void GetDelaySample(float &outl, float &outr, float inl, float inr) {

  // fonepole(currentDelay, delayTarget, .00007f);                     // This was the original line which doesnt filter out adc noise
  fonepole(currentDelay, delayTarget, 1.0f / MAX_DELAY);           // NOTE: this gets rid of noise but affects pitch and adds a bit of delay

  delr.SetDelay(currentDelay);
  dell.SetDelay(currentDelay);
  outl = dell.Read();
  outr = delr.Read();

  dell.Write((.01 * outl) + inl);                         // cutting feedback amount to .01
  outl = (feedback * outl) + ((1.0f - feedback) * inl);   // monitor input
  //  outl = outl; // no input monitoring

  delr.Write((.01 * outr) + inr);
  outr = (feedback * outr) + ((1.0f - feedback) * inr); // monitor input
  //  outr = outr; // no input monitoring

}
`