Config nodes not working yet, but everything is prepared.

This commit is contained in:
Sebastian
2024-12-08 02:25:57 +01:00
parent d9c97be326
commit 558829f619
7 changed files with 177 additions and 159 deletions
+62 -14
View File
@@ -1,8 +1,10 @@
#pragma once
#include "datatypes.h"
#include "edge.h"
#include "node.h"
#include "raymath.h"
#include "state.h"
#include <memory>
namespace VISEQ::GRAPH::NODES {
@@ -81,24 +83,16 @@ namespace VISEQ::GRAPH::NODES {
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);*/
/* }*/
midiNote.note += KEYS_DOWN.shift ? ((wheel > 0) - (wheel < 0)) * 12 : wheel;
break;}
case 1:{
midiCC.value += wheel;
/* for(auto mn : midi_nodes){*/
/*mn.lock()->modMidiCC(wheel);*/
/* }*/
midiCC.value += KEYS_DOWN.shift ? ((wheel > 0) - (wheel < 0)) * 12 : wheel;
break;}
case 2:{
midiPitchBend.value += wheel;
/* for(auto mn : midi_nodes){*/
/*mn.lock()->modMidiPitchBend(wheel);*/
/* }*/
midiPitchBend.value += KEYS_DOWN.shift ? ((wheel > 0) - (wheel < 0)) * 12 : wheel;
break;}
};
if(midiNote.note < -127 ) midiNote.note = -127;
if(midiNote.note > 127 ) midiNote.note = 127;
@@ -108,7 +102,6 @@ namespace VISEQ::GRAPH::NODES {
if(midiPitchBend.value < -16383 ) midiPitchBend.value = -16383;
if(midiPitchBend.value > 16383 ) midiPitchBend.value = 16383;
} else if(KEYS_DOWN.shift && !KEYS_DOWN.alt) {
} else if(KEYS_DOWN.alt) {
switch(state->node_mode){
case 0:{
@@ -122,7 +115,7 @@ namespace VISEQ::GRAPH::NODES {
if(midiCC.channel > 15 ) midiCC.channel = 15;
break;}
case 2:{
midiPitchBend.channel += wheel;
midiPitchBend.channel += KEYS_DOWN.shift ? ((wheel > 0) - (wheel < 0)) * 100 : wheel;
if(midiPitchBend.channel < 0 ) midiPitchBend.channel = 0;
if(midiPitchBend.channel > 15 ) midiPitchBend.channel = 15;
break;}
@@ -199,5 +192,60 @@ namespace VISEQ::GRAPH::NODES {
if(highlighted) DrawCircleLinesV(position, radius+2, (Color){255, 0, 0, 200});
DrawText(std::format("{}", id).c_str(), position.x + 20.0f, position.y + 20.0f, 10, WHITE);
}
friend void to_json(json& j, const ConfigNode& N){
std::vector<int> conns;
std::ranges::transform(N.connections.begin(), N.connections.end(), std::back_inserter(conns), [](VISEQ::GRAPH::EDGES::SPTR_Edge e){ return e->id;});
j = json{
{"id", N.id},
{"position", N.position},
{"distributionMode", N.distributionMode},
{"nodeType", N.nodeType},
{"midi_note_channel",N.midiNote.channel},
{"midi_note_note",N.midiNote.note},
{"midi_note_velocity",N.midiNote.velocity},
{"midi_note_gate",N.midiNote.gate},
{"midi_cc_channel",N.midiCC.channel},
{"midi_cc_control",N.midiCC.control},
{"midi_cc_value",N.midiCC.value},
{"midi_pc_channel",N.midiPC.channel},
{"midi_pc_program",N.midiPC.program},
{"midi_pc_value",N.midiPC.value},
{"midi_pitch_bend_channel",N.midiPitchBend.channel},
{"midi_pitch_bend_value",N.midiPitchBend.value},
{"midi_aftertouch_channel",N.midiAftertouch.channel},
{"midi_aftertouch_value",N.midiAftertouch.value},
{"midi_polypressure_channel",N.midiPolyPressure.channel},
{"midi_polypressure_value",N.midiPolyPressure.value},
{"connections",conns}};
}
friend void from_json(const json& j, ConfigNode& N){
std::cout << "configNode from_json" << std::endl;
j.at("id").get_to(N.id);
j.at("position").get_to<Vec2Df>(N.position);
j.at("distributionMode").get_to(N.distributionMode);
j.at("nodeType").get_to(N.nodeType);
j.at("midi_note_channel").get_to(N.midiNote.channel);
j.at("midi_note_note").get_to(N.midiNote.note);
j.at("midi_note_velocity").get_to(N.midiNote.velocity);
j.at("midi_note_gate").get_to(N.midiNote.gate);
j.at("midi_cc_channel").get_to(N.midiCC.channel);
j.at("midi_cc_control").get_to(N.midiCC.control);
j.at("midi_cc_value").get_to(N.midiCC.value);
j.at("midi_pc_channel").get_to(N.midiPC.channel);
j.at("midi_pc_program").get_to(N.midiPC.program);
j.at("midi_pc_value").get_to(N.midiPC.value);
j.at("midi_pitch_bend_channel").get_to(N.midiPitchBend.channel);
j.at("midi_pitch_bend_value").get_to(N.midiPitchBend.value);
j.at("midi_aftertouch_channel").get_to(N.midiAftertouch.channel);
j.at("midi_aftertouch_value").get_to(N.midiAftertouch.value);
j.at("midi_polypressure_channel").get_to(N.midiPolyPressure.channel);
j.at("midi_polypressure_value").get_to(N.midiPolyPressure.value);
//j.at("connections").get_to(N.connections);
}
};
}