compiling but mouse interaction is dead
This commit is contained in:
@@ -1,32 +1,16 @@
|
|||||||
CXX = g++
|
CXX = g++
|
||||||
CXXFLAGS = -std=c++23 -Wall -g -fno-omit-frame-pointer -gdwarf-4 -Og -Wnarrowing -DLIBREMIDI_ALSA=1 -DLIBREMIDI_HEADER_ONLY=1
|
|
||||||
CXXINC = -isysteminclude
|
|
||||||
|
|
||||||
LDLIBS = -lraylib -lasound -llibremidi -pthread
|
LDLIBS = -lraylib -lasound -llibremidi -pthread
|
||||||
LDFLAGS = -Llib -L/usr/lib -L/usr/local/lib
|
LDFLAGS = -Llib -L/usr/lib -L/usr/local/lib
|
||||||
|
|
||||||
hdr_files = ${wildcard src/*.h}
|
hdr_files = $(wildcard src/*.h)
|
||||||
|
|
||||||
src_files = ${wildcard src/*.cpp}
|
|
||||||
#src_files += ${wildcard include/libremidi/*.cpp}
|
|
||||||
|
|
||||||
all: viseq
|
all: viseq
|
||||||
|
|
||||||
viseq: $(src_files) $(hdr_files)
|
viseq:
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
$(CXX) ${wildcard build/*.o} -o viseq $(LDFLAGS) $(LDLIBS)
|
cd src; $(MAKE)
|
||||||
|
$(CXX) $(wildcard build/*.o) -o viseq $(LDFLAGS) $(LDLIBS)
|
||||||
$(src_files): %.cpp : %_src
|
|
||||||
$(CXX) -c $@ -o build/$(*F).o $(CXXFLAGS) $(CXXINC)
|
|
||||||
|
|
||||||
$(hdr_files): %.h : %_hdr
|
|
||||||
$(NOECHO) $(NOOP)
|
|
||||||
|
|
||||||
%_src:
|
|
||||||
$(NOECHO) $(NOOP)
|
|
||||||
|
|
||||||
%_hdr:
|
|
||||||
$(NOECHO) $(NOOP)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f build/*
|
rm -f build/*
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
CXX = g++
|
||||||
|
CXXFLAGS = -std=c++23 -Wall -g -fno-omit-frame-pointer -gdwarf-4 -Og -Wnarrowing -DLIBREMIDI_ALSA=1 -DLIBREMIDI_HEADER_ONLY=1
|
||||||
|
CXXINC = -I../include -isysteminclude
|
||||||
|
|
||||||
|
obj_files = main.o app-manager.o graph-manager.o signal-manager.o interaction-manager.o ui.o node.o midi-node.o config-node.o modifier-node.o midi.o signal.o canvas.o state.o edge.o
|
||||||
|
|
||||||
|
|
||||||
|
all: $(obj_files)
|
||||||
|
|
||||||
|
$(obj_files): %.o : %.cpp
|
||||||
|
$(CXX) -c $^ -o ../build/$@ $(CXXFLAGS) $(CXXINC)
|
||||||
|
|
||||||
|
#all: viseq
|
||||||
|
|
||||||
|
#viseq: main.o app-manager.o graph-manager.o signal-manager.o interaction-manager.o ui.o node.o midi-node.o config-node.o modifier-node.o midi.o signal.o canvas.o state.o edge.o
|
||||||
|
# $(CXX) ${wildcard build/*.o} -o viseq $(LDFLAGS) $(LDLIBS)
|
||||||
|
|
||||||
|
#main.o:
|
||||||
|
# $(CXX) -c src/main.cpp -o ../build/main.o $(CXXFLAGS) $(CXXINC)
|
||||||
|
#
|
||||||
|
#app-manager.o:
|
||||||
|
# $(CXX) -c src/app-manager.cpp -o ../build/app-manager.o $(CXXFLAGS) $(CXXINC)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#src/canvas.cpp
|
||||||
|
#src/signal.cpp
|
||||||
|
#src/midi.cpp
|
||||||
|
#src/node.cpp
|
||||||
|
#src/graph-manager.cpp
|
||||||
|
#src/modifier-node.cpp
|
||||||
|
#src/config-node.cpp
|
||||||
|
#src/midi-node.cpp
|
||||||
|
#src/ui.cpp
|
||||||
|
#src/state.cpp
|
||||||
|
#src/edge.cpp
|
||||||
|
#src/interaction-manager.cpp
|
||||||
|
#src/signal-manager.cpp
|
||||||
|
#src/app-manager.cpp
|
||||||
|
#src/main.cpp
|
||||||
@@ -1,5 +1,15 @@
|
|||||||
#include "app-manager.h"
|
#include "app-manager.h"
|
||||||
|
|
||||||
|
#include "interaction-manager.h"
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
#include "graph-manager.h"
|
||||||
|
#include "midi-node.h"
|
||||||
|
#include "state.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
namespace VISEQ::APP{
|
namespace VISEQ::APP{
|
||||||
void AppManager::init(){
|
void AppManager::init(){
|
||||||
canvas->camera.target = (Vector2){ state->settings.width/2.0f, state->settings.height/2.0f };
|
canvas->camera.target = (Vector2){ state->settings.width/2.0f, state->settings.height/2.0f };
|
||||||
|
|||||||
+2
-7
@@ -1,15 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <filesystem>
|
|
||||||
#include <fstream>
|
|
||||||
#include "interaction-manager.h"
|
#include "interaction-manager.h"
|
||||||
#include "nlohmann/json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
#include "datatypes.h"
|
|
||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
#include "graph-manager.h"
|
#include "graph-manager.h"
|
||||||
#include "midi-node.h"
|
#include "midi-node.h"
|
||||||
#include "node.h"
|
|
||||||
#include "raylib.h"
|
|
||||||
#include "signal-manager.h"
|
#include "signal-manager.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
@@ -34,8 +29,6 @@ namespace VISEQ::APP {
|
|||||||
|
|
||||||
UI::AppUI ui;
|
UI::AppUI ui;
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(AppManager, gm, sm);
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void close();
|
void close();
|
||||||
void startSignals();
|
void startSignals();
|
||||||
@@ -46,4 +39,6 @@ namespace VISEQ::APP {
|
|||||||
void drawUI();
|
void drawUI();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(AppManager, gm, sm)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,4 +282,12 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
|
|
||||||
//j.at("connections").get_to(N.connections);
|
//j.at("connections").get_to(N.connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void to_json(json& j, const std::shared_ptr<ConfigNode>& N){
|
||||||
|
j = *N;
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, std::shared_ptr<ConfigNode>& N){
|
||||||
|
N.reset(new ConfigNode(j.get<ConfigNode>()));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
void update() override;
|
void update() override;
|
||||||
void interact();
|
void interact();
|
||||||
void draw(Vec2Df mouse, Camera2D cam) override;
|
void draw(Vec2Df mouse, Camera2D cam) override;
|
||||||
|
|
||||||
friend void to_json(json& j, const ConfigNode& N);
|
friend void to_json(json& j, const ConfigNode& N);
|
||||||
friend void from_json(const json& j, ConfigNode& N);
|
friend void from_json(const json& j, ConfigNode& N);
|
||||||
|
friend void to_json(json& j, const std::shared_ptr<ConfigNode>& N);
|
||||||
|
friend void from_json(const json& j, std::shared_ptr<ConfigNode>& N);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#include "edge.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include "node.h"
|
||||||
|
|
||||||
|
namespace VISEQ::GRAPH::EDGES {
|
||||||
|
bool Edge::GActive() {return active;}
|
||||||
|
|
||||||
|
EdgeType Edge::getEdgeType() const {return edgeType;}
|
||||||
|
|
||||||
|
std::weak_ptr<NODES::Node> Edge::getNextNode(std::weak_ptr<NODES::Node> origin){
|
||||||
|
return start.lock() == origin.lock() ? end : start;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Edge::draw(Vec2Df mouse_pos, Camera2D cam) {}
|
||||||
|
|
||||||
|
void to_json(json& j, const VISEQ::GRAPH::EDGES::Edge& E){
|
||||||
|
j = json{{"id",E.id}, {"start", E.start.lock()->id}, {"end",E.end.lock()->id}, {"pass_forward",E.pass_forward}, {"pass_backward", E.pass_backward}};
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, Edge& E){
|
||||||
|
j.at("id").get_to(E.id);
|
||||||
|
j.at("pass_forward").get_to(E.pass_forward);
|
||||||
|
j.at("pass_backward").get_to(E.pass_backward);
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(json& j, const VISEQ::GRAPH::EDGES::SPTR_Edge& E){
|
||||||
|
j = *E;
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, VISEQ::GRAPH::EDGES::SPTR_Edge& E){
|
||||||
|
E.reset(new Edge(j.get<Edge>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+8
-9
@@ -35,15 +35,14 @@ namespace VISEQ::GRAPH::EDGES {
|
|||||||
float connector_offset = 8.0f;
|
float connector_offset = 8.0f;
|
||||||
float switches_offset = 25.0f;
|
float switches_offset = 25.0f;
|
||||||
|
|
||||||
virtual bool GActive() {return active;}
|
virtual bool GActive();
|
||||||
|
virtual EdgeType getEdgeType() const;
|
||||||
virtual EdgeType getEdgeType() const {return edgeType;}
|
std::weak_ptr<NODES::Node> getNextNode(std::weak_ptr<NODES::Node> origin);
|
||||||
|
void draw(Vec2Df mouse_pos, Camera2D cam);
|
||||||
std::weak_ptr<NODES::Node> getNextNode(std::weak_ptr<NODES::Node> origin){
|
friend void to_json(json& j, const Edge& E);
|
||||||
return start.lock() == origin.lock() ? end : start;
|
friend void from_json(const json& j, Edge& E);
|
||||||
}
|
friend void to_json(json& j, const std::shared_ptr<Edge>& E);
|
||||||
|
friend void from_json(const json& j, std::shared_ptr<Edge>& E);
|
||||||
void draw(Vec2Df mouse_pos, Camera2D cam) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<Edge> SPTR_Edge;
|
typedef std::shared_ptr<Edge> SPTR_Edge;
|
||||||
|
|||||||
@@ -460,4 +460,12 @@ namespace VISEQ::GRAPH{
|
|||||||
n->draw(mouse_pos, camera);
|
n->draw(mouse_pos, camera);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void to_json(json& j, const std::shared_ptr<GraphManager>& G){
|
||||||
|
j = *G;
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, std::shared_ptr<GraphManager>& G){
|
||||||
|
G.reset(new GraphManager(j.get<GraphManager>()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ namespace VISEQ::GRAPH {
|
|||||||
void drawNodes(Vec2Df mouse_pos, Camera2D camera);
|
void drawNodes(Vec2Df mouse_pos, Camera2D camera);
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(GraphManager, nodes, edges, selected_nodes)
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(GraphManager, nodes, edges, selected_nodes)
|
||||||
|
|
||||||
|
friend void from_json(const json& j, std::shared_ptr<GraphManager>& G);
|
||||||
|
friend void to_json(json& j, const std::shared_ptr<GraphManager>& G);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <cmath>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -388,4 +388,12 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void to_json(json& j, const std::shared_ptr<MidiNode>& N){
|
||||||
|
j = *N;
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, std::shared_ptr<MidiNode>& N){
|
||||||
|
N.reset(new MidiNode(j.get<MidiNode>()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,11 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
void modMidiPolyPressure(int incr);
|
void modMidiPolyPressure(int incr);
|
||||||
void interact();
|
void interact();
|
||||||
void draw(Vec2Df mouse, Camera2D cam) override ;
|
void draw(Vec2Df mouse, Camera2D cam) override ;
|
||||||
|
|
||||||
friend void to_json(json& j, const MidiNode& N);
|
friend void to_json(json& j, const MidiNode& N);
|
||||||
friend void from_json(const json& j, MidiNode& N);
|
friend void from_json(const json& j, MidiNode& N);
|
||||||
|
friend void to_json(json& j, const std::shared_ptr<MidiNode>& N);
|
||||||
|
friend void from_json(const json& j, std::shared_ptr<MidiNode>& N);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
|
|
||||||
|
#include "midi-node.h"
|
||||||
|
#include "config-node.h"
|
||||||
|
|
||||||
namespace VISEQ::GRAPH::NODES {
|
namespace VISEQ::GRAPH::NODES {
|
||||||
void Node::setMode(int _mode) {mode = _mode;}
|
void Node::setMode(int _mode) {mode = _mode;}
|
||||||
|
|
||||||
@@ -70,4 +73,37 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
c->draw();
|
c->draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void to_json(json& j, const Node& N){
|
||||||
|
if(N.getNodeType() == NodeType::MIDINODE){
|
||||||
|
j = dynamic_cast<const MidiNode&>(N);
|
||||||
|
}
|
||||||
|
if(N.getNodeType() == NodeType::CONFIGNODE){
|
||||||
|
j = dynamic_cast<const ConfigNode&>(N);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, Node& N){
|
||||||
|
|
||||||
|
if(j.at("nodeType") == NodeType::MIDINODE){
|
||||||
|
N = j.template get<MidiNode>();
|
||||||
|
}
|
||||||
|
if(j.at("nodeType") == NodeType::CONFIGNODE){
|
||||||
|
N = j.template get<ConfigNode>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(json& j, const SPTR_Node& N){
|
||||||
|
j = *N;
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, std::shared_ptr<Node>& N){
|
||||||
|
std::cout << "SPTR_Node" << std::endl;
|
||||||
|
if(N->getNodeType() == NodeType::MIDINODE){
|
||||||
|
N.reset(new MidiNode(j.get<MidiNode>()));
|
||||||
|
}
|
||||||
|
if(N->getNodeType() == NodeType::CONFIGNODE){
|
||||||
|
N.reset(new ConfigNode(j.get<ConfigNode>()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -18,8 +18,7 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
class Node : public BASE::Draggable, public GraphItem, public std::enable_shared_from_this<Node> {
|
class Node : public BASE::Draggable, public GraphItem, public std::enable_shared_from_this<Node> {
|
||||||
|
|
||||||
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) {}
|
||||||
|
|
||||||
@@ -54,6 +53,11 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
void draw(Vec2Df mp, Camera2D cam) override;
|
void draw(Vec2Df mp, Camera2D cam) override;
|
||||||
void draw() override;
|
void draw() override;
|
||||||
|
|
||||||
|
friend void to_json(json& j, const Node& N);
|
||||||
|
friend void from_json(const json& j, Node& N);
|
||||||
|
friend void to_json(json& j, const std::shared_ptr<Node>& N);
|
||||||
|
friend void from_json(const json& j, std::shared_ptr<Node>& N);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<VISEQ::GRAPH::NODES::Node> SPTR_Node;
|
typedef std::shared_ptr<VISEQ::GRAPH::NODES::Node> SPTR_Node;
|
||||||
|
|||||||
+33
-23
@@ -10,47 +10,48 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
namespace VISEQ::SIGNAL {
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::pause(){
|
void SignalManager::pause(){
|
||||||
play = false;
|
play = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::stop(){
|
void SignalManager::stop(){
|
||||||
play = false;
|
play = false;
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::start(){
|
void SignalManager::start(){
|
||||||
play = true;
|
play = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::reset(){
|
void SignalManager::reset(){
|
||||||
for(auto &s : signals){
|
for(auto &s : signals){
|
||||||
s->position = s->start.lock()->position + Vec2Df{0.1, 0.1};
|
s->position = s->start.lock()->position + Vec2Df{0.1, 0.1};
|
||||||
s->next = s->start;
|
s->next = s->start;
|
||||||
s->last = s->start;
|
s->last = s->start;
|
||||||
}
|
}
|
||||||
gm->reset();
|
gm->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::startSignalThread(){
|
void SignalManager::startSignalThread(){
|
||||||
std::thread t1(&SignalManager::updateSignals, this);
|
std::thread t1(&SignalManager::updateSignals, this);
|
||||||
t1.detach();
|
t1.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::stopSignalThread(){
|
void SignalManager::stopSignalThread(){
|
||||||
loop = false;
|
loop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::addSignalAtNode(WPTR_Node node){
|
void SignalManager::addSignalAtNode(WPTR_Node node){
|
||||||
Color c = {(unsigned char)(20 + (rand() % 200)), 100, (unsigned char)(20 + (int)(rand() % 200)), 200};
|
Color c = {(unsigned char)(20 + (rand() % 200)), 100, (unsigned char)(20 + (int)(rand() % 200)), 200};
|
||||||
signals.emplace_back(std::make_shared<Signal>(node.lock()->position + Vec2Df{0.5f, 0.5f}, 8.0f, 480, c)); // position + 1 or else it does not render. why? no idea!
|
signals.emplace_back(std::make_shared<Signal>(node.lock()->position + Vec2Df{0.5f, 0.5f}, 8.0f, 480, c)); // position + 1 or else it does not render. why? no idea!
|
||||||
signals.back()->next = node;
|
signals.back()->next = node;
|
||||||
signals.back()->last = node;
|
signals.back()->last = node;
|
||||||
signals.back()->start = node;
|
signals.back()->start = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::rerouteSignal(VEC_SPTR_Node nodes, VEC_WPTR_Node adjacent_nodes){
|
void SignalManager::rerouteSignal(VEC_SPTR_Node nodes, VEC_WPTR_Node adjacent_nodes){
|
||||||
auto reroute_signals = signals | RANGE_FILTER([nodes](SIGNAL::SPTR_Signal s){return std::ranges::contains(nodes, s->next.lock());});
|
auto reroute_signals = signals | RANGE_FILTER([nodes](SIGNAL::SPTR_Signal s){return std::ranges::contains(nodes, s->next.lock());});
|
||||||
|
|
||||||
for(auto s : reroute_signals){
|
for(auto s : reroute_signals){
|
||||||
@@ -66,21 +67,21 @@ void VISEQ::SIGNAL::SignalManager::rerouteSignal(VEC_SPTR_Node nodes, VEC_WPTR_N
|
|||||||
s->last = next_node;
|
s->last = next_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::rebaseSignal(VEC_SPTR_Node nodes){
|
void SignalManager::rebaseSignal(VEC_SPTR_Node nodes){
|
||||||
auto rebase_signals = signals | RANGE_FILTER([nodes](SIGNAL::SPTR_Signal s){return std::ranges::contains(nodes, s->start.lock());});
|
auto rebase_signals = signals | RANGE_FILTER([nodes](SIGNAL::SPTR_Signal s){return std::ranges::contains(nodes, s->start.lock());});
|
||||||
|
|
||||||
for(auto s : rebase_signals){
|
for(auto s : rebase_signals){
|
||||||
s->start = s->next;
|
s->start = s->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::removeSignal(std::shared_ptr<Signal> s){
|
void SignalManager::removeSignal(std::shared_ptr<Signal> s){
|
||||||
erase_signals.push_back(s);
|
erase_signals.push_back(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::updateSignals(){
|
void SignalManager::updateSignals(){
|
||||||
auto last = std::chrono::high_resolution_clock::now();
|
auto last = std::chrono::high_resolution_clock::now();
|
||||||
while(loop){
|
while(loop){
|
||||||
std::chrono::duration<double, std::micro> diff = std::chrono::high_resolution_clock::now() - last;
|
std::chrono::duration<double, std::micro> diff = std::chrono::high_resolution_clock::now() - last;
|
||||||
@@ -114,9 +115,9 @@ void VISEQ::SIGNAL::SignalManager::updateSignals(){
|
|||||||
last = std::chrono::high_resolution_clock::now();
|
last = std::chrono::high_resolution_clock::now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VISEQ::SIGNAL::SignalManager::drawSignals(Vec2Df mouse_pos, Camera2D camera){
|
void SignalManager::drawSignals(Vec2Df mouse_pos, Camera2D camera){
|
||||||
mutex->lock();
|
mutex->lock();
|
||||||
if(!erase_signals.empty()){
|
if(!erase_signals.empty()){
|
||||||
for(auto s: erase_signals){
|
for(auto s: erase_signals){
|
||||||
@@ -128,4 +129,13 @@ void VISEQ::SIGNAL::SignalManager::drawSignals(Vec2Df mouse_pos, Camera2D camera
|
|||||||
s->draw(mouse_pos, camera);
|
s->draw(mouse_pos, camera);
|
||||||
}
|
}
|
||||||
mutex->unlock();
|
mutex->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(json& j, const std::shared_ptr<SignalManager>& G){
|
||||||
|
j = *G;
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, std::shared_ptr<SignalManager>& G){
|
||||||
|
G.reset(new SignalManager(j.get<SignalManager>()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,5 +51,8 @@ namespace VISEQ::SIGNAL {
|
|||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(SignalManager, signals)
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(SignalManager, signals)
|
||||||
|
|
||||||
|
friend void from_json(const json& j, std::shared_ptr<SignalManager>& G);
|
||||||
|
friend void to_json(json& j, const std::shared_ptr<SignalManager>& G);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,34 @@ namespace VISEQ::SIGNAL {
|
|||||||
void Signal::draw(Vec2Df mouse, Camera2D cam) {
|
void Signal::draw(Vec2Df mouse, Camera2D cam) {
|
||||||
DrawCircle(position.x, position.y, radius, color);
|
DrawCircle(position.x, position.y, radius, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void to_json(json& j, const Signal& S){
|
||||||
|
std::map<std::string, int> fc = {{"r",S.color.r},{"g",S.color.g},{"b",S.color.b},{"a",S.color.a}};
|
||||||
|
j = json{{"color",fc},{"position", S.position},{"radius",S.radius},{"start",S.start.lock()->id},{"next",S.next.lock()->id},{"last",S.last.lock()->id},{"speed",S.speed},{"midi_note_offset",S.midi_note_offset},{"midi_cc_offset",S.midi_cc_offset},{"multiplier",S.multiplier}};
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, Signal& S){
|
||||||
|
|
||||||
|
Color c;
|
||||||
|
c.r = j.at("color")["r"].get<int>();
|
||||||
|
c.g = j.at("color")["g"].get<int>();
|
||||||
|
c.b = j.at("color")["b"].get<int>();
|
||||||
|
c.a = j.at("color")["a"].get<int>();
|
||||||
|
|
||||||
|
j.at("position").get_to<Vec2Df>(S.position);
|
||||||
|
j.at("speed").get_to<float>(S.speed);
|
||||||
|
j.at("radius").get_to<float>(S.radius);
|
||||||
|
j.at("midi_note_offset").get_to(S.midi_note_offset);
|
||||||
|
j.at("midi_cc_offset").get_to(S.midi_cc_offset);
|
||||||
|
|
||||||
|
S.color = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(json& j, const std::shared_ptr<Signal>& S){
|
||||||
|
j = *S;
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_json(const json& j, std::shared_ptr<Signal>& S){
|
||||||
|
S.reset(new Signal(j.get<Signal>()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -38,7 +38,13 @@ namespace VISEQ::SIGNAL {
|
|||||||
void reset();
|
void reset();
|
||||||
void toStart();
|
void toStart();
|
||||||
void update(double t_delta);
|
void update(double t_delta);
|
||||||
void draw(Vec2Df mouse, Camera2D cam) ;
|
void draw(Vec2Df mouse, Camera2D cam);
|
||||||
|
|
||||||
|
friend void to_json(json& j, const Signal& S);
|
||||||
|
friend void from_json(const json& j, Signal& S);
|
||||||
|
friend void to_json(json& j, const std::shared_ptr<Signal>& S);
|
||||||
|
friend void from_json(const json& j, std::shared_ptr<Signal>& S);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-117
@@ -15,94 +15,26 @@
|
|||||||
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;
|
||||||
|
|
||||||
namespace nlohmann {
|
//namespace nlohmann {
|
||||||
template <typename T>
|
// template <typename T>
|
||||||
struct adl_serializer<std::shared_ptr<T>> {
|
// struct adl_serializer<std::shared_ptr<T>> {
|
||||||
static void to_json(json& j, const std::shared_ptr<T>& opt) {
|
// static void to_json(json& j, const std::shared_ptr<T>& opt) {
|
||||||
if (opt) {
|
// if (opt) {
|
||||||
j = *opt;
|
// j = *opt;
|
||||||
} else {
|
// } else {
|
||||||
j = nullptr;
|
// j = nullptr;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
static void from_json(const json& j, std::shared_ptr<T>& opt) {
|
// static void from_json(const json& j, std::shared_ptr<T>& opt) {
|
||||||
if (j.is_null()) {
|
// if (j.is_null()) {
|
||||||
opt = nullptr;
|
// opt = nullptr;
|
||||||
} else {
|
// } else {
|
||||||
opt.reset(new T(j.get<T>()));
|
// opt.reset(new T(j.get<T>()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
}
|
//}
|
||||||
|
|
||||||
namespace VISEQ::GRAPH::EDGES {
|
|
||||||
using namespace VISEQ::GRAPH::NODES;
|
|
||||||
|
|
||||||
inline void to_json(json& j, const VISEQ::GRAPH::EDGES::Edge& E){
|
|
||||||
j = json{{"id",E.id}, {"start", E.start.lock()->id}, {"end",E.end.lock()->id}, {"pass_forward",E.pass_forward}, {"pass_backward", E.pass_backward}};
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void from_json(const json& j, Edge& E){
|
|
||||||
j.at("id").get_to(E.id);
|
|
||||||
j.at("pass_forward").get_to(E.pass_forward);
|
|
||||||
j.at("pass_backward").get_to(E.pass_backward);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void to_json(json& j, const VISEQ::GRAPH::EDGES::SPTR_Edge& E){
|
|
||||||
j = *E;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void from_json(const json& j, VISEQ::GRAPH::EDGES::SPTR_Edge& E){
|
|
||||||
E.reset(new Edge(j.get<Edge>()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace VISEQ::GRAPH::NODES {
|
|
||||||
|
|
||||||
/* ------------------- MIDINODE ---------------------- */
|
|
||||||
|
|
||||||
inline void to_json(json& j, const MidiNode::NodeMidiOut& MO){
|
|
||||||
j = json{{"port_id", MO.i}, {"enabled", MO.enabled}, {"name", MO.name}};
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------- NODE ---------------------- */
|
|
||||||
|
|
||||||
inline void to_json(json& j, const Node& N){
|
|
||||||
if(N.getNodeType() == NodeType::MIDINODE){
|
|
||||||
j = dynamic_cast<const MidiNode&>(N);
|
|
||||||
}
|
|
||||||
if(N.getNodeType() == NodeType::CONFIGNODE){
|
|
||||||
j = dynamic_cast<const ConfigNode&>(N);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void from_json(const json& j, Node& N){
|
|
||||||
|
|
||||||
if(j.at("nodeType") == NodeType::MIDINODE){
|
|
||||||
N = j.template get<MidiNode>();
|
|
||||||
}
|
|
||||||
if(j.at("nodeType") == NodeType::CONFIGNODE){
|
|
||||||
N = j.template get<ConfigNode>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void to_json(json& j, const SPTR_Node& N){
|
|
||||||
j = *N;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void from_json(const json& j, std::shared_ptr<Node>& N){
|
|
||||||
std::cout << "SPTR_Node" << std::endl;
|
|
||||||
if(N->getNodeType() == NodeType::MIDINODE){
|
|
||||||
N.reset(new MidiNode(j.get<MidiNode>()));
|
|
||||||
}
|
|
||||||
if(N->getNodeType() == NodeType::CONFIGNODE){
|
|
||||||
N.reset(new ConfigNode(j.get<ConfigNode>()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace VISEQ::GRAPH {
|
namespace VISEQ::GRAPH {
|
||||||
inline void to_json(json& j, const GraphItem& G){
|
inline void to_json(json& j, const GraphItem& G){
|
||||||
@@ -136,35 +68,35 @@ namespace VISEQ::BASE{
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace VISEQ::SIGNAL{
|
namespace VISEQ::SIGNAL{
|
||||||
inline void to_json(json& j, const Signal& G){
|
// inline void to_json(json& j, const Signal& G){
|
||||||
std::map<std::string, int> fc = {{"r",G.color.r},{"g",G.color.g},{"b",G.color.b},{"a",G.color.a}};
|
// std::map<std::string, int> fc = {{"r",G.color.r},{"g",G.color.g},{"b",G.color.b},{"a",G.color.a}};
|
||||||
j = json{{"color",fc},{"position", G.position},{"radius",G.radius},{"start",G.start.lock()->id},{"next",G.next.lock()->id},{"last",G.last.lock()->id},{"speed",G.speed},{"midi_note_offset",G.midi_note_offset},{"midi_cc_offset",G.midi_cc_offset},{"multiplier",G.multiplier}};
|
// j = json{{"color",fc},{"position", G.position},{"radius",G.radius},{"start",G.start.lock()->id},{"next",G.next.lock()->id},{"last",G.last.lock()->id},{"speed",G.speed},{"midi_note_offset",G.midi_note_offset},{"midi_cc_offset",G.midi_cc_offset},{"multiplier",G.multiplier}};
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
inline void from_json(const json& j, Signal& S){
|
// inline void from_json(const json& j, Signal& S){
|
||||||
|
//
|
||||||
Color c;
|
// Color c;
|
||||||
c.r = j.at("color")["r"].get<int>();
|
// c.r = j.at("color")["r"].get<int>();
|
||||||
c.g = j.at("color")["g"].get<int>();
|
// c.g = j.at("color")["g"].get<int>();
|
||||||
c.b = j.at("color")["b"].get<int>();
|
// c.b = j.at("color")["b"].get<int>();
|
||||||
c.a = j.at("color")["a"].get<int>();
|
// c.a = j.at("color")["a"].get<int>();
|
||||||
|
//
|
||||||
j.at("position").get_to<Vec2Df>(S.position);
|
// j.at("position").get_to<Vec2Df>(S.position);
|
||||||
j.at("speed").get_to<float>(S.speed);
|
// j.at("speed").get_to<float>(S.speed);
|
||||||
j.at("radius").get_to<float>(S.radius);
|
// j.at("radius").get_to<float>(S.radius);
|
||||||
j.at("midi_note_offset").get_to(S.midi_note_offset);
|
// j.at("midi_note_offset").get_to(S.midi_note_offset);
|
||||||
j.at("midi_cc_offset").get_to(S.midi_cc_offset);
|
// j.at("midi_cc_offset").get_to(S.midi_cc_offset);
|
||||||
|
//
|
||||||
S.color = c;
|
// S.color = c;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
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>()));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ namespace VISEQ::APP{
|
|||||||
old_istate = istate;
|
old_istate = istate;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static std::shared_ptr<State> get() {
|
std::shared_ptr<State> State::get() {
|
||||||
if(!State::instance){
|
if(!State::instance){
|
||||||
State::instance.reset(new State());
|
State::instance.reset(new State());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ namespace VISEQ::APP{
|
|||||||
void update(Camera2D camera);
|
void update(Camera2D camera);
|
||||||
|
|
||||||
inline static std::shared_ptr<State> instance;
|
inline static std::shared_ptr<State> instance;
|
||||||
inline static std::shared_ptr<State> get();
|
static std::shared_ptr<State> get();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "midi-node.h"
|
#include "midi-node.h"
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "raygui/raygui.h"
|
#include "raygui/raygui.h"
|
||||||
#include "raygui/dark/style_dark.h"
|
|
||||||
|
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user