Inbetween states. Midi nodes and config nodes use same interface now.

This commit is contained in:
Sebastian
2024-12-07 22:09:06 +01:00
parent 3b0e7e986f
commit d9c97be326
5 changed files with 341 additions and 84 deletions
+44 -22
View File
@@ -1,12 +1,9 @@
#pragma once
#include "datatypes.h"
#include "edge.h"
#include "midi-node.h"
#include "node.h"
#include "raymath.h"
#include <memory>
#include <vector>
namespace VISEQ::GRAPH::NODES {
@@ -27,6 +24,7 @@ namespace VISEQ::GRAPH::NODES {
MIDI::MidiPitchBend midiPitchBend;
MIDI::MidiPolyPressure midiPolyPressure;
MIDI::MidiPC midiPC;
MIDI::MidiAftertouch midiAftertouch;
int mode = 0;
float radius = 20.0f;
@@ -36,45 +34,69 @@ namespace VISEQ::GRAPH::NODES {
int GGate(){
return 0;
}
MIDI::MidiNote getNotes(){
return midiNote;
}
MIDI::MidiCC getCC(){
return midiCC;
}
MIDI::MidiPC getPC(){
return midiPC;
}
MIDI::MidiPitchBend getPitchBend(){
return midiPitchBend;
}
MIDI::MidiPolyPressure getPolyPressure(){
return midiPolyPressure;
}
MIDI::MidiAftertouch getAftertouch(){
return midiAftertouch;
}
void update() override {
Node::update();
mode = state->node_mode;
}
std::vector<std::weak_ptr<MidiNode>> getConnectedMidiNodes(){
auto midi_conns = connections | RANGE_FILTER([](EDGES::SPTR_Edge c){ return c->start.lock()->getNodeType() == NodeType::MIDINODE || c->end.lock()->getNodeType() == NodeType::MIDINODE;}) | std::ranges::to<std::vector<std::shared_ptr<EDGES::Edge>>>();
std::vector<std::weak_ptr<MidiNode>> midi_nodes;
for(auto e : midi_conns){
if(e->start.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->start.lock()));
if(e->end.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->end.lock()));
}
return midi_nodes;
}
/*std::vector<std::weak_ptr<MidiNode>> getConnectedMidiNodes(){*/
/* auto midi_conns = connections | RANGE_FILTER([](EDGES::SPTR_Edge c){ return c->start.lock()->getNodeType() == NodeType::MIDINODE || c->end.lock()->getNodeType() == NodeType::MIDINODE;}) | std::ranges::to<std::vector<std::shared_ptr<EDGES::Edge>>>();*/
/* std::vector<std::weak_ptr<MidiNode>> midi_nodes;*/
/* for(auto e : midi_conns){*/
/* if(e->start.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->start.lock()));*/
/* if(e->end.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->end.lock()));*/
/* }*/
/* return midi_nodes;*/
/*}*/
void interact(){
float wheel = GetMouseWheelMove();
auto midi_nodes = getConnectedMidiNodes();
/*auto midi_nodes = getConnectedMidiNodes();*/
if(KEYS_DOWN.ctrl && !KEYS_DOWN.alt){
switch(state->node_mode){
case 0:{
midiNote.note += wheel;
for(auto mn : midi_nodes){
mn.lock()->modMidiNote(wheel);
}
/* for(auto mn : midi_nodes){*/
/*mn.lock()->modMidiNote(wheel);*/
/* }*/
break;}
case 1:{
midiCC.value += wheel;
for(auto mn : midi_nodes){
mn.lock()->modMidiCC(wheel);
}
/* for(auto mn : midi_nodes){*/
/*mn.lock()->modMidiCC(wheel);*/
/* }*/
break;}
case 2:{
midiPitchBend.value += wheel;
for(auto mn : midi_nodes){
mn.lock()->modMidiPitchBend(wheel);
}
/* for(auto mn : midi_nodes){*/
/*mn.lock()->modMidiPitchBend(wheel);*/
/* }*/
break;}
};
if(midiNote.note < -127 ) midiNote.note = -127;