From 1f2cbc4c3165493249c0a51e8c933084d7804cfb Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 17 Jul 2026 01:07:09 +0200 Subject: [PATCH] modifier chains implemented for notes --- src/graph-manager.cpp | 4 +-- src/midi-node.cpp | 61 +++++++++++++++++++++++++++---------------- src/state.cpp | 29 +++++++++++++++++--- src/state.h | 3 +++ 4 files changed, 69 insertions(+), 28 deletions(-) diff --git a/src/graph-manager.cpp b/src/graph-manager.cpp index a8b6d31..311be3e 100644 --- a/src/graph-manager.cpp +++ b/src/graph-manager.cpp @@ -386,8 +386,8 @@ namespace VISEQ::GRAPH{ unsigned char opacity_to = 250.0f - Clamp(to_from_handle.dist(mouse_pos), 0.0f, 220.0f); float opacity_normalized = Clamp((float)opacity / 255.0f, .0f, 1.0f); - float opacity_from_normalized = Clamp((float)opacity_from / 255.0f, .0f, 1.0f); - float opacity_to_normalized = Clamp((float)opacity_to / 255.0f, .0f, 1.0f); + //float opacity_from_normalized = Clamp((float)opacity_from / 255.0f, .0f, 1.0f); + //float opacity_to_normalized = Clamp((float)opacity_to / 255.0f, .0f, 1.0f); // Line with small connector circles if(c->end.lock()->getNodeType() == NodeType::MIDINODE && c->start.lock()->getNodeType() == NodeType::MIDINODE){ diff --git a/src/midi-node.cpp b/src/midi-node.cpp index 7643b2e..6980825 100644 --- a/src/midi-node.cpp +++ b/src/midi-node.cpp @@ -3,6 +3,7 @@ #include "config-node.h" #include "datatypes.h" #include "edge.h" +#include "interaction-event.h" #include "midi.h" #include "node.h" #include "raylib.h" @@ -181,16 +182,22 @@ namespace VISEQ::GRAPH::NODES { switch(mode){ case NOTE:{ - if(state->isModChain(APP::CTRL, APP::SHIFT, APP::ALT)){ - std::cout << "yeah" << std::endl; - } - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) modMidiNoteValue(wheel); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) modMidiNoteVelocity(wheel); + if(state->isModChain(APP::CTRL)) modMidiNoteValue(wheel); + if(state->isModChain(APP::CTRL, APP::SHIFT)) modMidiNoteValue(wheel*12); + if(state->isModChain(APP::CTRL, APP::ALT)) modMidiNoteValue(wheel*12); + if(state->isModChain(APP::CTRL, APP::SHIFT, APP::ALT)) modMidiNoteValue(wheel*24); + if(state->isModChain(APP::CTRL, APP::ALT, APP::SHIFT)) modMidiNoteValue(wheel*24); + + if(state->isModChain(APP::SHIFT)) modMidiNoteVelocity(wheel); + if(state->isModChain(APP::SHIFT, APP::CTRL)) modMidiNoteVelocity(wheel*16); + if(state->isModChain(APP::SHIFT, APP::ALT)) modMidiNoteVelocity(wheel*16); + if(state->isModChain(APP::SHIFT, APP::CTRL, APP::ALT)) modMidiNoteVelocity(wheel*32); + if(state->isModChain(APP::SHIFT, APP::ALT, APP::CTRL)) modMidiNoteVelocity(wheel*32); - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) modMidiNoteGate(wheel*100); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) modMidiNoteGate(wheel*1000); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) modMidiNoteGate(wheel*10); - if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) modMidiNoteGate(wheel); + if(state->isModChain(APP::ALT)) modMidiNoteGate(wheel*100); + if(state->isModChain(APP::ALT, APP::CTRL)) modMidiNoteGate(wheel*1000); + if(state->isModChain(APP::ALT, APP::SHIFT)) modMidiNoteGate(wheel*10); + if(state->isModChain(APP::ALT, APP::SHIFT, APP::CTRL)) modMidiNoteGate(wheel); break;} case CC:{ if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) modMidiCCValue(wheel); @@ -277,23 +284,31 @@ namespace VISEQ::GRAPH::NODES { VMATH::Vec2D desc_position = position + VMATH::Vec2D(radius + 7.0f, radius + 7.0f); switch(mode){ case NOTE:{ - if(!KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(MIDI::Notes[getNotes().note], position, 14, VS_COLOR_DARKGREY); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawCenteredText(std::format("{}", getNotes().velocity), position, 12, VS_COLOR_WHITE); + if(state->isModChainStart(APP::CTRL) || state->modifier_chain.size() == 0) DrawCenteredText(MIDI::Notes[getNotes().note], position, 14, VS_COLOR_DARKGREY); + if(state->isModChainStart(APP::SHIFT)) DrawCenteredText(std::format("{}", getNotes().velocity), position, 12, VS_COLOR_DARKGREY); - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.1f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_WHITE); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.2f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_WHITE); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.2f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_WHITE); - if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawCenteredText(std::format("{:.3f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_WHITE); + if(state->isModChain(APP::ALT)) DrawCenteredText(std::format("{:.1f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_DARKGREY); + if(state->isModChainStart(APP::ALT, APP::CTRL)) DrawCenteredText(std::format("{:.2f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_DARKGREY); + if(state->isModChain(APP::ALT, APP::SHIFT)) DrawCenteredText(std::format("{:.2f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_DARKGREY); + if(state->isModChain(APP::ALT, APP::SHIFT, APP::CTRL)) DrawCenteredText(std::format("{:.3f}s", (float)getNotes().gate / 1000.f), position, 12, VS_COLOR_DARKGREY); - if(selected){ - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("NOTE", desc_position, 8, VS_COLOR_WHITE); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VALUE", desc_position, 8, VS_COLOR_WHITE); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && !KEYS_DOWN.alt) DrawText("VELOCITY", desc_position, 8, VS_COLOR_WHITE); + if(selected || hovering()){ + if(state->isModChain(APP::CTRL)) DrawText("NOTE +1", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::CTRL, APP::SHIFT)) DrawText("NOTE +12", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::CTRL, APP::ALT)) DrawText("NOTE +12", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::CTRL, APP::SHIFT, APP::ALT)) DrawText("NOTE +24", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::CTRL, APP::ALT, APP::SHIFT)) DrawText("NOTE +24", desc_position, 8, VS_COLOR_WHITE); + + if(state->isModChain(APP::SHIFT)) DrawText("VELOCITY +1", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::SHIFT, APP::CTRL)) DrawText("VELOCITY +16", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::SHIFT, APP::ALT)) DrawText("VELOCITY +16", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::SHIFT, APP::CTRL, APP::ALT)) DrawText("VELOCITY +32", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::SHIFT, APP::ALT, APP::CTRL)) DrawText("VELOCITY +32", desc_position, 8, VS_COLOR_WHITE); - if(!KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 0.1s", desc_position, 8, VS_COLOR_WHITE); - if(KEYS_DOWN.ctrl && !KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 1.0s", desc_position, 8, VS_COLOR_WHITE); - if(!KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 0.01s", desc_position, 8, VS_COLOR_WHITE); - if(KEYS_DOWN.ctrl && KEYS_DOWN.shift && KEYS_DOWN.alt) DrawText("GATE 0.001s", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::ALT)) DrawText("GATE 0.1s", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChainStart(APP::ALT, APP::CTRL)) DrawText("GATE 1.0s", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::ALT, APP::SHIFT)) DrawText("GATE 0.01s", desc_position, 8, VS_COLOR_WHITE); + if(state->isModChain(APP::ALT, APP::SHIFT, APP::CTRL)) DrawText("GATE 0.001s", desc_position, 8, VS_COLOR_WHITE); } break;} case CC:{ diff --git a/src/state.cpp b/src/state.cpp index bde4e9a..d3a5da1 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -4,6 +4,7 @@ #include "raylib.h" #include "vmath.h" #include +#include namespace VISEQ::APP{ @@ -59,14 +60,22 @@ namespace VISEQ::APP{ if(modifier_chain.size() < n_modifier){ ModifierKeyNames modKey = keys_pressed.ctrl ? CTRL : keys_pressed.shift ? SHIFT : ALT; modifier_chain.push_back(modKey); - std::cout << modifier_chain.size() << " " << modKey << std::endl; + //std::cout << modifier_chain.size() << " " << modKey << std::endl; + for(ModifierKeyNames n : modifier_chain){ + std::cout << n << " "; + } + std::cout << std::endl; } if(modifier_chain.size() > n_modifier){ - ModifierKeyNames modKey = !keys_released.ctrl ? CTRL : !keys_released.shift ? SHIFT : ALT; + ModifierKeyNames modKey = keys_released.ctrl ? CTRL : keys_released.shift ? SHIFT : ALT; auto it = std::remove(modifier_chain.begin(), modifier_chain.end(), modKey); modifier_chain.erase(it); - std::cout << modifier_chain.size() << " " << modKey << std::endl; + //std::cout << modifier_chain.size() << " " << modKey << std::endl; + for(ModifierKeyNames n : modifier_chain){ + std::cout << n << " "; + } + std::cout << std::endl; } screen_mouse = {round(mouse_pos.x), round(mouse_pos.y)}; @@ -89,6 +98,20 @@ namespace VISEQ::APP{ return State::instance; } + bool State::isModChainEmpty(){ + return modifier_chain.size() == 0; + } + + bool State::isModChainStart(ModifierKeyNames first){ + if(modifier_chain.size() < 1) return false; + return std::equal(modifier_chain.begin(), modifier_chain.begin() + 1, std::vector{first}.begin()); + } + + bool State::isModChainStart(ModifierKeyNames first, ModifierKeyNames second){ + if(modifier_chain.size() < 2) return false; + return std::equal(modifier_chain.begin(), modifier_chain.begin() + 2, std::vector{first, second}.begin()); + } + bool State::isModChain(ModifierKeyNames first){ return modifier_chain == std::vector{first}; } diff --git a/src/state.h b/src/state.h index 7a45049..c6ddaf8 100644 --- a/src/state.h +++ b/src/state.h @@ -102,6 +102,9 @@ namespace VISEQ::APP{ std::deque event_queue; + bool isModChainEmpty(); + bool isModChainStart(ModifierKeyNames first); + bool isModChainStart(ModifierKeyNames first, ModifierKeyNames second); bool isModChain(ModifierKeyNames first); bool isModChain(ModifierKeyNames first, ModifierKeyNames second); bool isModChain(ModifierKeyNames first, ModifierKeyNames second, ModifierKeyNames third);