2024-10-31 01:43:00 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2024-12-09 01:40:13 +01:00
|
|
|
#include "button.h"
|
2024-12-07 15:28:33 +01:00
|
|
|
#include "config-node.h"
|
2024-12-13 01:15:55 +01:00
|
|
|
#include "control-node.h"
|
2024-11-01 02:38:47 +01:00
|
|
|
#include "datatypes.h"
|
2024-12-07 22:09:06 +01:00
|
|
|
#include "edge.h"
|
2024-10-31 01:43:00 +01:00
|
|
|
#include "node.h"
|
2024-12-09 01:40:13 +01:00
|
|
|
#include "raylib.h"
|
2024-10-31 01:43:00 +01:00
|
|
|
#include "raymath.h"
|
2024-12-09 01:40:13 +01:00
|
|
|
#include "state.h"
|
2024-10-31 01:43:00 +01:00
|
|
|
#include <map>
|
2024-12-13 01:15:55 +01:00
|
|
|
#include <memory>
|
2024-12-09 01:40:13 +01:00
|
|
|
#include <random>
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-12-08 02:25:57 +01:00
|
|
|
namespace VISEQ::APP::UI{
|
|
|
|
|
class AppUI;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
namespace VISEQ::GRAPH::NODES {
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
class MidiNode : public Node{
|
2024-12-08 02:25:57 +01:00
|
|
|
friend class APP::UI::AppUI;
|
|
|
|
|
|
2024-12-07 15:28:33 +01:00
|
|
|
private:
|
2024-12-07 22:09:06 +01:00
|
|
|
MIDI::MidiNote midiNote;
|
|
|
|
|
MIDI::MidiCC midiCC;
|
2024-12-11 01:16:06 +01:00
|
|
|
MIDI::MidiPC midiPC;
|
2024-12-07 22:09:06 +01:00
|
|
|
MIDI::MidiPitchBend midiPitchBend;
|
|
|
|
|
MIDI::MidiAftertouch midiAftertouch;
|
|
|
|
|
MIDI::MidiPolyPressure midiPolyPressure;
|
2024-12-09 01:40:13 +01:00
|
|
|
|
|
|
|
|
std::vector<APP::UI::ButtonRound> channelButtons;
|
2024-12-07 15:28:33 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
public:
|
2024-11-14 01:37:16 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
struct NodeMidiOut{
|
|
|
|
|
int i;
|
|
|
|
|
std::string name;
|
|
|
|
|
bool enabled;
|
|
|
|
|
};
|
2024-11-02 15:52:16 +01:00
|
|
|
|
2024-12-09 01:40:13 +01:00
|
|
|
MidiNode() {init();}
|
|
|
|
|
MidiNode(Vec2Df position) : Node(position) {init();}
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
NodeType nodeType = NodeType::MIDINODE;
|
2024-12-13 01:15:55 +01:00
|
|
|
|
|
|
|
|
//std::vector<std::shared_ptr<ControlNode>> controlNodes;
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
bool send_note = true;
|
|
|
|
|
bool send_cc = false;
|
|
|
|
|
bool send_pc = false;
|
|
|
|
|
bool send_pitch_bend = false;
|
2024-11-01 02:38:47 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
int midi_out = -1;
|
|
|
|
|
|
|
|
|
|
std::map<int, NodeMidiOut> midi_outs;
|
2024-11-01 02:38:47 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
bool gui_midi_channel_edit = false;
|
|
|
|
|
bool gui_midi_note_edit = false;
|
|
|
|
|
bool gui_midi_velocity_edit = false;
|
|
|
|
|
bool gui_midi_gate_edit = false;
|
|
|
|
|
|
|
|
|
|
float start = 0;
|
|
|
|
|
float fade = 0;
|
|
|
|
|
float time = 0;
|
|
|
|
|
float last = 0;
|
2024-12-09 01:40:13 +01:00
|
|
|
|
|
|
|
|
void init(){
|
|
|
|
|
channelButtons.clear();
|
|
|
|
|
for(int i = 0; i < 16; ++i){
|
|
|
|
|
channelButtons.emplace_back(position, 4.0f, VS_COLOR_YELLOW);
|
|
|
|
|
channelButtons.back().hover_color = VS_COLOR_PINK;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-12-05 00:01:42 +01:00
|
|
|
std::shared_ptr<MidiNode> getPtr(){
|
|
|
|
|
return std::static_pointer_cast<MidiNode>(shared_from_this());
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
virtual NodeType getNodeType() const override {return nodeType;}
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-11-14 01:37:16 +01:00
|
|
|
void setMidiPort(int midi_port, bool _state){
|
|
|
|
|
midi_outs[midi_port].enabled = _state;
|
2024-10-31 01:43:00 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
void trigger() override {
|
|
|
|
|
triggered = true;
|
|
|
|
|
start = GetTime();
|
2024-12-08 14:21:46 +01:00
|
|
|
fade = getNotes().gate;
|
2024-11-03 03:48:49 +01:00
|
|
|
}
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-12-08 14:21:46 +01:00
|
|
|
void setMode(int _mode) override {
|
2024-11-03 03:48:49 +01:00
|
|
|
mode = _mode;
|
|
|
|
|
}
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-12-08 02:25:57 +01:00
|
|
|
MIDI::MidiNote getNotes() const {
|
2024-12-07 22:09:06 +01:00
|
|
|
MIDI::MidiNote cNote;
|
|
|
|
|
for(auto cn : getConnectedConfigNodes()){
|
|
|
|
|
cNote += cn.lock()->getNotes();
|
|
|
|
|
}
|
2024-12-08 02:25:57 +01:00
|
|
|
return midiNote + cNote;
|
2024-12-07 22:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-08 02:25:57 +01:00
|
|
|
MIDI::MidiCC getCC() const {
|
2024-12-07 22:09:06 +01:00
|
|
|
MIDI::MidiCC cCC;
|
|
|
|
|
for(auto cn : getConnectedConfigNodes()){
|
|
|
|
|
cCC += cn.lock()->getCC();
|
|
|
|
|
}
|
2024-12-08 02:25:57 +01:00
|
|
|
return midiCC + cCC;
|
2024-12-07 22:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-08 02:25:57 +01:00
|
|
|
MIDI::MidiPC getPC() const {
|
2024-12-07 22:09:06 +01:00
|
|
|
MIDI::MidiPC cPC;
|
|
|
|
|
for(auto cn : getConnectedConfigNodes()){
|
|
|
|
|
cPC += cn.lock()->getPC();
|
|
|
|
|
}
|
2024-12-08 02:25:57 +01:00
|
|
|
return midiPC + cPC;
|
2024-12-07 22:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-08 02:25:57 +01:00
|
|
|
MIDI::MidiPitchBend getPitchBend() const {
|
2024-12-07 22:09:06 +01:00
|
|
|
MIDI::MidiPitchBend cPitchBend;
|
|
|
|
|
for(auto cn : getConnectedConfigNodes()){
|
|
|
|
|
cPitchBend += cn.lock()->getPitchBend();
|
|
|
|
|
}
|
2024-12-08 02:25:57 +01:00
|
|
|
return midiPitchBend + cPitchBend;
|
2024-12-07 22:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-08 02:25:57 +01:00
|
|
|
MIDI::MidiAftertouch getAftertouch() const {
|
2024-12-07 22:09:06 +01:00
|
|
|
MIDI::MidiAftertouch cAftertouch;
|
|
|
|
|
for(auto cn : getConnectedConfigNodes()){
|
|
|
|
|
cAftertouch += cn.lock()->getAftertouch();
|
|
|
|
|
}
|
2024-12-08 02:25:57 +01:00
|
|
|
return midiAftertouch + cAftertouch;
|
2024-12-07 22:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-08 02:25:57 +01:00
|
|
|
MIDI::MidiPolyPressure getPolyPressure() const {
|
2024-12-07 22:09:06 +01:00
|
|
|
MIDI::MidiPolyPressure cPolyPressure;
|
|
|
|
|
for(auto cn : getConnectedConfigNodes()){
|
|
|
|
|
cPolyPressure += cn.lock()->getPolyPressure();
|
|
|
|
|
}
|
2024-12-08 02:25:57 +01:00
|
|
|
return midiPolyPressure + cPolyPressure;
|
2024-12-07 22:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-08 02:25:57 +01:00
|
|
|
std::vector<std::weak_ptr<ConfigNode>> getConnectedConfigNodes() const {
|
2024-12-07 15:28:33 +01:00
|
|
|
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()));
|
|
|
|
|
}
|
2024-12-08 14:21:46 +01:00
|
|
|
/*std::cout << "id: " << id << " n cn: " << config_nodes.size() << std::endl;*/
|
2024-12-07 15:28:33 +01:00
|
|
|
return config_nodes;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-30 02:54:40 +01:00
|
|
|
void update() override {
|
|
|
|
|
Node::update();
|
2024-12-08 02:25:57 +01:00
|
|
|
mode = state->node_mode;
|
2024-12-07 15:28:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void modMidiNote(int incr){
|
2024-12-07 22:09:06 +01:00
|
|
|
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;
|
2024-12-07 15:28:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void modMidiCC(int incr){
|
2024-12-07 22:09:06 +01:00
|
|
|
midiCC.control += incr;
|
|
|
|
|
if(midiCC.control < 0 ) midiCC.control = 127;
|
|
|
|
|
if(midiCC.control > 127 ) midiCC.control = 0;
|
2024-12-07 15:28:33 +01:00
|
|
|
}
|
2024-12-07 22:09:06 +01:00
|
|
|
|
2024-12-11 01:16:06 +01:00
|
|
|
void modMidiPC(int incr){
|
|
|
|
|
midiPC.program += incr;
|
|
|
|
|
if(midiPC.program < 0 ) midiPC.program = 127;
|
|
|
|
|
if(midiPC.program > 127 ) midiPC.program = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-07 15:28:33 +01:00
|
|
|
void modMidiPitchBend(int incr){
|
2024-12-07 22:09:06 +01:00
|
|
|
midiPitchBend.value += incr;
|
|
|
|
|
if(midiPitchBend.value < 0 ) midiPitchBend.value = 0;
|
|
|
|
|
if(midiPitchBend.value > 16383 ) midiPitchBend.value = 16383;
|
2024-11-30 02:54:40 +01:00
|
|
|
}
|
2024-12-11 01:16:06 +01:00
|
|
|
|
|
|
|
|
void modMidiAftertouch(int incr){
|
|
|
|
|
midiAftertouch.value += incr;
|
|
|
|
|
if(midiAftertouch.value < 0 ) midiAftertouch.value = 0;
|
|
|
|
|
if(midiAftertouch.value > 127 ) midiAftertouch.value = 127;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void modMidiPolyPressure(int incr){
|
|
|
|
|
midiPolyPressure.value += incr;
|
|
|
|
|
if(midiPolyPressure.value < 0 ) midiPolyPressure.value = 0;
|
|
|
|
|
if(midiPolyPressure.value > 127 ) midiPolyPressure.value = 127;
|
|
|
|
|
}
|
2024-11-21 02:03:32 +01:00
|
|
|
|
2024-11-14 00:55:09 +01:00
|
|
|
void interact(){
|
2024-11-14 01:37:16 +01:00
|
|
|
float wheel = GetMouseWheelMove();
|
2024-11-14 00:55:09 +01:00
|
|
|
|
2024-11-19 01:04:06 +01:00
|
|
|
if(KEYS_DOWN.ctrl && !KEYS_DOWN.alt){
|
2024-11-24 03:08:06 +01:00
|
|
|
switch(state->node_mode){
|
2024-11-14 00:55:09 +01:00
|
|
|
case 0:{
|
2024-12-07 15:28:33 +01:00
|
|
|
modMidiNote(wheel);
|
2024-11-14 00:55:09 +01:00
|
|
|
break;}
|
|
|
|
|
case 1:{
|
2024-12-07 15:28:33 +01:00
|
|
|
modMidiCC(wheel);
|
2024-11-14 00:55:09 +01:00
|
|
|
break;}
|
|
|
|
|
case 2:{
|
2024-12-11 01:16:06 +01:00
|
|
|
modMidiPC(wheel);
|
|
|
|
|
break;}
|
|
|
|
|
case 3:{
|
2024-12-07 15:28:33 +01:00
|
|
|
modMidiPitchBend(wheel);
|
2024-11-14 00:55:09 +01:00
|
|
|
break;}
|
2024-12-11 01:16:06 +01:00
|
|
|
case 4:{
|
|
|
|
|
modMidiAftertouch(wheel);
|
|
|
|
|
break;}
|
|
|
|
|
case 5:{
|
|
|
|
|
modMidiPolyPressure(wheel);
|
|
|
|
|
break;}
|
2024-11-14 00:55:09 +01:00
|
|
|
};
|
2024-11-19 01:04:06 +01:00
|
|
|
} else if(KEYS_DOWN.shift && !KEYS_DOWN.alt) {
|
2024-12-07 22:09:06 +01:00
|
|
|
midiNote.velocity += wheel;
|
|
|
|
|
if(midiNote.velocity < 0 ) midiNote.velocity = 127;
|
|
|
|
|
if(midiNote.velocity > 127 ) midiNote.velocity = 0;
|
2024-11-19 01:04:06 +01:00
|
|
|
} else if(KEYS_DOWN.alt) {
|
2024-11-24 03:08:06 +01:00
|
|
|
switch(state->node_mode){
|
2024-11-14 00:55:09 +01:00
|
|
|
case 0:{
|
2024-11-19 01:04:06 +01:00
|
|
|
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
2024-12-07 22:09:06 +01:00
|
|
|
midiNote.gate += incr;
|
|
|
|
|
if(midiNote.gate < 0 ) midiNote.gate = 0;
|
2024-11-14 00:55:09 +01:00
|
|
|
break;}
|
|
|
|
|
case 1:{
|
2024-12-07 22:09:06 +01:00
|
|
|
midiCC.value += wheel;
|
|
|
|
|
if(midiCC.value < 0 ) midiCC.value = 0;
|
|
|
|
|
if(midiCC.value > 127 ) midiCC.value = 127;
|
2024-11-14 00:55:09 +01:00
|
|
|
break;}
|
|
|
|
|
case 2:{
|
2024-12-11 01:16:06 +01:00
|
|
|
midiPC.value += wheel;
|
|
|
|
|
if(midiPC.value < 0 ) midiPC.value = 0;
|
|
|
|
|
if(midiPC.value > 127 ) midiPC.value = 127;
|
|
|
|
|
break;}
|
|
|
|
|
case 3:{
|
2024-11-19 01:04:06 +01:00
|
|
|
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
2024-12-07 22:09:06 +01:00
|
|
|
midiPitchBend.value += incr;
|
|
|
|
|
if(midiPitchBend.value < 0 ) midiPitchBend.value = 0;
|
|
|
|
|
if(midiPitchBend.value > 16383 ) midiPitchBend.value = 16383;
|
2024-11-14 00:55:09 +01:00
|
|
|
break;}
|
2024-12-11 01:16:06 +01:00
|
|
|
case 4:{
|
|
|
|
|
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
|
|
|
|
midiAftertouch.value += incr;
|
|
|
|
|
if(midiAftertouch.value < 0 ) midiAftertouch.value = 0;
|
|
|
|
|
if(midiAftertouch.value > 127 ) midiAftertouch.value = 127;
|
|
|
|
|
break;}
|
|
|
|
|
case 5:{
|
|
|
|
|
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
|
|
|
|
midiPolyPressure.value += incr;
|
|
|
|
|
if(midiPolyPressure.value < 0 ) midiPolyPressure.value = 0;
|
|
|
|
|
if(midiPolyPressure.value > 127 ) midiPolyPressure.value = 127;
|
|
|
|
|
break;}
|
2024-11-14 00:55:09 +01:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
void draw(Vec2Df mouse, Camera2D cam) override {
|
2024-11-12 01:42:05 +01:00
|
|
|
Node::draw();
|
2024-12-13 00:30:31 +01:00
|
|
|
/*if(hovering()) {*/
|
|
|
|
|
/* radius += radius < hover_radius ? 2 : 0;*/
|
|
|
|
|
/*} else {*/
|
|
|
|
|
/* radius -= radius > node_radius ? 2 : 0;*/
|
|
|
|
|
/*}*/
|
2024-12-09 01:40:13 +01:00
|
|
|
|
2024-11-17 02:40:31 +01:00
|
|
|
if(hovering() || selected) interact();
|
2024-11-14 01:37:16 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
last = time;
|
|
|
|
|
time = GetTime();
|
2024-12-08 14:21:46 +01:00
|
|
|
if(time - start >= (float)getNotes().gate / 1000.0f){
|
2024-11-03 03:48:49 +01:00
|
|
|
triggered = false;
|
|
|
|
|
fade = 0;
|
|
|
|
|
} else {
|
|
|
|
|
fade -= (time - last)*1000.0f;
|
2024-10-31 01:43:00 +01:00
|
|
|
}
|
2024-11-03 03:48:49 +01:00
|
|
|
|
2024-12-09 01:40:13 +01:00
|
|
|
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) * getNotes().velocity - 90.0f, 24, (Color){158, 134, 200, 255});
|
2024-11-03 03:48:49 +01:00
|
|
|
DrawCircleLinesV(position, radius + 4, (Color){100, 100, 100, 255});
|
|
|
|
|
|
2024-12-08 14:21:46 +01:00
|
|
|
float midi_gate_map = round((255.f / getNotes().gate) * fade);
|
2024-11-03 03:48:49 +01:00
|
|
|
|
|
|
|
|
Color gate_color = VS_COLOR_GREEN;
|
|
|
|
|
|
2024-10-31 01:43:00 +01:00
|
|
|
switch(mode){
|
|
|
|
|
case 0:{
|
2024-11-03 03:48:49 +01:00
|
|
|
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){180, 210, 115, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
2024-10-31 01:43:00 +01:00
|
|
|
break;}
|
|
|
|
|
case 1:{
|
2024-11-03 03:48:49 +01:00
|
|
|
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){229, 181, 103, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
2024-10-31 01:43:00 +01:00
|
|
|
break;}
|
|
|
|
|
case 2:{
|
2024-11-03 03:48:49 +01:00
|
|
|
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){232, 125, 62, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
2024-10-31 01:43:00 +01:00
|
|
|
break;}
|
|
|
|
|
}
|
2024-11-16 00:29:01 +01:00
|
|
|
if(!picked_up && !selected && !in_selection_rect && !hovering()) DrawCircle(position.x, position.y, radius, gate_color);
|
2024-11-18 01:57:10 +01:00
|
|
|
if(picked_up || in_selection_rect || hovering()) DrawCircle(position.x, position.y, radius, (Color){108, 153, 187, 255});
|
2024-11-17 02:40:31 +01:00
|
|
|
if(selected) DrawCircle(position.x, position.y, radius, (Color){255, 153, 187, 255});
|
2024-10-31 01:43:00 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
if(distributionMode == Distribution::RANDOM) DrawCircle(position.x, position.y, radius/2.0f, VS_COLOR_PINK);
|
|
|
|
|
if(distributionMode == Distribution::ROUNDROBIN) DrawCircle(position.x, position.y, radius/2.0f, VS_COLOR_YELLOW);
|
|
|
|
|
|
|
|
|
|
if(selected) DrawCircleLinesV(position, radius+8, (Color){158, 255, 210, 255});
|
2024-12-09 01:40:13 +01:00
|
|
|
|
2024-12-13 00:30:31 +01:00
|
|
|
/*if(hovering()){*/
|
|
|
|
|
/* for(int i = 0; i < 16; ++i){*/
|
|
|
|
|
/* channelButtons.at(i).position = position.orbitAtAngle(radius - 6.0f, DEG2RAD * (360.0f/16.0f)*i);*/
|
|
|
|
|
/* Color col = VS_COLOR_YELLOW;*/
|
|
|
|
|
/* if(mode == 0 && midiNote.channel == i) col = VS_COLOR_PINK;*/
|
|
|
|
|
/* if(mode == 1 && midiCC.channel == i) col = VS_COLOR_PINK;*/
|
|
|
|
|
/* if(mode == 2 && midiPitchBend.channel == i) col = VS_COLOR_PINK;*/
|
|
|
|
|
/* channelButtons.at(i).color = col;*/
|
|
|
|
|
/* channelButtons.at(i).draw();*/
|
|
|
|
|
/* if(channelButtons.at(i).hovering()) DrawCenteredText(std::format("{}", i+1), position + (Vec2Df){0,10.0f}, 8, VS_COLOR_WHITE);*/
|
|
|
|
|
/* if(channelButtons.at(i).clicked()) {*/
|
|
|
|
|
/* if(mode == 0) midiNote.channel = i;*/
|
|
|
|
|
/* if(mode == 1) midiCC.channel = i;*/
|
|
|
|
|
/* if(mode == 2) midiPitchBend.channel = i;*/
|
|
|
|
|
/* }*/
|
|
|
|
|
/* }*/
|
|
|
|
|
/*}*/
|
2024-11-03 03:48:49 +01:00
|
|
|
|
2024-11-19 01:04:06 +01:00
|
|
|
if(KEYS_DOWN.alt){
|
2024-11-03 03:48:49 +01:00
|
|
|
float value = 0;
|
|
|
|
|
int offset_gate = 0;
|
|
|
|
|
switch(mode){
|
|
|
|
|
case 0:
|
2024-12-08 02:25:57 +01:00
|
|
|
value = (float)getNotes().gate/1000.0f;
|
2024-11-03 03:48:49 +01:00
|
|
|
offset_gate = MeasureText(std::format("{:.2f}", value).c_str(), 12);
|
2024-12-13 00:30:31 +01:00
|
|
|
DrawText(std::format("{:.2f}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
2024-11-03 03:48:49 +01:00
|
|
|
break;
|
|
|
|
|
case 1:
|
2024-12-08 02:25:57 +01:00
|
|
|
value = (float)getCC().value;
|
2024-11-03 03:48:49 +01:00
|
|
|
offset_gate = MeasureText(std::format("{}", value).c_str(), 12);
|
2024-12-13 00:30:31 +01:00
|
|
|
DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
2024-11-03 03:48:49 +01:00
|
|
|
break;
|
|
|
|
|
case 2:
|
2024-12-08 02:25:57 +01:00
|
|
|
value = (float)getPitchBend().value;
|
2024-11-03 03:48:49 +01:00
|
|
|
offset_gate = MeasureText(std::format("{}", value).c_str(), 12);
|
2024-12-13 00:30:31 +01:00
|
|
|
DrawText(std::format("{}",value).c_str(), position.x-offset_gate/2.0f, position.y-5, 12, WHITE );
|
2024-11-03 03:48:49 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
switch(mode){
|
|
|
|
|
case 0:{
|
2024-12-08 02:25:57 +01:00
|
|
|
int offset = MeasureText(MIDI::Notes[(int)getNotes().note].c_str(), 12);
|
2024-12-13 00:30:31 +01:00
|
|
|
DrawText(MIDI::Notes[getNotes().note].c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
2024-11-03 03:48:49 +01:00
|
|
|
break;}
|
|
|
|
|
case 1:{
|
2024-12-08 02:25:57 +01:00
|
|
|
int offset = MeasureText(std::format("{}", getCC().control).c_str(), 12);
|
2024-12-13 00:30:31 +01:00
|
|
|
DrawText(std::format("{}", getCC().control).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
2024-11-03 03:48:49 +01:00
|
|
|
break;}
|
|
|
|
|
case 2:{
|
2024-12-08 02:25:57 +01:00
|
|
|
int offset = MeasureText(std::format("{}", getPitchBend().value).c_str(), 12);
|
2024-12-13 00:30:31 +01:00
|
|
|
DrawText(std::format("{}", getPitchBend().value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
2024-11-03 03:48:49 +01:00
|
|
|
break;}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-02 15:52:16 +01:00
|
|
|
|
2024-11-03 03:48:49 +01:00
|
|
|
if(highlighted) DrawCircleLinesV(position, radius+2, (Color){255, 0, 0, 200});
|
2024-12-09 01:40:13 +01:00
|
|
|
//DrawText(std::format("{}", id).c_str(), position.x + 20.0f, position.y + 20.0f, 10, WHITE);
|
2024-11-03 03:48:49 +01:00
|
|
|
}
|
2024-12-08 02:25:57 +01:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2024-11-03 03:48:49 +01:00
|
|
|
};
|
|
|
|
|
}
|