Skip to content

Commit

Permalink
added more wavetable oscillators, changed shape/shiftshape behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
peterall committed Jan 6, 2019
1 parent 4c369a2 commit 85cf383
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 48 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

66 changes: 26 additions & 40 deletions macro-oscillator2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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)
{
Expand All @@ -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);

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""]
]
}
}
2 changes: 1 addition & 1 deletion osc_ad.mk → osc_add.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OSCILLATOR = ad
OSCILLATOR = add

UCXXSRC = macro-oscillator2.cc \
eurorack/plaits/dsp/engine/additive_engine.cc \
Expand Down
2 changes: 1 addition & 1 deletion osc_gr.mk → osc_grn.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OSCILLATOR = gr
OSCILLATOR = grn

UCXXSRC = macro-oscillator2.cc \
eurorack/plaits/dsp/engine/grain_engine.cc \
Expand Down
2 changes: 1 addition & 1 deletion osc_ws.mk → osc_wsh.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OSCILLATOR = ws
OSCILLATOR = wsh

UCXXSRC = macro-oscillator2.cc \
eurorack/plaits/dsp/engine/waveshaping_engine.cc \
Expand Down
8 changes: 8 additions & 0 deletions osc_wta.mk
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions osc_wtb.mk
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions osc_wtc.mk
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions osc_wtd.mk
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions osc_wte.mk
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions osc_wtf.mk
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 85cf383

Please sign in to comment.