-
-
Save mattgillooly/d3449db96a1e363658d6135c3c620025 to your computer and use it in GitHub Desktop.
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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