From 85cf3833cebd9cc6180d22fc840afe614eb29f07 Mon Sep 17 00:00:00 2001 From: Peter Allwin Date: Sun, 6 Jan 2019 22:19:08 +0100 Subject: [PATCH] added more wavetable oscillators, changed shape/shiftshape behavior --- README.md | 45 ++++++++++++++++++++++++++++ eurorack | 2 +- macro-oscillator2.cc | 66 ++++++++++++++++------------------------- makefile.inc | 2 +- manifest.json | 7 +++-- osc_ad.mk => osc_add.mk | 2 +- osc_gr.mk => osc_grn.mk | 2 +- osc_ws.mk => osc_wsh.mk | 2 +- osc_wta.mk | 8 +++++ osc_wtb.mk | 8 +++++ osc_wtc.mk | 8 +++++ osc_wtd.mk | 8 +++++ osc_wte.mk | 8 +++++ osc_wtf.mk | 8 +++++ 14 files changed, 128 insertions(+), 48 deletions(-) create mode 100644 README.md rename osc_ad.mk => osc_add.mk (90%) rename osc_gr.mk => osc_grn.mk (90%) rename osc_ws.mk => osc_wsh.mk (90%) create mode 100644 osc_wta.mk create mode 100644 osc_wtb.mk create mode 100644 osc_wtc.mk create mode 100644 osc_wtd.mk create mode 100644 osc_wte.mk create mode 100644 osc_wtf.mk diff --git a/README.md b/README.md new file mode 100644 index 0000000..223e026 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +Macro Oscillator 2 for Prologue +=============================== + +This is a port of some of Mutable Instruments Plaits oscillators to the Korg Prologue MultiEngine. + +Oscillators +----- +| Name | Oscillator | +|--|--|--| +| `va` | Pair of classic waveforms | +| `wsh` | Waveshaping oscillator | +| `fm` | Two operator FM | +| `grn` | Granular formant oscillator | +| `add` | Harmonic oscillator | +| `wta`-`wtf`* | Wavetable oscillator | + +\* Due to the 32k size constraint in the MultiEngine the Wavetable oscillator is split into 6 oscillators with 4 'rows' each. + +Common parameters +---- +In the MultiEngine options if the Prologue you can find `Harmonics`, `Timbre` and `Morph` paramters for the oscillator (0-100%). These will do different things depending on the oscillator and is described in the [Mutable Instruments Plaits documentation](https://mutable-instruments.net/modules/plaits/manual/) + +Plaits offer both `out` and `aux` outputs, and the `Out/Aux` parameter sets the mix between them. + +Finally, `Shape Prm` sets which parameter the `Shape` knob and Shape LFO controls, and `ShiftS Prm` sets which parameters is controlled when pressing `Shift` and turning the `Shape` knob. + +| Value | Parameter | +|--|--| +| 1| Harmonics | +| 2| Timbre | +| 3| Morph | + +Issues +---- +* Oscillators can sometime use more CPU than available causing the voice to hang forcing a reboot of the Prologue +* The Prologue Librarian tends to timeout when transferring the user oscillator, however typically the transfer is still complete. Try adding the user oscillator one at a time and transfer 'Send All' after each. + +Building +------- +* Checkout the repo (including subrepos) +* Follow the toolchain installation instructions in the `logue-sdk` +* Build with `make` + +(only tested on MacOSX) + diff --git a/eurorack b/eurorack index 1cf95b2..475b401 160000 --- a/eurorack +++ b/eurorack @@ -1 +1 @@ -Subproject commit 1cf95b2f26edd6cd9f89d038c2746f958abefae4 +Subproject commit 475b4017f9c648fb02accbf1e6349ce246fd4232 diff --git a/macro-oscillator2.cc b/macro-oscillator2.cc index 5cb5237..fd3ef69 100644 --- a/macro-oscillator2.cc +++ b/macro-oscillator2.cc @@ -8,7 +8,7 @@ plaits::VirtualAnalogEngine engine; float out_gain = 0.8f, aux_gain = 0.8f; #endif -#ifdef OSC_WS +#ifdef OSC_WSH #include "plaits/dsp/engine/waveshaping_engine.h" plaits::WaveshapingEngine engine; float out_gain = 0.7f, aux_gain = 0.6f; @@ -20,18 +20,24 @@ plaits::FMEngine engine; float out_gain = 0.6f, aux_gain = 0.6f; #endif -#ifdef OSC_GR +#ifdef OSC_GRN #include "plaits/dsp/engine/grain_engine.h" plaits::GrainEngine engine; float out_gain = 0.7f, aux_gain = 0.6f; #endif -#ifdef OSC_AD +#ifdef OSC_ADD #include "plaits/dsp/engine/additive_engine.h" plaits::AdditiveEngine engine; float out_gain = 0.8f, aux_gain = 0.8f; #endif +#if defined(OSC_WTA) || defined(OSC_WTB) || defined(OSC_WTC) || defined(OSC_WTD) || defined(OSC_WTE) || defined(OSC_WTF) +#include "plaits/dsp/engine/wavetable_engine.h" +plaits::WavetableEngine engine; +float out_gain = 0.6f, aux_gain = 0.6f; +#endif + plaits::EngineParameters parameters = { .trigger = plaits::TRIGGER_UNPATCHED, .note = 0, @@ -48,7 +54,7 @@ float harmonics = 0, shape = 0, shiftshape = 0; -int param_mode = 0; +int shape_param = 0, shift_shape_param = 0; void OSC_INIT(uint32_t platform, uint32_t api) { @@ -67,40 +73,19 @@ void OSC_CYCLE(const user_osc_param_t *const params, parameters.note = ((float)(params->pitch >> 8)) + ((params->pitch & 0xFF) * k_note_mod_fscale); - float shape_lfo = clip01f(shape + q31_to_f32(params->shape_lfo)); + float shape_lfo = q31_to_f32(params->shape_lfo); - switch(param_mode) { - case 0: - parameters.timbre = shape_lfo; - parameters.morph = shiftshape; - parameters.harmonics = harmonics; - break; - case 1: - parameters.timbre = shape_lfo; - parameters.morph = morph; - parameters.harmonics = shiftshape; - break; - case 2: - parameters.timbre = shiftshape; - parameters.morph = shape_lfo; - parameters.harmonics = harmonics; - break; - case 3: - parameters.timbre = timbre; - parameters.morph = shape_lfo; - parameters.harmonics = shiftshape; - break; - case 4: - parameters.timbre = shiftshape; - parameters.morph = morph; - parameters.harmonics = shape_lfo; - break; - case 5: - parameters.timbre = timbre; - parameters.morph = shiftshape; - parameters.harmonics = shape_lfo; - break; - } + parameters.harmonics = clip01f(harmonics + + (shape_param == 0 ? (shape + shape_lfo) : 0.0f) + + (shift_shape_param == 0 ? shiftshape : 0.0f)); + + parameters.timbre = clip01f(timbre + + (shape_param == 1 ? (shape + shape_lfo) : 0.0f) + + (shift_shape_param == 1 ? shiftshape : 0.0f)); + + parameters.morph = clip01f(morph + + (shape_param == 2 ? (shape + shape_lfo) : 0.0f) + + (shift_shape_param == 2 ? shiftshape : 0.0f)); engine.Render(parameters, out, aux, (size_t)frames, &enveloped); @@ -145,18 +130,19 @@ void OSC_PARAM(uint16_t index, uint16_t value) break; case k_osc_param_id5: - param_mode = value % 6; + shape_param = value % 3; break; case k_osc_param_id6: + shift_shape_param = value % 3; break; case k_osc_param_shape: - shape = clip01f(param_val_to_f32(value)); + shape = param_val_to_f32(value); break; case k_osc_param_shiftshape: - shiftshape = clip01f(param_val_to_f32(value)); + shiftshape = param_val_to_f32(value); break; default: diff --git a/makefile.inc b/makefile.inc index 6135234..2ad2d94 100644 --- a/makefile.inc +++ b/makefile.inc @@ -70,7 +70,7 @@ LDSCRIPT = $(LDDIR)/userosc.ld DLIBS = -lm DADEFS = -DSTM32F401xC -DCORTEX_USE_FPU=TRUE -DARM_MATH_CM4 -DDEFS = -DSTM32F401xC -DCORTEX_USE_FPU=TRUE -DARM_MATH_CM4 -D__FPU_PRESENT -D_USE_MATH_DEFINES -DOSC_$(OSCILLATOR_UC) +DDEFS = -DSTM32F401xC -DCORTEX_USE_FPU=TRUE -DARM_MATH_CM4 -D__FPU_PRESENT -D_USE_MATH_DEFINES -DOSC_$(OSCILLATOR_UC) -DOSCILLATOR_TYPE=$(OSCILLATOR) COPT = -std=c11 -mstructure-size-boundary=8 CXXOPT = -std=c++11 -fno-rtti -fno-exceptions -fno-non-call-exceptions -fno-use-cxa-atexit -ffunction-sections -fdata-sections -funroll-loops diff --git a/manifest.json b/manifest.json index 417f69e..fb256ed 100644 --- a/manifest.json +++ b/manifest.json @@ -7,14 +7,15 @@ "dev_id" : 0, "prg_id" : 0, "version" : "1.0-0", - "name" : "mo2 %OSCILLATOR%", - "num_param" : 5, + "name" : "mo2%OSCILLATOR%", + "num_param" : 6, "params" : [ ["Harmonics", 0, 100, "%"], ["Timbre", 0, 100, "%"], ["Morph", 0, 100, "%"], ["Out/Aux", 0, 100, "%"], - ["ParamMode", 0, 5, ""] + ["Shape Prm", 0, 2, ""], + ["ShftS Prm", 0, 2, ""] ] } } diff --git a/osc_ad.mk b/osc_add.mk similarity index 90% rename from osc_ad.mk rename to osc_add.mk index 83ff624..f6c8e70 100644 --- a/osc_ad.mk +++ b/osc_add.mk @@ -1,4 +1,4 @@ -OSCILLATOR = ad +OSCILLATOR = add UCXXSRC = macro-oscillator2.cc \ eurorack/plaits/dsp/engine/additive_engine.cc \ diff --git a/osc_gr.mk b/osc_grn.mk similarity index 90% rename from osc_gr.mk rename to osc_grn.mk index de7daad..44f47c4 100644 --- a/osc_gr.mk +++ b/osc_grn.mk @@ -1,4 +1,4 @@ -OSCILLATOR = gr +OSCILLATOR = grn UCXXSRC = macro-oscillator2.cc \ eurorack/plaits/dsp/engine/grain_engine.cc \ diff --git a/osc_ws.mk b/osc_wsh.mk similarity index 90% rename from osc_ws.mk rename to osc_wsh.mk index 780107d..ae54132 100644 --- a/osc_ws.mk +++ b/osc_wsh.mk @@ -1,4 +1,4 @@ -OSCILLATOR = ws +OSCILLATOR = wsh UCXXSRC = macro-oscillator2.cc \ eurorack/plaits/dsp/engine/waveshaping_engine.cc \ diff --git a/osc_wta.mk b/osc_wta.mk new file mode 100644 index 0000000..d66f1d0 --- /dev/null +++ b/osc_wta.mk @@ -0,0 +1,8 @@ +OSCILLATOR = wta + +UCXXSRC = macro-oscillator2.cc \ + eurorack/plaits/dsp/engine/wavetable_engine.cc \ + eurorack/plaits/resources.cc \ + eurorack/stmlib/dsp/units.cc + +include makefile.inc diff --git a/osc_wtb.mk b/osc_wtb.mk new file mode 100644 index 0000000..c62780c --- /dev/null +++ b/osc_wtb.mk @@ -0,0 +1,8 @@ +OSCILLATOR = wtb + +UCXXSRC = macro-oscillator2.cc \ + eurorack/plaits/dsp/engine/wavetable_engine.cc \ + eurorack/plaits/resources.cc \ + eurorack/stmlib/dsp/units.cc + +include makefile.inc diff --git a/osc_wtc.mk b/osc_wtc.mk new file mode 100644 index 0000000..ec03fc2 --- /dev/null +++ b/osc_wtc.mk @@ -0,0 +1,8 @@ +OSCILLATOR = wtc + +UCXXSRC = macro-oscillator2.cc \ + eurorack/plaits/dsp/engine/wavetable_engine.cc \ + eurorack/plaits/resources.cc \ + eurorack/stmlib/dsp/units.cc + +include makefile.inc diff --git a/osc_wtd.mk b/osc_wtd.mk new file mode 100644 index 0000000..43d47d2 --- /dev/null +++ b/osc_wtd.mk @@ -0,0 +1,8 @@ +OSCILLATOR = wtd + +UCXXSRC = macro-oscillator2.cc \ + eurorack/plaits/dsp/engine/wavetable_engine.cc \ + eurorack/plaits/resources.cc \ + eurorack/stmlib/dsp/units.cc + +include makefile.inc diff --git a/osc_wte.mk b/osc_wte.mk new file mode 100644 index 0000000..f24ca4d --- /dev/null +++ b/osc_wte.mk @@ -0,0 +1,8 @@ +OSCILLATOR = wte + +UCXXSRC = macro-oscillator2.cc \ + eurorack/plaits/dsp/engine/wavetable_engine.cc \ + eurorack/plaits/resources.cc \ + eurorack/stmlib/dsp/units.cc + +include makefile.inc diff --git a/osc_wtf.mk b/osc_wtf.mk new file mode 100644 index 0000000..f4982c5 --- /dev/null +++ b/osc_wtf.mk @@ -0,0 +1,8 @@ +OSCILLATOR = wtf + +UCXXSRC = macro-oscillator2.cc \ + eurorack/plaits/dsp/engine/wavetable_engine.cc \ + eurorack/plaits/resources.cc \ + eurorack/stmlib/dsp/units.cc + +include makefile.inc