From 39b4e9eae8d6f53607acd64cef6614e473795ba6 Mon Sep 17 00:00:00 2001 From: Jeremy Weatherford Date: Thu, 28 Jun 2018 11:13:50 -0400 Subject: [PATCH 1/2] add Keyframer Sequencer mode to context menu --- src/Frames.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Frames.cpp b/src/Frames.cpp index 4450c9a..9e2b88a 100644 --- a/src/Frames.cpp +++ b/src/Frames.cpp @@ -46,10 +46,13 @@ struct Frames : Module { frames::Keyframer keyframer; frames::PolyLfo poly_lfo; bool poly_lfo_mode = false; + bool sequencer_mode = false; uint16_t lastControls[4] = {}; + uint8_t sequencer_step = 0; SchmittTrigger addTrigger; SchmittTrigger delTrigger; + SchmittTrigger stepTrigger; Frames(); void step() override; @@ -57,6 +60,7 @@ struct Frames : Module { json_t *toJson() override { json_t *rootJ = json_object(); json_object_set_new(rootJ, "polyLfo", json_boolean(poly_lfo_mode)); + json_object_set_new(rootJ, "seqMode", json_boolean(sequencer_mode)); json_t *keyframesJ = json_array(); for (int i = 0; i < keyframer.num_keyframes(); i++) { @@ -87,6 +91,10 @@ struct Frames : Module { if (polyLfoJ) poly_lfo_mode = json_boolean_value(polyLfoJ); + json_t *seqModeJ = json_object_get(rootJ, "seqMode"); + if (seqModeJ) + sequencer_mode = json_boolean_value(seqModeJ); + json_t *keyframesJ = json_object_get(rootJ, "keyframes"); if (keyframesJ) { json_t *keyframeJ; @@ -195,6 +203,16 @@ void Frames::step() { keyframer.RemoveKeyframe(nearestTimestamp); } } + if (sequencer_mode) { + if (stepTrigger.process(rescale(inputs[FRAME_INPUT].value, 0.1f, 2.f, 0.f, 1.f))) { + ++sequencer_step; + } + if (sequencer_step >= keyframer.num_keyframes()) + sequencer_step = 0; + + timestampMod = keyframer.keyframe(sequencer_step).timestamp; + } + keyframer.Evaluate(timestampMod); } @@ -409,6 +427,18 @@ struct FramesWidget : ModuleWidget { } }; + struct FramesSeqModeItem : MenuItem { + Frames *frames; + bool sequencer_mode; + void onAction(EventAction &e) override { + frames->sequencer_mode = !frames->sequencer_mode; + } + void step() override { + rightText = frames->sequencer_mode ? "✔" : ""; + MenuItem::step(); + } + }; + menu->addChild(construct()); menu->addChild(construct(&MenuLabel::text, "Channel Settings")); for (int i = 0; i < 4; i++) { @@ -420,6 +450,7 @@ struct FramesWidget : ModuleWidget { menu->addChild(construct(&MenuLabel::text, "Mode")); menu->addChild(construct(&MenuItem::text, "Keyframer", &FramesModeItem::frames, frames, &FramesModeItem::poly_lfo_mode, false)); menu->addChild(construct(&MenuItem::text, "Poly LFO", &FramesModeItem::frames, frames, &FramesModeItem::poly_lfo_mode, true)); + menu->addChild(construct(&MenuItem::text, "Sequencer", &FramesSeqModeItem::frames, frames)); } }; From 4951564811e0e6ff80a9c374a21f3bedecba39c7 Mon Sep 17 00:00:00 2001 From: Jeremy Weatherford Date: Thu, 28 Jun 2018 13:48:57 -0400 Subject: [PATCH 2/2] Modulation param affects step trigger input in sequencer mode --- src/Frames.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Frames.cpp b/src/Frames.cpp index 9e2b88a..af19151 100644 --- a/src/Frames.cpp +++ b/src/Frames.cpp @@ -204,15 +204,15 @@ void Frames::step() { } } if (sequencer_mode) { - if (stepTrigger.process(rescale(inputs[FRAME_INPUT].value, 0.1f, 2.f, 0.f, 1.f))) { + if (stepTrigger.process(rescale(inputs[FRAME_INPUT].value * params[MODULATION_PARAM].value, 0.1f, 2.f, 0.f, 1.f))) { ++sequencer_step; } if (sequencer_step >= keyframer.num_keyframes()) sequencer_step = 0; - + timestampMod = keyframer.keyframe(sequencer_step).timestamp; } - + keyframer.Evaluate(timestampMod); } @@ -420,6 +420,8 @@ struct FramesWidget : ModuleWidget { bool poly_lfo_mode; void onAction(EventAction &e) override { frames->poly_lfo_mode = poly_lfo_mode; + if (frames->poly_lfo_mode) + frames->sequencer_mode = false; } void step() override { rightText = (frames->poly_lfo_mode == poly_lfo_mode) ? "✔" : ""; @@ -432,6 +434,8 @@ struct FramesWidget : ModuleWidget { bool sequencer_mode; void onAction(EventAction &e) override { frames->sequencer_mode = !frames->sequencer_mode; + if (frames->sequencer_mode) + frames->poly_lfo_mode = false; } void step() override { rightText = frames->sequencer_mode ? "✔" : "";