Config nodes change midi notes. Better would be midi nodes read from config nodes.
This commit is contained in:
+58
-29
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "config-node.h"
|
||||
#include "datatypes.h"
|
||||
#include "node.h"
|
||||
#include "raymath.h"
|
||||
@@ -10,7 +11,23 @@
|
||||
namespace VISEQ::GRAPH::NODES {
|
||||
|
||||
class MidiNode : public Node{
|
||||
|
||||
private:
|
||||
int midi_note_channel = 1;
|
||||
int midi_note = 48;
|
||||
int midi_velocity = 60;
|
||||
int midi_gate = 10; // gate time in milliseconds
|
||||
|
||||
int midi_cc_channel = 0;
|
||||
int midi_cc = 0;
|
||||
int midi_cc_value = 0;
|
||||
|
||||
int midi_pc_channel = 0;
|
||||
int midi_pc = 0;
|
||||
int midi_pc_value = 0;
|
||||
|
||||
int midi_pitch_bend_channel = 0;
|
||||
int midi_pitch_bend = 8192;
|
||||
|
||||
public:
|
||||
|
||||
struct NodeMidiOut{
|
||||
@@ -42,22 +59,6 @@ namespace VISEQ::GRAPH::NODES {
|
||||
|
||||
int mode = 0;
|
||||
|
||||
int midi_note_channel = 1;
|
||||
int midi_note = 48;
|
||||
int midi_velocity = 60;
|
||||
int midi_gate = 10; // gate time in milliseconds
|
||||
|
||||
int midi_cc_channel = 0;
|
||||
int midi_cc = 0;
|
||||
int midi_cc_value = 0;
|
||||
|
||||
int midi_pc_channel = 0;
|
||||
int midi_pc = 0;
|
||||
int midi_pc_value = 0;
|
||||
|
||||
int midi_pitch_bend_channel = 0;
|
||||
int midi_pitch_bend = 8192;
|
||||
|
||||
float start = 0;
|
||||
float fade = 0;
|
||||
float time = 0;
|
||||
@@ -87,9 +88,46 @@ namespace VISEQ::GRAPH::NODES {
|
||||
return midi_gate;
|
||||
}
|
||||
|
||||
std::vector<std::weak_ptr<ConfigNode>> getConnectedConfigNodes(){
|
||||
auto config_conns = connections | RANGE_FILTER([](EDGES::SPTR_Edge c){ return c->start.lock()->getNodeType() == NodeType::CONFIGNODE || c->end.lock()->getNodeType() == NodeType::CONFIGNODE;}) | std::ranges::to<std::vector<std::shared_ptr<EDGES::Edge>>>();
|
||||
std::vector<std::weak_ptr<ConfigNode>> config_nodes;
|
||||
for(auto e : config_conns){
|
||||
if(e->start.lock()->getNodeType() == NodeType::CONFIGNODE) config_nodes.push_back(std::dynamic_pointer_cast<ConfigNode>(e->start.lock()));
|
||||
if(e->end.lock()->getNodeType() == NodeType::CONFIGNODE) config_nodes.push_back(std::dynamic_pointer_cast<ConfigNode>(e->end.lock()));
|
||||
}
|
||||
return config_nodes;
|
||||
}
|
||||
|
||||
void update() override {
|
||||
Node::update();
|
||||
mode = state->node_mode;
|
||||
|
||||
}
|
||||
|
||||
int getMidiNote(){
|
||||
int mod_notes = 0;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
mod_notes += cn.lock()->midiNote.note;
|
||||
}
|
||||
return midi_note + mod_notes;
|
||||
}
|
||||
|
||||
void modMidiNote(int incr){
|
||||
midi_note += incr;
|
||||
if(midi_note < 0 ) midi_note = VISEQ::MIDI::Notes.size()-1;
|
||||
if(midi_note >= (int)VISEQ::MIDI::Notes.size()) midi_note = 0;
|
||||
}
|
||||
|
||||
void modMidiCC(int incr){
|
||||
midi_cc += incr;
|
||||
if(midi_cc < 0 ) midi_cc = 127;
|
||||
if(midi_cc > 127 ) midi_cc = 0;
|
||||
}
|
||||
|
||||
void modMidiPitchBend(int incr){
|
||||
midi_pitch_bend += incr;
|
||||
if(midi_pitch_bend < 0 ) midi_pitch_bend = 0;
|
||||
if(midi_pitch_bend > 16383 ) midi_pitch_bend = 16383;
|
||||
}
|
||||
|
||||
void interact(){
|
||||
@@ -98,24 +136,15 @@ namespace VISEQ::GRAPH::NODES {
|
||||
if(KEYS_DOWN.ctrl && !KEYS_DOWN.alt){
|
||||
switch(state->node_mode){
|
||||
case 0:{
|
||||
midi_note += wheel;
|
||||
modMidiNote(wheel);
|
||||
break;}
|
||||
case 1:{
|
||||
midi_cc += wheel;
|
||||
modMidiCC(wheel);
|
||||
break;}
|
||||
case 2:{
|
||||
midi_pitch_bend += wheel;
|
||||
modMidiPitchBend(wheel);
|
||||
break;}
|
||||
};
|
||||
if(midi_note < 0 ) midi_note = VISEQ::MIDI::Notes.size()-1;
|
||||
if(midi_note >= (int)VISEQ::MIDI::Notes.size()) midi_note = 0;
|
||||
|
||||
if(midi_cc < 0 ) midi_cc = 127;
|
||||
if(midi_cc > 127 ) midi_cc = 0;
|
||||
|
||||
if(midi_pitch_bend < 0 ) midi_pitch_bend = 0;
|
||||
if(midi_pitch_bend > 16383 ) midi_pitch_bend = 16383;
|
||||
|
||||
} else if(KEYS_DOWN.shift && !KEYS_DOWN.alt) {
|
||||
midi_velocity += wheel;
|
||||
if(midi_velocity < 0 ) midi_velocity = 127;
|
||||
|
||||
Reference in New Issue
Block a user