From 039dcf2932be1db3addd7c12c4e13165feb72bcc Mon Sep 17 00:00:00 2001 From: beserge Date: Thu, 13 Aug 2020 14:33:44 -0400 Subject: [PATCH 1/7] simple template --- petal/FrequencyShifter/FrequencyShifter.cpp | 28 +++++++++++++++++++++ petal/FrequencyShifter/Makefile | 14 +++++++++++ 2 files changed, 42 insertions(+) create mode 100644 petal/FrequencyShifter/FrequencyShifter.cpp create mode 100644 petal/FrequencyShifter/Makefile diff --git a/petal/FrequencyShifter/FrequencyShifter.cpp b/petal/FrequencyShifter/FrequencyShifter.cpp new file mode 100644 index 000000000..b434c04d3 --- /dev/null +++ b/petal/FrequencyShifter/FrequencyShifter.cpp @@ -0,0 +1,28 @@ +#include "daisy_petal.h" +#include "daisysp.h" + +using namespace daisy; +using namespace daisysp; + +DaisyPetal hw; + +void callback(float **in, float **out, size_t size) +{ + for (size_t i = 0; i < size; i++) + { + } +} + +int main(void) +{ + float samplerate; + + hw.Init(); + samplerate = hw.AudioSampleRate(); + + hw.StartAdc(); + hw.StartAudio(callback); + while(1) + { + } +} diff --git a/petal/FrequencyShifter/Makefile b/petal/FrequencyShifter/Makefile new file mode 100644 index 000000000..3c7cb1171 --- /dev/null +++ b/petal/FrequencyShifter/Makefile @@ -0,0 +1,14 @@ +# Project Name +TARGET = FrequencyShifter + +# Sources +CPP_SOURCES = FrequencyShifter.cpp + +# Library Locations +LIBDAISY_DIR = ../../libdaisy +DAISYSP_DIR = ../../DaisySP + +# Core location, and generic Makefile. +SYSTEM_FILES_DIR = $(LIBDAISY_DIR)/core +include $(SYSTEM_FILES_DIR)/Makefile + From 9f643bf33e3f6fe1e92650fd8e401fb5d9abd8e8 Mon Sep 17 00:00:00 2001 From: beserge Date: Thu, 13 Aug 2020 17:10:02 -0400 Subject: [PATCH 2/7] first attemp --- petal/FrequencyShifter/FrequencyShifter.cpp | 66 ++++++++++++++++++--- petal/FrequencyShifter/README.md | 14 +++++ 2 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 petal/FrequencyShifter/README.md diff --git a/petal/FrequencyShifter/FrequencyShifter.cpp b/petal/FrequencyShifter/FrequencyShifter.cpp index b434c04d3..0200d50e2 100644 --- a/petal/FrequencyShifter/FrequencyShifter.cpp +++ b/petal/FrequencyShifter/FrequencyShifter.cpp @@ -4,25 +4,75 @@ using namespace daisy; using namespace daisysp; -DaisyPetal hw; +DaisyPetal petal; +PitchShifter ps; +Oscillator lfo; +CrossFade fader; -void callback(float **in, float **out, size_t size) +bool bypassOn; + +Parameter lfoFreqParam; +Parameter shiftTransParam; + +void UpdateControls(); + +void AudioCallback(float **in, float **out, size_t size) { + UpdateControls(); + for (size_t i = 0; i < size; i++) { - } + float inf = in[0][i]; + float process = ps.Process(in[0][i]); + out[0][i] = out[1][i] = fader.Process(inf, process); + } } int main(void) { float samplerate; + petal.Init(); + samplerate = petal.AudioSampleRate(); + + lfoFreqParam.Init(petal.knob[0], .1, 20, Parameter::LOGARITHMIC); + shiftTransParam.Init(petal.knob[2], -12, 12, Parameter::LINEAR); + + lfo.Init(petal.AudioCallbackRate()); + lfo.SetAmp(1); + lfo.SetWaveform(Oscillator::WAVE_SIN); - hw.Init(); - samplerate = hw.AudioSampleRate(); + ps.Init(samplerate); - hw.StartAdc(); - hw.StartAudio(callback); + fader.Init(); + + petal.StartAdc(); + petal.StartAudio(AudioCallback); while(1) { - } + petal.SetFootswitchLed((DaisyPetal::FootswitchLed)0, bypassOn); + dsy_system_delay(6); + } } + +void UpdateControls() +{ + petal.UpdateAnalogControls(); + petal.DebounceControls(); + + //knobs + lfo.SetFreq(lfoFreqParam.Process()); + lfo.SetAmp(petal.knob[1].Process()); + ps.SetTransposition(shiftTransParam.Process() + (lfo.Process()) * 12); + + fader.SetPos(petal.knob[3].Process()); + if (bypassOn) + { + fader.SetPos(0); + } + + //bypass switch + if (petal.switches[0].RisingEdge()) + { + bypassOn = !bypassOn; + } +} \ No newline at end of file diff --git a/petal/FrequencyShifter/README.md b/petal/FrequencyShifter/README.md new file mode 100644 index 000000000..574df438e --- /dev/null +++ b/petal/FrequencyShifter/README.md @@ -0,0 +1,14 @@ +## Description +Frequency shifter. Built in LFO for vibrato type effect. + +## Controls + +| Control | Description | Comment | +| --- | --- | --- | +| Knob 1 | Lfo Frequency | .1 Hz to 20 Hz | +| Knob 2 | Lfo Amplitude | 0 to 1 octaves bipolar | +| Knob 3 | Pitchshifter Transposition | -12 to 12 semitones | +| Knob 4 | Dry/Wet | | +| Footswitch 1 | Bypass | | +| In 1 | Pitchshift In | | +| Out 1 2 | Pitchshift Out | | From 196f106516152f60a72bf268381bf9d57bc05d27 Mon Sep 17 00:00:00 2001 From: beserge Date: Fri, 14 Aug 2020 18:10:43 -0400 Subject: [PATCH 3/7] moved lfo to audio callback for smoothness --- petal/FrequencyShifter/FrequencyShifter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/petal/FrequencyShifter/FrequencyShifter.cpp b/petal/FrequencyShifter/FrequencyShifter.cpp index 0200d50e2..25436486e 100644 --- a/petal/FrequencyShifter/FrequencyShifter.cpp +++ b/petal/FrequencyShifter/FrequencyShifter.cpp @@ -22,6 +22,8 @@ void AudioCallback(float **in, float **out, size_t size) for (size_t i = 0; i < size; i++) { + ps.SetTransposition(shiftTransParam.Process() + (lfo.Process()) * 12); + float inf = in[0][i]; float process = ps.Process(in[0][i]); out[0][i] = out[1][i] = fader.Process(inf, process); @@ -37,7 +39,7 @@ int main(void) lfoFreqParam.Init(petal.knob[0], .1, 20, Parameter::LOGARITHMIC); shiftTransParam.Init(petal.knob[2], -12, 12, Parameter::LINEAR); - lfo.Init(petal.AudioCallbackRate()); + lfo.Init(samplerate); lfo.SetAmp(1); lfo.SetWaveform(Oscillator::WAVE_SIN); @@ -62,8 +64,7 @@ void UpdateControls() //knobs lfo.SetFreq(lfoFreqParam.Process()); lfo.SetAmp(petal.knob[1].Process()); - ps.SetTransposition(shiftTransParam.Process() + (lfo.Process()) * 12); - + fader.SetPos(petal.knob[3].Process()); if (bypassOn) { From 832d52552d7b20fb08daeba24844499cd9507567 Mon Sep 17 00:00:00 2001 From: beserge Date: Wed, 19 Aug 2020 11:22:17 -0400 Subject: [PATCH 4/7] control changes --- petal/FrequencyShifter/FrequencyShifter.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/petal/FrequencyShifter/FrequencyShifter.cpp b/petal/FrequencyShifter/FrequencyShifter.cpp index 25436486e..4101a4a72 100644 --- a/petal/FrequencyShifter/FrequencyShifter.cpp +++ b/petal/FrequencyShifter/FrequencyShifter.cpp @@ -11,8 +11,9 @@ CrossFade fader; bool bypassOn; -Parameter lfoFreqParam; -Parameter shiftTransParam; +Parameter lfoFreqParam, lfoAmpParam; +Parameter shiftTransParam, shiftDelParam; +Parameter faderPosParam; void UpdateControls(); @@ -22,7 +23,7 @@ void AudioCallback(float **in, float **out, size_t size) for (size_t i = 0; i < size; i++) { - ps.SetTransposition(shiftTransParam.Process() + (lfo.Process()) * 12); + ps.SetTransposition(shiftTransParam.Value() + (lfo.Process()) * 12); float inf = in[0][i]; float process = ps.Process(in[0][i]); @@ -36,8 +37,11 @@ int main(void) petal.Init(); samplerate = petal.AudioSampleRate(); - lfoFreqParam.Init(petal.knob[0], .1, 20, Parameter::LOGARITHMIC); + lfoFreqParam.Init(petal.knob[0], .1, 20, Parameter::EXPONENTIAL); + lfoAmpParam.Init(petal.knob[1], 0, 10, Parameter::LINEAR); shiftTransParam.Init(petal.knob[2], -12, 12, Parameter::LINEAR); + shiftDelParam.Init(petal.knob[3], 100, 16000, Parameter::LOGARITHMIC); + faderPosParam.Init(petal.knob[4], 0, 1, Parameter::LINEAR); lfo.Init(samplerate); lfo.SetAmp(1); @@ -52,6 +56,7 @@ int main(void) while(1) { petal.SetFootswitchLed((DaisyPetal::FootswitchLed)0, bypassOn); + petal.UpdateLeds(); dsy_system_delay(6); } } @@ -63,9 +68,11 @@ void UpdateControls() //knobs lfo.SetFreq(lfoFreqParam.Process()); - lfo.SetAmp(petal.knob[1].Process()); + lfo.SetAmp(lfoAmpParam.Process()); + ps.SetDelSize(shiftDelParam); + shiftTransParam.Process() - fader.SetPos(petal.knob[3].Process()); + fader.SetPos(faderPosParam.Process()); if (bypassOn) { fader.SetPos(0); From 6d0909601fa2524c0696ecfd44f50b34a6e16655 Mon Sep 17 00:00:00 2001 From: beserge Date: Mon, 9 Nov 2020 12:56:33 -0500 Subject: [PATCH 5/7] leds, controls, stereo --- petal/FrequencyShifter/FrequencyShifter.cpp | 119 ++++++++++++-------- 1 file changed, 70 insertions(+), 49 deletions(-) diff --git a/petal/FrequencyShifter/FrequencyShifter.cpp b/petal/FrequencyShifter/FrequencyShifter.cpp index 4101a4a72..8c9dc258f 100644 --- a/petal/FrequencyShifter/FrequencyShifter.cpp +++ b/petal/FrequencyShifter/FrequencyShifter.cpp @@ -5,7 +5,7 @@ using namespace daisy; using namespace daisysp; DaisyPetal petal; -PitchShifter ps; +PitchShifter psl ,psr; Oscillator lfo; CrossFade fader; @@ -19,16 +19,22 @@ void UpdateControls(); void AudioCallback(float **in, float **out, size_t size) { - UpdateControls(); - - for (size_t i = 0; i < size; i++) - { - ps.SetTransposition(shiftTransParam.Value() + (lfo.Process()) * 12); - - float inf = in[0][i]; - float process = ps.Process(in[0][i]); - out[0][i] = out[1][i] = fader.Process(inf, process); - } + UpdateControls(); + + for (size_t i = 0; i < size; i++) + { + psl.SetTransposition(shiftTransParam.Value() + lfo.Process()); + psr.SetTransposition(shiftTransParam.Value() + lfo.Process()); + + float inl = in[0][i]; + float processl = psl.Process(inl); + + float inr = in[1][i]; + float processr = psr.Process(inr); + + out[0][i] = fader.Process(inl, processl); + out[1][i] = fader.Process(inr, processr); + } } int main(void) @@ -37,50 +43,65 @@ int main(void) petal.Init(); samplerate = petal.AudioSampleRate(); - lfoFreqParam.Init(petal.knob[0], .1, 20, Parameter::EXPONENTIAL); - lfoAmpParam.Init(petal.knob[1], 0, 10, Parameter::LINEAR); - shiftTransParam.Init(petal.knob[2], -12, 12, Parameter::LINEAR); - shiftDelParam.Init(petal.knob[3], 100, 16000, Parameter::LOGARITHMIC); - faderPosParam.Init(petal.knob[4], 0, 1, Parameter::LINEAR); - - lfo.Init(samplerate); - lfo.SetAmp(1); - lfo.SetWaveform(Oscillator::WAVE_SIN); - - ps.Init(samplerate); - - fader.Init(); - + lfoFreqParam.Init(petal.knob[0], .1, 20, Parameter::EXPONENTIAL); + lfoAmpParam.Init(petal.knob[1], 0, 12, Parameter::EXPONENTIAL); + shiftTransParam.Init(petal.knob[2], -12, 12, Parameter::LINEAR); + shiftDelParam.Init(petal.knob[3], 0, (SHIFT_BUFFER_SIZE - 256), Parameter::LINEAR); + faderPosParam.Init(petal.knob[4], 0, 1, Parameter::LINEAR); + + lfo.Init(samplerate); + lfo.SetWaveform(Oscillator::WAVE_SIN); + + psl.Init(samplerate); + psr.Init(samplerate); + + fader.Init(); + petal.StartAdc(); petal.StartAudio(AudioCallback); + + int i = 0; while(1) { - petal.SetFootswitchLed((DaisyPetal::FootswitchLed)0, bypassOn); - petal.UpdateLeds(); - dsy_system_delay(6); - } + petal.ClearLeds(); + + petal.SetFootswitchLed((DaisyPetal::FootswitchLed)0, !bypassOn); + + petal.SetRingLed((DaisyPetal::RingLed)i , 0, 1, 0); + i++; + i %= 8; + + petal.UpdateLeds(); + dsy_system_delay(60); + } } +float delsize; + void UpdateControls() { - petal.UpdateAnalogControls(); - petal.DebounceControls(); - - //knobs - lfo.SetFreq(lfoFreqParam.Process()); - lfo.SetAmp(lfoAmpParam.Process()); - ps.SetDelSize(shiftDelParam); - shiftTransParam.Process() - - fader.SetPos(faderPosParam.Process()); - if (bypassOn) - { - fader.SetPos(0); - } + petal.UpdateAnalogControls(); + petal.DebounceControls(); + + //knobs + lfo.SetFreq(lfoFreqParam.Process()); + lfo.SetAmp(lfoAmpParam.Process()); + + fonepole(delsize, 256 + shiftDelParam.Process(), .001f); + psl.SetDelSize(delsize); + psr.SetDelSize(delsize); + + shiftTransParam.Process(); + + fader.SetPos(faderPosParam.Process()); + if (bypassOn) + { + fader.SetPos(0); + } - //bypass switch - if (petal.switches[0].RisingEdge()) - { - bypassOn = !bypassOn; - } -} \ No newline at end of file + //bypass switch + if (petal.switches[0].RisingEdge()) + { + bypassOn = !bypassOn; + } +} From 7919a0f0786949d1a716b5f68524b11979aadf9e Mon Sep 17 00:00:00 2001 From: beserge Date: Tue, 10 Nov 2020 15:58:06 -0500 Subject: [PATCH 6/7] readme --- petal/FrequencyShifter/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/petal/FrequencyShifter/README.md b/petal/FrequencyShifter/README.md index 574df438e..ee18ec94b 100644 --- a/petal/FrequencyShifter/README.md +++ b/petal/FrequencyShifter/README.md @@ -8,7 +8,8 @@ Frequency shifter. Built in LFO for vibrato type effect. | Knob 1 | Lfo Frequency | .1 Hz to 20 Hz | | Knob 2 | Lfo Amplitude | 0 to 1 octaves bipolar | | Knob 3 | Pitchshifter Transposition | -12 to 12 semitones | -| Knob 4 | Dry/Wet | | -| Footswitch 1 | Bypass | | +| Knob 4 | | | +| Knob 5 | Dry/Wet | | +| Footswitch 1 | Bypass | LED On = Effect On | | In 1 | Pitchshift In | | | Out 1 2 | Pitchshift Out | | From 56362665345cd76d3205f9e43f168709cd1971d8 Mon Sep 17 00:00:00 2001 From: beserge Date: Mon, 16 Nov 2020 11:29:13 -0500 Subject: [PATCH 7/7] delsize crunch persists --- petal/FrequencyShifter/FrequencyShifter.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/petal/FrequencyShifter/FrequencyShifter.cpp b/petal/FrequencyShifter/FrequencyShifter.cpp index 8c9dc258f..2952dbccb 100644 --- a/petal/FrequencyShifter/FrequencyShifter.cpp +++ b/petal/FrequencyShifter/FrequencyShifter.cpp @@ -15,6 +15,9 @@ Parameter lfoFreqParam, lfoAmpParam; Parameter shiftTransParam, shiftDelParam; Parameter faderPosParam; +float trans, transTarget; +float delsize, delsizeTarget; + void UpdateControls(); void AudioCallback(float **in, float **out, size_t size) @@ -23,8 +26,14 @@ void AudioCallback(float **in, float **out, size_t size) for (size_t i = 0; i < size; i++) { - psl.SetTransposition(shiftTransParam.Value() + lfo.Process()); - psr.SetTransposition(shiftTransParam.Value() + lfo.Process()); + fonepole(trans, transTarget, .0005f); + psl.SetTransposition(trans + lfo.Process()); + psr.SetTransposition(trans + lfo.Process()); + + fonepole(delsize, delsizeTarget, .001f); + psl.SetDelSize(delsize); + psr.SetDelSize(delsize); + float inl = in[0][i]; float processl = psl.Process(inl); @@ -76,7 +85,6 @@ int main(void) } } -float delsize; void UpdateControls() { @@ -87,11 +95,9 @@ void UpdateControls() lfo.SetFreq(lfoFreqParam.Process()); lfo.SetAmp(lfoAmpParam.Process()); - fonepole(delsize, 256 + shiftDelParam.Process(), .001f); - psl.SetDelSize(delsize); - psr.SetDelSize(delsize); + delsizeTarget = 256 + shiftDelParam.Process(); - shiftTransParam.Process(); + transTarget = shiftTransParam.Process(); fader.SetPos(faderPosParam.Process()); if (bypassOn)