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
+1 -4
View File
@@ -29,12 +29,9 @@ namespace VISEQ::APP {
std::shared_ptr<APP::State> state = APP::State::get(); std::shared_ptr<APP::State> state = APP::State::get();
std::shared_ptr<CANVAS::Canvas> canvas = std::make_shared<CANVAS::Canvas>(); std::shared_ptr<CANVAS::Canvas> canvas = std::make_shared<CANVAS::Canvas>();
//VISEQ::GRAPH::GraphManager gm;
//VISEQ::SIGNAL::SignalManager sm;
std::shared_ptr<GraphManager> gm = std::make_shared<GraphManager>(); std::shared_ptr<GraphManager> gm = std::make_shared<GraphManager>();
std::shared_ptr<SIGNAL::SignalManager> sm = std::make_shared<SIGNAL::SignalManager>(gm->getPtr(), &mutex); std::shared_ptr<SIGNAL::SignalManager> sm = std::make_shared<SIGNAL::SignalManager>(gm->getPtr(), &mutex);
VISEQ::INTERACTION::InteractionManager im; VISEQ::INTERACTION::InteractionManager im;
// VISEQ::APP::Mouse mouse;
UI::AppUI ui; UI::AppUI ui;
@@ -63,7 +60,7 @@ namespace VISEQ::APP {
json graph = json::parse(f); json graph = json::parse(f);
for(auto n : graph.at("gm").at("nodes")){ for(auto n : graph.at("gm").at("nodes")){
std::cout << "object? " << n.is_object() << std::endl; std::cout << "object? " << n << std::endl;
if(n.is_object()){ if(n.is_object()){
std::cout << "nodeType = " << n.at("nodeType").get<int>() << std::endl; std::cout << "nodeType = " << n.at("nodeType").get<int>() << std::endl;
+62 -14
View File
@@ -1,8 +1,10 @@
#pragma once #pragma once
#include "datatypes.h" #include "datatypes.h"
#include "edge.h"
#include "node.h" #include "node.h"
#include "raymath.h" #include "raymath.h"
#include "state.h"
#include <memory> #include <memory>
namespace VISEQ::GRAPH::NODES { namespace VISEQ::GRAPH::NODES {
@@ -81,24 +83,16 @@ namespace VISEQ::GRAPH::NODES {
if(KEYS_DOWN.ctrl && !KEYS_DOWN.alt){ if(KEYS_DOWN.ctrl && !KEYS_DOWN.alt){
switch(state->node_mode){ switch(state->node_mode){
case 0:{ case 0:{
midiNote.note += wheel; midiNote.note += KEYS_DOWN.shift ? ((wheel > 0) - (wheel < 0)) * 12 : wheel;
/* for(auto mn : midi_nodes){*/
/*mn.lock()->modMidiNote(wheel);*/
/* }*/
break;} break;}
case 1:{ case 1:{
midiCC.value += wheel; midiCC.value += KEYS_DOWN.shift ? ((wheel > 0) - (wheel < 0)) * 12 : wheel;
/* for(auto mn : midi_nodes){*/
/*mn.lock()->modMidiCC(wheel);*/
/* }*/
break;} break;}
case 2:{ case 2:{
midiPitchBend.value += wheel; midiPitchBend.value += KEYS_DOWN.shift ? ((wheel > 0) - (wheel < 0)) * 12 : wheel;
/* for(auto mn : midi_nodes){*/
/*mn.lock()->modMidiPitchBend(wheel);*/
/* }*/
break;} break;}
}; };
if(midiNote.note < -127 ) midiNote.note = -127; if(midiNote.note < -127 ) midiNote.note = -127;
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;
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) { } else if(KEYS_DOWN.alt) {
switch(state->node_mode){ switch(state->node_mode){
case 0:{ case 0:{
@@ -122,7 +115,7 @@ namespace VISEQ::GRAPH::NODES {
if(midiCC.channel > 15 ) midiCC.channel = 15; if(midiCC.channel > 15 ) midiCC.channel = 15;
break;} break;}
case 2:{ 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 < 0 ) midiPitchBend.channel = 0;
if(midiPitchBend.channel > 15 ) midiPitchBend.channel = 15; if(midiPitchBend.channel > 15 ) midiPitchBend.channel = 15;
break;} break;}
@@ -199,5 +192,60 @@ namespace VISEQ::GRAPH::NODES {
if(highlighted) DrawCircleLinesV(position, radius+2, (Color){255, 0, 0, 200}); 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); 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);
}
}; };
} }
+1 -1
View File
@@ -488,7 +488,7 @@ namespace VISEQ::GRAPH {
} }
NLOHMANN_DEFINE_TYPE_INTRUSIVE(GraphManager, nodes, edges) NLOHMANN_DEFINE_TYPE_INTRUSIVE(GraphManager, nodes, edges, selected_nodes)
/*inline void to_json(json& j, const GraphManager& G){*/ /*inline void to_json(json& j, const GraphManager& G){*/
/* j = json{{"nodes", G.nodes}, {"edges", G.edges}};*/ /* j = json{{"nodes", G.nodes}, {"edges", G.edges}};*/
+84 -24
View File
@@ -9,9 +9,15 @@
#define RADIUS 14.0f #define RADIUS 14.0f
namespace VISEQ::APP::UI{
class AppUI;
}
namespace VISEQ::GRAPH::NODES { namespace VISEQ::GRAPH::NODES {
class MidiNode : public Node{ class MidiNode : public Node{
friend class APP::UI::AppUI;
private: private:
MIDI::MidiNote midiNote; MIDI::MidiNote midiNote;
MIDI::MidiCC midiCC; MIDI::MidiCC midiCC;
@@ -80,55 +86,56 @@ namespace VISEQ::GRAPH::NODES {
return midiNote.gate; return midiNote.gate;
} }
MIDI::MidiNote getNotes(){ MIDI::MidiNote getNotes() const {
MIDI::MidiNote cNote; MIDI::MidiNote cNote;
for(auto cn : getConnectedConfigNodes()){ for(auto cn : getConnectedConfigNodes()){
cNote += cn.lock()->getNotes(); cNote += cn.lock()->getNotes();
} }
return cNote; std::cout << cNote.note << std::endl;
return midiNote + cNote;
} }
MIDI::MidiCC getCC(){ MIDI::MidiCC getCC() const {
MIDI::MidiCC cCC; MIDI::MidiCC cCC;
for(auto cn : getConnectedConfigNodes()){ for(auto cn : getConnectedConfigNodes()){
cCC += cn.lock()->getCC(); cCC += cn.lock()->getCC();
} }
return cCC; return midiCC + cCC;
} }
MIDI::MidiPC getPC(){ MIDI::MidiPC getPC() const {
MIDI::MidiPC cPC; MIDI::MidiPC cPC;
for(auto cn : getConnectedConfigNodes()){ for(auto cn : getConnectedConfigNodes()){
cPC += cn.lock()->getPC(); cPC += cn.lock()->getPC();
} }
return cPC; return midiPC + cPC;
} }
MIDI::MidiPitchBend getPitchBend(){ MIDI::MidiPitchBend getPitchBend() const {
MIDI::MidiPitchBend cPitchBend; MIDI::MidiPitchBend cPitchBend;
for(auto cn : getConnectedConfigNodes()){ for(auto cn : getConnectedConfigNodes()){
cPitchBend += cn.lock()->getPitchBend(); cPitchBend += cn.lock()->getPitchBend();
} }
return cPitchBend; return midiPitchBend + cPitchBend;
} }
MIDI::MidiAftertouch getAftertouch(){ MIDI::MidiAftertouch getAftertouch() const {
MIDI::MidiAftertouch cAftertouch; MIDI::MidiAftertouch cAftertouch;
for(auto cn : getConnectedConfigNodes()){ for(auto cn : getConnectedConfigNodes()){
cAftertouch += cn.lock()->getAftertouch(); cAftertouch += cn.lock()->getAftertouch();
} }
return cAftertouch; return midiAftertouch + cAftertouch;
} }
MIDI::MidiPolyPressure getPolyPressure(){ MIDI::MidiPolyPressure getPolyPressure() const {
MIDI::MidiPolyPressure cPolyPressure; MIDI::MidiPolyPressure cPolyPressure;
for(auto cn : getConnectedConfigNodes()){ for(auto cn : getConnectedConfigNodes()){
cPolyPressure += cn.lock()->getPolyPressure(); cPolyPressure += cn.lock()->getPolyPressure();
} }
return cPolyPressure; return midiPolyPressure + cPolyPressure;
} }
std::vector<std::weak_ptr<ConfigNode>> getConnectedConfigNodes(){ std::vector<std::weak_ptr<ConfigNode>> getConnectedConfigNodes() const {
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>>>(); 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; std::vector<std::weak_ptr<ConfigNode>> config_nodes;
for(auto e : config_conns){ for(auto e : config_conns){
@@ -140,8 +147,7 @@ namespace VISEQ::GRAPH::NODES {
void update() override { void update() override {
Node::update(); Node::update();
mode = state->node_mode; mode = state->node_mode;
} }
int getMidiNote(){ int getMidiNote(){
@@ -257,17 +263,17 @@ namespace VISEQ::GRAPH::NODES {
int offset_gate = 0; int offset_gate = 0;
switch(mode){ switch(mode){
case 0: case 0:
value = (float)midiNote.gate/1000.0f; value = (float)getNotes().gate/1000.0f;
offset_gate = MeasureText(std::format("{:.2f}", value).c_str(), 12); 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 ); DrawText(std::format("{:.2f}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
break; break;
case 1: case 1:
value = (float)midiCC.value; value = (float)getCC().value;
offset_gate = MeasureText(std::format("{}", value).c_str(), 12); 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 ); DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
break; break;
case 2: case 2:
value = (float)midiPitchBend.value; value = (float)getPitchBend().value;
offset_gate = MeasureText(std::format("{}", value).c_str(), 12); 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 ); DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
break; break;
@@ -275,16 +281,16 @@ namespace VISEQ::GRAPH::NODES {
} else { } else {
switch(mode){ switch(mode){
case 0:{ case 0:{
int offset = MeasureText(MIDI::Notes[(int)midiNote.note].c_str(), 12); int offset = MeasureText(MIDI::Notes[(int)getNotes().note].c_str(), 12);
DrawText(MIDI::Notes[midiNote.note].c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE ); DrawText(MIDI::Notes[getNotes().note].c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
break;} break;}
case 1:{ case 1:{
int offset = MeasureText(std::format("{}", midiCC.control).c_str(), 12); int offset = MeasureText(std::format("{}", getCC().control).c_str(), 12);
DrawText(std::format("{}", midiCC.control).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE ); DrawText(std::format("{}", getCC().control).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
break;} break;}
case 2:{ case 2:{
int offset = MeasureText(std::format("{}", midiPitchBend.value).c_str(), 12); int offset = MeasureText(std::format("{}", getPitchBend().value).c_str(), 12);
DrawText(std::format("{}", midiPitchBend.value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE ); DrawText(std::format("{}", getPitchBend().value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
break;} break;}
} }
} }
@@ -292,5 +298,59 @@ namespace VISEQ::GRAPH::NODES {
if(highlighted) DrawCircleLinesV(position, radius+2, (Color){255, 0, 0, 200}); 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); DrawText(std::format("{}", id).c_str(), position.x + 20.0f, position.y + 20.0f, 10, WHITE);
} }
friend void to_json(json& j, const MidiNode& 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, MidiNode& N){
std::cout << "MidiNode" << 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);
}
}; };
} }
+1 -1
View File
@@ -21,7 +21,7 @@ namespace VISEQ::GRAPH::NODES {
public: public:
Node() {} Node() {std::cout << "Node constructor" << std::endl;}
Node(float x, float y) : Draggable(Vec2Df(x, y)) {} Node(float x, float y) : Draggable(Vec2Df(x, y)) {}
Node(Vec2Df p) : Draggable(p) {} Node(Vec2Df p) : Draggable(p) {}
+7 -94
View File
@@ -5,7 +5,6 @@
#include "graph-item.h" #include "graph-item.h"
#include "node.h" #include "node.h"
#include "edge.h" #include "edge.h"
//#include "graph-manager.h"
#include "datatypes.h" #include "datatypes.h"
#include "signal.h" #include "signal.h"
@@ -13,11 +12,6 @@
#include <iostream> #include <iostream>
#include <memory> #include <memory>
/*using namespace VISEQ::BASE;*/
/*using namespace VISEQ::SIGNAL;*/
/*using namespace VISEQ::GRAPH::NODES;*/
/*using namespace VISEQ::GRAPH::EDGES;*/
typedef std::shared_ptr<VISEQ::GRAPH::GraphItem> SPTR_GraphItem; typedef std::shared_ptr<VISEQ::GRAPH::GraphItem> SPTR_GraphItem;
typedef std::vector<SPTR_GraphItem> VEC_SPTR_GraphItem; typedef std::vector<SPTR_GraphItem> VEC_SPTR_GraphItem;
@@ -58,7 +52,7 @@ namespace VISEQ::GRAPH::EDGES {
inline void to_json(json& j, const VISEQ::GRAPH::EDGES::SPTR_Edge& E){ inline void to_json(json& j, const VISEQ::GRAPH::EDGES::SPTR_Edge& E){
j = *E; j = *E;
} }
inline void from_json(const json& j, VISEQ::GRAPH::EDGES::SPTR_Edge& E){ inline void from_json(const json& j, VISEQ::GRAPH::EDGES::SPTR_Edge& E){
E.reset(new Edge(j.get<Edge>())); E.reset(new Edge(j.get<Edge>()));
} }
@@ -68,55 +62,10 @@ namespace VISEQ::GRAPH::NODES {
/* ------------------- MIDINODE ---------------------- */ /* ------------------- MIDINODE ---------------------- */
inline void to_json(json& j, const MidiNode& 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.getNotes().channel},
{"midi_note",N.getNotes().note},
{"midi_velocity",N.midi_velocity},
{"midi_gate",N.midi_gate},
{"midi_cc_channel",N.midi_cc_channel},
{"midi_cc",N.midi_cc},
{"midi_cc_value",N.midi_cc_value},
{"midi_pc_channel",N.midi_pc_channel},
{"midi_pc_value",N.midi_pc_value},
{"midi_pitch_bend_channel",N.midi_pitch_bend_channel},
{"midi_pitch_bend",N.midi_pitch_bend},
{"connections",conns}};
}
inline void from_json(const json& j, MidiNode& N){
std::cout << "MidiNode" << 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.getNotes().channel);
j.at("midi_note").get_to(N.getNotes().note);
j.at("midi_velocity").get_to(N.midi_velocity);
j.at("midi_gate").get_to(N.midi_gate);
j.at("midi_cc_channel").get_to(N.midi_cc_channel);
j.at("midi_cc").get_to(N.midi_cc);
j.at("midi_cc_value").get_to(N.midi_cc_value);
j.at("midi_pc_channel").get_to(N.midi_pc_channel);
j.at("midi_pc_value").get_to(N.midi_pc_value);
j.at("midi_pitch_bend_channel").get_to(N.midi_pitch_bend_channel);
j.at("midi_pitch_bend").get_to(N.midi_pitch_bend);
//j.at("connections").get_to(N.connections);
}
inline void to_json(json& j, const std::shared_ptr<MidiNode>& N){ inline void to_json(json& j, const std::shared_ptr<MidiNode>& N){
j = *N; j = *N;
} }
inline void from_json(const json& j, std::shared_ptr<MidiNode>& N){ inline void from_json(const json& j, std::shared_ptr<MidiNode>& N){
N.reset(new MidiNode(j.get<MidiNode>())); N.reset(new MidiNode(j.get<MidiNode>()));
} }
@@ -127,45 +76,11 @@ namespace VISEQ::GRAPH::NODES {
/* ----------------- CONFIG NODE -----------------*/ /* ----------------- CONFIG NODE -----------------*/
inline 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.getNotes().channel},
{"midi_note",N.getNotes().note},
{"midi_cc_channel",N.midiCC.channel},
{"midi_cc",N.midiCC.value},
{"midi_pitch_bend_channel",N.midiPitchBend.channel},
{"midi_pitch_bend",N.midiPitchBend.value},
{"connections",conns}};
}
inline void from_json(const json& j, ConfigNode& N){
std::cout << "ConfigNode" << 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.getNotes().channel);
j.at("midi_note").get_to(N.getNotes().note);
j.at("midi_cc_channel").get_to(N.midiCC.channel);
j.at("midi_cc").get_to(N.midiCC.value);
j.at("midi_pitch_bend_channel").get_to(N.midiPitchBend.channel);
j.at("midi_pitch_bend").get_to(N.midiPitchBend.value);
//j.at("connections").get_to(N.connections);
}
inline void to_json(json& j, const std::shared_ptr<ConfigNode>& N){ inline void to_json(json& j, const std::shared_ptr<ConfigNode>& N){
j = *N; j = *N;
} }
inline void from_json(const json& j, std::shared_ptr<ConfigNode>& N){ inline void from_json(const json& j, std::shared_ptr<ConfigNode>& N){
N.reset(new ConfigNode(j.get<ConfigNode>())); N.reset(new ConfigNode(j.get<ConfigNode>()));
} }
@@ -185,11 +100,9 @@ namespace VISEQ::GRAPH::NODES {
inline void from_json(const json& j, Node& N){ inline void from_json(const json& j, Node& N){
if(j.at("nodeType") == NodeType::MIDINODE){ if(j.at("nodeType") == NodeType::MIDINODE){
std::cout << j.at("nodeType") << std::endl;
N = j.template get<MidiNode>(); N = j.template get<MidiNode>();
} }
if(j.at("nodeType") == NodeType::CONFIGNODE){ if(j.at("nodeType") == NodeType::CONFIGNODE){
std::cout << j.at("nodeType") << std::endl;
N = j.template get<ConfigNode>(); N = j.template get<ConfigNode>();
} }
} }
@@ -197,7 +110,7 @@ namespace VISEQ::GRAPH::NODES {
inline void to_json(json& j, const SPTR_Node& N){ inline void to_json(json& j, const SPTR_Node& N){
j = *N; j = *N;
} }
inline void from_json(const json& j, std::shared_ptr<Node>& N){ inline void from_json(const json& j, std::shared_ptr<Node>& N){
std::cout << "SPTR_Node" << std::endl; std::cout << "SPTR_Node" << std::endl;
N.reset(new Node(j.get<Node>())); N.reset(new Node(j.get<Node>()));
@@ -229,11 +142,11 @@ namespace VISEQ::BASE{
inline void from_json(const json& j, Movable& G){ inline void from_json(const json& j, Movable& G){
std::cout << "Movable" << std::endl; std::cout << "Movable" << std::endl;
// j = json{{"position", G.position}}; j.at("position").get_to<Vec2Df>(G.position);
} }
inline void from_json(json& j, const std::shared_ptr<Movable>& G){ inline void from_json(json& j, const std::shared_ptr<Movable>& G){
// j = *G; j = *G;
} }
} }
@@ -263,7 +176,7 @@ namespace VISEQ::SIGNAL{
inline void to_json(json& j, const std::shared_ptr<Signal>& G){ inline void to_json(json& j, const std::shared_ptr<Signal>& G){
j = *G; j = *G;
} }
inline void from_json(const json& j, std::shared_ptr<Signal>& S){ inline void from_json(const json& j, std::shared_ptr<Signal>& S){
S.reset(new Signal(j.get<Signal>())); S.reset(new Signal(j.get<Signal>()));
} }
+21 -21
View File
@@ -139,55 +139,55 @@ namespace VISEQ::APP::UI{
switch(state->node_mode){ switch(state->node_mode){
case 0:{ case 0:{
GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note - 75, 220, 20}, "NOTE CHANNEL"); GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note - 75, 220, 20}, "NOTE CHANNEL");
GuiToggleGroup((Rectangle){np.x + 20, np.y + y_cc_note - 50, 25, 20}, "1;2;3;4;5;6;7;8\n9;10;11;12;13;14;15;16", &mn->midi_note_channel); GuiToggleGroup((Rectangle){np.x + 20, np.y + y_cc_note - 50, 25, 20}, "1;2;3;4;5;6;7;8\n9;10;11;12;13;14;15;16", &mn->midiNote.channel);
GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note , 100, 20}, "NOTE"); GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note , 100, 20}, "NOTE");
float v = mn->midi_note; float v = mn->midiNote.note;
GuiLabel((Rectangle){np.x + 210, np.y + y_cc_note , 20, 20}, MIDI::Notes[(int)round(v)].c_str()); GuiLabel((Rectangle){np.x + 210, np.y + y_cc_note , 20, 20}, MIDI::Notes[(int)round(v)].c_str());
GuiLabel((Rectangle){np.x + 160, np.y + y_cc_note , 40, 20}, std::format("{}",mn->midi_note).c_str()); GuiLabel((Rectangle){np.x + 160, np.y + y_cc_note , 40, 20}, std::format("{}",mn->midiNote.note).c_str());
GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 30, 220, 20}, "", "", &v, 0, 127); GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 30, 220, 20}, "", "", &v, 0, 127);
mn->midi_note = round(v); mn->midiNote.note = round(v);
GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note + 60, 100, 20}, "VELOCITY"); GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note + 60, 100, 20}, "VELOCITY");
v = mn->midi_velocity; v = mn->midiNote.velocity;
GuiLabel((Rectangle){np.x + 210, np.y + y_cc_note + 60, 20, 20}, std::format("{}",mn->midi_velocity).c_str()); GuiLabel((Rectangle){np.x + 210, np.y + y_cc_note + 60, 20, 20}, std::format("{}",mn->midiNote.velocity).c_str());
GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 90, 220, 20}, "", "", &v, 0, 127); GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 90, 220, 20}, "", "", &v, 0, 127);
mn->midi_velocity = round(v); mn->midiNote.velocity = round(v);
GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note + 120, 100, 20}, "GATE"); GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note + 120, 100, 20}, "GATE");
v = mn->midi_gate; v = mn->midiNote.gate;
GuiLabel((Rectangle){np.x + 210, np.y + y_cc_note + 120, 20, 20}, std::format("{}",(float)mn->midi_gate/1000.0f).c_str()); GuiLabel((Rectangle){np.x + 210, np.y + y_cc_note + 120, 20, 20}, std::format("{}",(float)mn->midiNote.gate/1000.0f).c_str());
GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 150, 220, 20}, "", "", &v, 0, 30000); GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 150, 220, 20}, "", "", &v, 0, 30000);
mn->midi_gate = round(v); mn->midiNote.gate= round(v);
break;} break;}
case 1: case 1:
{ {
GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note - 75, 220, 20}, "CC CHANNEL"); GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note - 75, 220, 20}, "CC CHANNEL");
GuiToggleGroup((Rectangle){np.x + 20, np.y + y_cc_note - 50, 25, 20}, "1;2;3;4;5;6;7;8\n9;10;11;12;13;14;15;16", &mn->midi_cc_channel); GuiToggleGroup((Rectangle){np.x + 20, np.y + y_cc_note - 50, 25, 20}, "1;2;3;4;5;6;7;8\n9;10;11;12;13;14;15;16", &mn->midiCC.channel);
GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note , 100, 20}, "CC"); GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note , 100, 20}, "CC");
float v = mn->midi_cc; float v = mn->midiCC.control;
GuiLabel((Rectangle){np.x + 160, np.y + y_cc_note , 40, 20}, std::format("{}",mn->midi_cc).c_str()); GuiLabel((Rectangle){np.x + 160, np.y + y_cc_note , 40, 20}, std::format("{}",mn->midiCC.control).c_str());
GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 30, 220, 20}, "", "", &v, 0, 127); GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 30, 220, 20}, "", "", &v, 0, 127);
mn->midi_cc = round(v); mn->midiCC.control = round(v);
GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note + 60, 100, 20}, "CC VALUE"); GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note + 60, 100, 20}, "CC VALUE");
v = mn->midi_cc_value; v = mn->midiCC.value;
GuiLabel((Rectangle){np.x + 210, np.y + y_cc_note + 60, 20, 20}, std::format("{}",mn->midi_cc_value).c_str()); GuiLabel((Rectangle){np.x + 210, np.y + y_cc_note + 60, 20, 20}, std::format("{}",mn->midiCC.value).c_str());
GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 90, 220, 20}, "", "", &v, 0, 127); GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 90, 220, 20}, "", "", &v, 0, 127);
mn->midi_cc_value = round(v); mn->midiCC.value = round(v);
break;} break;}
case 2: case 2:
{ {
GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note - 75, 220, 20}, "PITCH BEND CHANNEL"); GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note - 75, 220, 20}, "PITCH BEND CHANNEL");
GuiToggleGroup((Rectangle){np.x + 20, np.y + y_cc_note - 50, 25, 20}, "1;2;3;4;5;6;7;8\n9;10;11;12;13;14;15;16", &mn->midi_pitch_bend_channel); GuiToggleGroup((Rectangle){np.x + 20, np.y + y_cc_note - 50, 25, 20}, "1;2;3;4;5;6;7;8\n9;10;11;12;13;14;15;16", &mn->midiPitchBend.channel);
GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note , 100, 20}, "CC"); GuiLabel((Rectangle){np.x + 20, np.y + y_cc_note , 100, 20}, "CC");
float v = mn->midi_pitch_bend; float v = mn->midiPitchBend.value;
GuiLabel((Rectangle){np.x + 160, np.y + y_cc_note , 40, 20}, std::format("{}",mn->midi_pitch_bend).c_str()); GuiLabel((Rectangle){np.x + 160, np.y + y_cc_note , 40, 20}, std::format("{}",mn->midiPitchBend.value).c_str());
GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 30, 220, 20}, "", "", &v, 0, 16383); GuiSlider((Rectangle){np.x + 20, np.y + y_cc_note + 30, 220, 20}, "", "", &v, 0, 16383);
mn->midi_pitch_bend = round(v); mn->midiPitchBend.value = round(v);
break;} break;}
} }
} }