diff --git a/dep/DaisySP/Source/Effects/chorus.cpp b/dep/DaisySP/Source/Effects/chorus.cpp index d0031e9..f9cecc7 100644 --- a/dep/DaisySP/Source/Effects/chorus.cpp +++ b/dep/DaisySP/Source/Effects/chorus.cpp @@ -4,12 +4,17 @@ using namespace daisysp; +#define DSY_SDRAM_BSS __attribute__((section(".sdram_bss"))) +#define DSY_BUFFER_MAX_SIZE 2400 + +float DSY_SDRAM_BSS ChorusBuffer[DSY_BUFFER_MAX_SIZE]; + //ChorusEngine stuff void ChorusEngine::Init(float sample_rate) { sample_rate_ = sample_rate; - del_.Init(); + del_.Init(ChorusBuffer, DSY_BUFFER_MAX_SIZE); lfo_amp_ = 0.f; feedback_ = .2f; SetDelay(.75); diff --git a/dep/DaisySP/Source/Effects/chorus.h b/dep/DaisySP/Source/Effects/chorus.h index 7e36492..6e63c0f 100644 --- a/dep/DaisySP/Source/Effects/chorus.h +++ b/dep/DaisySP/Source/Effects/chorus.h @@ -57,8 +57,6 @@ class ChorusEngine private: float sample_rate_; - static constexpr int32_t kDelayLength - = 2400; // 50 ms at 48kHz = .05 * 48000 //triangle lfos float lfo_phase_; @@ -69,7 +67,7 @@ class ChorusEngine float delay_; - DelayLine del_; + DelayLine del_; float ProcessLfo(); }; diff --git a/dep/DaisySP/Source/Effects/flanger.cpp b/dep/DaisySP/Source/Effects/flanger.cpp index 7b3206e..8fc8f45 100644 --- a/dep/DaisySP/Source/Effects/flanger.cpp +++ b/dep/DaisySP/Source/Effects/flanger.cpp @@ -4,13 +4,19 @@ using namespace daisysp; + +#define DSY_SDRAM_BSS __attribute__((section(".sdram_bss"))) +#define DSY_BUFFER_MAX_SIZE 960 + +float DSY_SDRAM_BSS FlangerBuffer[DSY_BUFFER_MAX_SIZE]; + void Flanger::Init(float sample_rate) { sample_rate_ = sample_rate; SetFeedback(.2f); - del_.Init(); + del_.Init(FlangerBuffer, DSY_BUFFER_MAX_SIZE); lfo_amp_ = 0.f; SetDelay(.75); diff --git a/dep/DaisySP/Source/Effects/flanger.h b/dep/DaisySP/Source/Effects/flanger.h index f17eb47..1cebddb 100644 --- a/dep/DaisySP/Source/Effects/flanger.h +++ b/dep/DaisySP/Source/Effects/flanger.h @@ -55,7 +55,6 @@ class Flanger private: float sample_rate_; - static constexpr int32_t kDelayLength = 960; // 20 ms at 48kHz = .02 * 48000 float feedback_; @@ -66,7 +65,7 @@ class Flanger float delay_; - DelayLine del_; + DelayLine del_; float ProcessLfo(); }; diff --git a/dep/DaisySP/Source/Effects/phaser.cpp b/dep/DaisySP/Source/Effects/phaser.cpp index da9c2d5..8c0ec87 100644 --- a/dep/DaisySP/Source/Effects/phaser.cpp +++ b/dep/DaisySP/Source/Effects/phaser.cpp @@ -4,12 +4,18 @@ using namespace daisysp; + +#define DSY_SDRAM_BSS __attribute__((section(".sdram_bss"))) +#define DSY_BUFFER_MAX_SIZE 2400 + +float DSY_SDRAM_BSS PhaserBuffer[DSY_BUFFER_MAX_SIZE]; + //PhaserEngine stuff void PhaserEngine::Init(float sample_rate) { sample_rate_ = sample_rate; - del_.Init(); + del_.Init(PhaserBuffer, DSY_BUFFER_MAX_SIZE); lfo_amp_ = 0.f; feedback_ = .2f; SetFreq(200.f); diff --git a/dep/DaisySP/Source/Effects/phaser.h b/dep/DaisySP/Source/Effects/phaser.h index 20a6b63..f4c78a6 100644 --- a/dep/DaisySP/Source/Effects/phaser.h +++ b/dep/DaisySP/Source/Effects/phaser.h @@ -52,8 +52,6 @@ class PhaserEngine private: float sample_rate_; - static constexpr int32_t kDelayLength - = 2400; // 50 ms at 48kHz = .05 * 48000 //triangle lfo float lfo_phase_; @@ -68,7 +66,7 @@ class PhaserEngine float deltime_; float last_sample_; - DelayLine del_; + DelayLine del_; float ProcessLfo(); }; diff --git a/dep/DaisySP/Source/Effects/pitchshifter.h b/dep/DaisySP/Source/Effects/pitchshifter.h index e700014..0b6d295 100644 --- a/dep/DaisySP/Source/Effects/pitchshifter.h +++ b/dep/DaisySP/Source/Effects/pitchshifter.h @@ -18,6 +18,9 @@ //#define SHIFT_BUFFER_SIZE 8192 //#define SHIFT_BUFFER_SIZE 1024 +#define DSY_SDRAM_BSS __attribute__((section(".sdram_bss"))) +float DSY_SDRAM_BSS ShiftBuffer[SHIFT_BUFFER_SIZE]; + namespace daisysp { static inline uint32_t hash_xs32(uint32_t x) @@ -67,7 +70,7 @@ class PitchShifter mod_freq_ = 5.0f; SetSemitones(); gain_ = 0.0f; - d_.Init(); + d_.Init(ShiftBuffer, SHIFT_BUFFER_SIZE); phs_.Init(sr, 50, 0); shift_up_ = true; del_size_ = SHIFT_BUFFER_SIZE; @@ -167,7 +170,7 @@ class PitchShifter semitone_ratios_[i] = powf(2.0f, (float)i / 12); } } - typedef DelayLine ShiftDelay; + typedef DelayLine ShiftDelay; ShiftDelay d_; float pitch_shift_, mod_freq_; uint32_t del_size_; diff --git a/dep/DaisySP/Source/PhysicalModeling/KarplusString.cpp b/dep/DaisySP/Source/PhysicalModeling/KarplusString.cpp index 317e203..042501b 100644 --- a/dep/DaisySP/Source/PhysicalModeling/KarplusString.cpp +++ b/dep/DaisySP/Source/PhysicalModeling/KarplusString.cpp @@ -5,6 +5,12 @@ using namespace daisysp; +#define DSY_SDRAM_BSS __attribute__((section(".sdram_bss"))) +#define DSY_BUFFER_MAX_SIZE 1024 + +float DSY_SDRAM_BSS KarplusBuffer[DSY_BUFFER_MAX_SIZE]; +float DSY_SDRAM_BSS KarplusBuffer2[DSY_BUFFER_MAX_SIZE / 4]; + void String::Init(float sample_rate) { sample_rate_ = sample_rate; @@ -14,8 +20,8 @@ void String::Init(float sample_rate) brightness_ = .5f; damping_ = .5f; - string_.Init(); - stretch_.Init(); + string_.Init(KarplusBuffer, DSY_BUFFER_MAX_SIZE); + stretch_.Init(KarplusBuffer2, DSY_BUFFER_MAX_SIZE / 4); Reset(); SetFreq(440.f); diff --git a/dep/DaisySP/Source/PhysicalModeling/KarplusString.h b/dep/DaisySP/Source/PhysicalModeling/KarplusString.h index 1b76cd7..a2a5354 100644 --- a/dep/DaisySP/Source/PhysicalModeling/KarplusString.h +++ b/dep/DaisySP/Source/PhysicalModeling/KarplusString.h @@ -66,8 +66,6 @@ class String private: - static constexpr size_t kDelayLineSize = 1024; - enum StringNonLinearity { NON_LINEARITY_CURVED_BRIDGE, @@ -77,8 +75,8 @@ class String template float ProcessInternal(const float in); - DelayLine string_; - DelayLine stretch_; + DelayLine string_; + DelayLine stretch_; float frequency_, non_linearity_amount_, brightness_, damping_; diff --git a/dep/DaisySP/Source/Utility/delayline.h b/dep/DaisySP/Source/Utility/delayline.h index 6e79067..9029ba5 100644 --- a/dep/DaisySP/Source/Utility/delayline.h +++ b/dep/DaisySP/Source/Utility/delayline.h @@ -16,7 +16,7 @@ DelayLine del; By: shensley */ -template + class DelayLine { public: @@ -24,14 +24,20 @@ class DelayLine ~DelayLine() {} /** initializes the delay line by clearing the values within, and setting delay to 1 sample. */ - void Init() { Reset(); } + void Init(float *buffer, size_t buffer_size) + { + max_size = buffer_size; + line_ = buffer; + + Reset(); + } /** clears buffer, sets write ptr to 0, and delay to 1 sample. */ void Reset() { for(size_t i = 0; i < max_size; i++) { - line_[i] = T(0); + line_[i] = 0.0f; } write_ptr_ = 0; delay_ = 1; @@ -57,43 +63,43 @@ class DelayLine : max_size - 1; } - /** writes the sample of type T to the delay line, and advances the write ptr + /** writes the sample of type float to the delay line, and advances the write ptr */ - inline void Write(const T sample) + inline void Write(const float sample) { line_[write_ptr_] = sample; write_ptr_ = (write_ptr_ - 1 + max_size) % max_size; } - /** returns the next sample of type T in the delay line, interpolated if necessary. + /** returns the next sample of type float in the delay line, interpolated if necessary. */ - inline const T Read() const + inline const float Read() const { - T a = line_[(write_ptr_ + delay_) % max_size]; - T b = line_[(write_ptr_ + delay_ + 1) % max_size]; + float a = line_[(write_ptr_ + delay_) % max_size]; + float b = line_[(write_ptr_ + delay_ + 1) % max_size]; return a + (b - a) * frac_; } /** Read from a set location */ - inline const T Read(float delay) const + inline const float Read(float delay) const { int32_t delay_integral = static_cast(delay); float delay_fractional = delay - static_cast(delay_integral); - const T a = line_[(write_ptr_ + delay_integral) % max_size]; - const T b = line_[(write_ptr_ + delay_integral + 1) % max_size]; + const float a = line_[(write_ptr_ + delay_integral) % max_size]; + const float b = line_[(write_ptr_ + delay_integral + 1) % max_size]; return a + (b - a) * delay_fractional; } - inline const T ReadHermite(float delay) const + inline const float ReadHermite(float delay) const { int32_t delay_integral = static_cast(delay); float delay_fractional = delay - static_cast(delay_integral); int32_t t = (write_ptr_ + delay_integral + max_size); - const T xm1 = line_[(t - 1) % max_size]; - const T x0 = line_[(t) % max_size]; - const T x1 = line_[(t + 1) % max_size]; - const T x2 = line_[(t + 2) % max_size]; + const float xm1 = line_[(t - 1) % max_size]; + const float x0 = line_[(t) % max_size]; + const float x1 = line_[(t + 1) % max_size]; + const float x2 = line_[(t + 2) % max_size]; const float c = (x1 - xm1) * 0.5f; const float v = x0 - x1; const float w = c + v; @@ -103,10 +109,10 @@ class DelayLine return (((a * f) - b_neg) * f + c) * f + x0; } - inline const T Allpass(const T sample, size_t delay, const T coefficient) + inline const float Allpass(const float sample, size_t delay, const float coefficient) { - T read = line_[(write_ptr_ + delay) % max_size]; - T write = sample + coefficient * read; + float read = line_[(write_ptr_ + delay) % max_size]; + float write = sample + coefficient * read; Write(write); return -write * coefficient + read; } @@ -115,7 +121,8 @@ class DelayLine float frac_; size_t write_ptr_; size_t delay_; - T line_[max_size]; + size_t max_size; + float *line_; }; } // namespace daisysp #endif diff --git a/dep/SSD1351-Driver-Library/src/ssd1351.cpp b/dep/SSD1351-Driver-Library/src/ssd1351.cpp index 9a7cc3f..09a4430 100644 --- a/dep/SSD1351-Driver-Library/src/ssd1351.cpp +++ b/dep/SSD1351-Driver-Library/src/ssd1351.cpp @@ -1,7 +1,7 @@ #include "ssd1351.h" #include -DisplayRAM DRAM; +DisplayRAM __attribute__((section(".sdram_bss"))) DRAM; #define DRAM_16 DRAM.halfw #define DRAM_8 DRAM.byte diff --git a/src/config.h b/src/config.h index 669d406..3d97036 100644 --- a/src/config.h +++ b/src/config.h @@ -2,4 +2,4 @@ // https://github.com/snail23/ironpedal #define PROFILES 20 // 416 bytes per profile -#define VERSION "1.1.1" +#define VERSION "1.1.2" diff --git a/src/effects/delay.h b/src/effects/delay.h index 0f89839..48516e4 100644 --- a/src/effects/delay.h +++ b/src/effects/delay.h @@ -3,6 +3,8 @@ namespace Effect { + float DSY_SDRAM_BSS DelayBuffer[2400]; + class Delay { public: @@ -12,7 +14,7 @@ namespace Effect this->delay.Init(this->ironpedal->knobs[PedalPCB::KNOB_2], 0.0f, 50.01f, daisy::Parameter::LINEAR); - this->delay_line.Init(); + this->delay_line.Init(DelayBuffer, sizeof(DelayBuffer) / sizeof(float)); this->delay_line.SetDelay((size_t)(this->ironpedal->AudioSampleRate() / this->ironpedal->GetEffect(EFFECT_DELAY).values[PedalPCB::KNOB_2])); } @@ -50,7 +52,7 @@ namespace Effect private: daisy::Parameter delay; - daisysp::DelayLine delay_line; + daisysp::DelayLine delay_line; Snailsoft::Ironpedal *ironpedal; }; diff --git a/src/effects/looper.h b/src/effects/looper.h index 09b208f..176c808 100644 --- a/src/effects/looper.h +++ b/src/effects/looper.h @@ -3,7 +3,7 @@ namespace Effect { - float DSY_SDRAM_BSS Buffer[48000 * 60 * 5]; + float DSY_SDRAM_BSS LooperBuffer[48000 * 60 * 5]; class Looper { @@ -42,10 +42,10 @@ namespace Effect for (size_t i = 0; i < size; ++i) { if (this->ironpedal->GetEffect(EFFECT_LOOPER).values[PedalPCB::KNOB_2] > 0.5f) - Buffer[this->buffer_size = this->buffer_size < sizeof(Buffer) / sizeof(float) ? this->buffer_size + 1 : 0] = in[i]; + LooperBuffer[this->buffer_size = this->buffer_size < sizeof(LooperBuffer) / sizeof(float) ? this->buffer_size + 1 : 0] = in[i]; else - out[i] = in[i] + Buffer[this->buffer_index = this->buffer_index < this->buffer_size ? this->buffer_index + 1 : 0] * this->ironpedal->GetEffect(EFFECT_LOOPER).values[PedalPCB::KNOB_5]; + out[i] = in[i] + LooperBuffer[this->buffer_index = this->buffer_index < this->buffer_size ? this->buffer_index + 1 : 0] * this->ironpedal->GetEffect(EFFECT_LOOPER).values[PedalPCB::KNOB_5]; } } diff --git a/src/effects/misc.h b/src/effects/misc.h index 2a230fa..4ddf0a0 100644 --- a/src/effects/misc.h +++ b/src/effects/misc.h @@ -54,7 +54,7 @@ namespace Effect { if (this->ironpedal->GetEffect(i).enabled) { - sprintf(buf, "%s%s%u", buf, first ? "" : ", ", i); + sprintf(buf, first ? "%s%u" : "%s, %u", buf, i); if (first) first = false;