Inbetween states. Midi nodes and config nodes use same interface now.
This commit is contained in:
+91
-51
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "config-node.h"
|
||||
#include "datatypes.h"
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
#include "raymath.h"
|
||||
#include <map>
|
||||
@@ -12,21 +13,12 @@ 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;
|
||||
MIDI::MidiNote midiNote;
|
||||
MIDI::MidiCC midiCC;
|
||||
MIDI::MidiPitchBend midiPitchBend;
|
||||
MIDI::MidiAftertouch midiAftertouch;
|
||||
MIDI::MidiPolyPressure midiPolyPressure;
|
||||
MIDI::MidiPC midiPC;
|
||||
|
||||
public:
|
||||
|
||||
@@ -77,7 +69,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
void trigger() override {
|
||||
triggered = true;
|
||||
start = GetTime();
|
||||
fade = midi_gate;
|
||||
fade = midiNote.gate;
|
||||
}
|
||||
|
||||
void SMode(int _mode) override{
|
||||
@@ -85,9 +77,57 @@ namespace VISEQ::GRAPH::NODES {
|
||||
}
|
||||
|
||||
int GGate(){
|
||||
return midi_gate;
|
||||
return midiNote.gate;
|
||||
}
|
||||
|
||||
MIDI::MidiNote getNotes(){
|
||||
MIDI::MidiNote cNote;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cNote += cn.lock()->getNotes();
|
||||
}
|
||||
return cNote;
|
||||
}
|
||||
|
||||
MIDI::MidiCC getCC(){
|
||||
MIDI::MidiCC cCC;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cCC += cn.lock()->getCC();
|
||||
}
|
||||
return cCC;
|
||||
}
|
||||
|
||||
MIDI::MidiPC getPC(){
|
||||
MIDI::MidiPC cPC;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cPC += cn.lock()->getPC();
|
||||
}
|
||||
return cPC;
|
||||
}
|
||||
|
||||
MIDI::MidiPitchBend getPitchBend(){
|
||||
MIDI::MidiPitchBend cPitchBend;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cPitchBend += cn.lock()->getPitchBend();
|
||||
}
|
||||
return cPitchBend;
|
||||
}
|
||||
|
||||
MIDI::MidiAftertouch getAftertouch(){
|
||||
MIDI::MidiAftertouch cAftertouch;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cAftertouch += cn.lock()->getAftertouch();
|
||||
}
|
||||
return cAftertouch;
|
||||
}
|
||||
|
||||
MIDI::MidiPolyPressure getPolyPressure(){
|
||||
MIDI::MidiPolyPressure cPolyPressure;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cPolyPressure += cn.lock()->getPolyPressure();
|
||||
}
|
||||
return cPolyPressure;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -109,25 +149,25 @@ namespace VISEQ::GRAPH::NODES {
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
mod_notes += cn.lock()->midiNote.note;
|
||||
}
|
||||
return midi_note + mod_notes;
|
||||
return midiNote.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;
|
||||
midiNote.note += incr;
|
||||
if(midiNote.note < 0 ) midiNote.note = VISEQ::MIDI::Notes.size()-1;
|
||||
if(midiNote.note >= (int)VISEQ::MIDI::Notes.size()) midiNote.note = 0;
|
||||
}
|
||||
|
||||
void modMidiCC(int incr){
|
||||
midi_cc += incr;
|
||||
if(midi_cc < 0 ) midi_cc = 127;
|
||||
if(midi_cc > 127 ) midi_cc = 0;
|
||||
midiCC.control += incr;
|
||||
if(midiCC.control < 0 ) midiCC.control = 127;
|
||||
if(midiCC.control > 127 ) midiCC.control = 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;
|
||||
midiPitchBend.value += incr;
|
||||
if(midiPitchBend.value < 0 ) midiPitchBend.value = 0;
|
||||
if(midiPitchBend.value > 16383 ) midiPitchBend.value = 16383;
|
||||
}
|
||||
|
||||
void interact(){
|
||||
@@ -146,26 +186,26 @@ namespace VISEQ::GRAPH::NODES {
|
||||
break;}
|
||||
};
|
||||
} else if(KEYS_DOWN.shift && !KEYS_DOWN.alt) {
|
||||
midi_velocity += wheel;
|
||||
if(midi_velocity < 0 ) midi_velocity = 127;
|
||||
if(midi_velocity > 127 ) midi_velocity = 0;
|
||||
midiNote.velocity += wheel;
|
||||
if(midiNote.velocity < 0 ) midiNote.velocity = 127;
|
||||
if(midiNote.velocity > 127 ) midiNote.velocity = 0;
|
||||
} else if(KEYS_DOWN.alt) {
|
||||
switch(state->node_mode){
|
||||
case 0:{
|
||||
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
||||
midi_gate += incr;
|
||||
if(midi_gate < 0 ) midi_gate = 0;
|
||||
midiNote.gate += incr;
|
||||
if(midiNote.gate < 0 ) midiNote.gate = 0;
|
||||
break;}
|
||||
case 1:{
|
||||
midi_cc_value += wheel;
|
||||
if(midi_cc_value < 0 ) midi_cc_value = 0;
|
||||
if(midi_cc_value > 127 ) midi_cc_value = 127;
|
||||
midiCC.value += wheel;
|
||||
if(midiCC.value < 0 ) midiCC.value = 0;
|
||||
if(midiCC.value > 127 ) midiCC.value = 127;
|
||||
break;}
|
||||
case 2:{
|
||||
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
||||
midi_pitch_bend += incr;
|
||||
if(midi_pitch_bend < 0 ) midi_pitch_bend = 0;
|
||||
if(midi_pitch_bend > 16383 ) midi_pitch_bend = 16383;
|
||||
midiPitchBend.value += incr;
|
||||
if(midiPitchBend.value < 0 ) midiPitchBend.value = 0;
|
||||
if(midiPitchBend.value > 16383 ) midiPitchBend.value = 16383;
|
||||
break;}
|
||||
};
|
||||
}
|
||||
@@ -177,7 +217,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
|
||||
last = time;
|
||||
time = GetTime();
|
||||
if(time - start >= (float)midi_gate / 1000.0f){
|
||||
if(time - start >= (float)midiNote.gate / 1000.0f){
|
||||
triggered = false;
|
||||
fade = 0;
|
||||
} else {
|
||||
@@ -185,10 +225,10 @@ namespace VISEQ::GRAPH::NODES {
|
||||
}
|
||||
|
||||
DrawRing(position, radius, radius+4, 0, 360, 24, (Color){60, 60, 60, 255});
|
||||
DrawRing(position, radius, radius+4, 0.0f - 90.0f, (360.0f/127.0f) * midi_velocity - 90.0f, 24, (Color){158, 134, 200, 255});
|
||||
DrawRing(position, radius, radius+4, 0.0f - 90.0f, (360.0f/127.0f) * midiNote.velocity - 90.0f, 24, (Color){158, 134, 200, 255});
|
||||
DrawCircleLinesV(position, radius + 4, (Color){100, 100, 100, 255});
|
||||
|
||||
float midi_gate_map = round((255.f / midi_gate) * fade);
|
||||
float midi_gate_map = round((255.f / midiNote.gate) * fade);
|
||||
|
||||
Color gate_color = VS_COLOR_GREEN;
|
||||
|
||||
@@ -217,17 +257,17 @@ namespace VISEQ::GRAPH::NODES {
|
||||
int offset_gate = 0;
|
||||
switch(mode){
|
||||
case 0:
|
||||
value = (float)midi_gate/1000.0f;
|
||||
value = (float)midiNote.gate/1000.0f;
|
||||
offset_gate = MeasureText(std::format("{:.2f}", value).c_str(), 12);
|
||||
DrawText(std::format("{:.2f}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
||||
break;
|
||||
case 1:
|
||||
value = (float)midi_cc_value;
|
||||
value = (float)midiCC.value;
|
||||
offset_gate = MeasureText(std::format("{}", value).c_str(), 12);
|
||||
DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
||||
break;
|
||||
case 2:
|
||||
value = (float)midi_pitch_bend;
|
||||
value = (float)midiPitchBend.value;
|
||||
offset_gate = MeasureText(std::format("{}", value).c_str(), 12);
|
||||
DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
||||
break;
|
||||
@@ -235,16 +275,16 @@ namespace VISEQ::GRAPH::NODES {
|
||||
} else {
|
||||
switch(mode){
|
||||
case 0:{
|
||||
int offset = MeasureText(MIDI::Notes[(int)midi_note].c_str(), 12);
|
||||
DrawText(MIDI::Notes[midi_note].c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
int offset = MeasureText(MIDI::Notes[(int)midiNote.note].c_str(), 12);
|
||||
DrawText(MIDI::Notes[midiNote.note].c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
break;}
|
||||
case 1:{
|
||||
int offset = MeasureText(std::format("{}", midi_cc).c_str(), 12);
|
||||
DrawText(std::format("{}", midi_cc).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
int offset = MeasureText(std::format("{}", midiCC.control).c_str(), 12);
|
||||
DrawText(std::format("{}", midiCC.control).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
break;}
|
||||
case 2:{
|
||||
int offset = MeasureText(std::format("{}", midi_pitch_bend).c_str(), 12);
|
||||
DrawText(std::format("{}", midi_pitch_bend).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
int offset = MeasureText(std::format("{}", midiPitchBend.value).c_str(), 12);
|
||||
DrawText(std::format("{}", midiPitchBend.value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
break;}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user