Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minimal pitch-shifting code demo, based on @quentintopper's multi-effects code from this thread: https://forum.electro-smith.com/t/basic-multi-effect-pedal/441
#include "daisy_petal.h"
#include "daisysp.h"
using namespace daisy;
using namespace daisysp;
static DaisyPetal hardware;
static int32_t pitchShiftAmount = 12;
static PitchShifter DSY_SDRAM_BSS pitchShifter;
static CrossFade pitchCrossfade;
void callback(float *in, float *out, size_t size) {
float shifted;
for (size_t i = 0; i < size; i += 2) {
shifted = pitchShifter.Process(in[i]);
out[i] = pitchCrossfade.Process(in[i], shifted);
}
}
int main(void) {
float samplerate;
hardware.Init();
samplerate = hardware.AudioSampleRate();
pitchShifter.Init(samplerate);
pitchShifter.SetTransposition((float) pitchShiftAmount);
pitchCrossfade.Init(CROSSFADE_CPOW);
hardware.StartAdc();
hardware.StartAudio(callback);
while (1) {
dsy_system_delay(10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment