Inbetween states. Midi nodes and config nodes use same interface now.
This commit is contained in:
+44
-22
@@ -1,12 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "edge.h"
|
|
||||||
#include "midi-node.h"
|
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace VISEQ::GRAPH::NODES {
|
namespace VISEQ::GRAPH::NODES {
|
||||||
|
|
||||||
@@ -27,6 +24,7 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
MIDI::MidiPitchBend midiPitchBend;
|
MIDI::MidiPitchBend midiPitchBend;
|
||||||
MIDI::MidiPolyPressure midiPolyPressure;
|
MIDI::MidiPolyPressure midiPolyPressure;
|
||||||
MIDI::MidiPC midiPC;
|
MIDI::MidiPC midiPC;
|
||||||
|
MIDI::MidiAftertouch midiAftertouch;
|
||||||
|
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
float radius = 20.0f;
|
float radius = 20.0f;
|
||||||
@@ -37,44 +35,68 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MIDI::MidiNote getNotes(){
|
||||||
|
return midiNote;
|
||||||
|
}
|
||||||
|
|
||||||
|
MIDI::MidiCC getCC(){
|
||||||
|
return midiCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
MIDI::MidiPC getPC(){
|
||||||
|
return midiPC;
|
||||||
|
}
|
||||||
|
|
||||||
|
MIDI::MidiPitchBend getPitchBend(){
|
||||||
|
return midiPitchBend;
|
||||||
|
}
|
||||||
|
|
||||||
|
MIDI::MidiPolyPressure getPolyPressure(){
|
||||||
|
return midiPolyPressure;
|
||||||
|
}
|
||||||
|
|
||||||
|
MIDI::MidiAftertouch getAftertouch(){
|
||||||
|
return midiAftertouch;
|
||||||
|
}
|
||||||
|
|
||||||
void update() override {
|
void update() override {
|
||||||
Node::update();
|
Node::update();
|
||||||
mode = state->node_mode;
|
mode = state->node_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::weak_ptr<MidiNode>> getConnectedMidiNodes(){
|
/*std::vector<std::weak_ptr<MidiNode>> getConnectedMidiNodes(){*/
|
||||||
auto midi_conns = connections | RANGE_FILTER([](EDGES::SPTR_Edge c){ return c->start.lock()->getNodeType() == NodeType::MIDINODE || c->end.lock()->getNodeType() == NodeType::MIDINODE;}) | std::ranges::to<std::vector<std::shared_ptr<EDGES::Edge>>>();
|
/* auto midi_conns = connections | RANGE_FILTER([](EDGES::SPTR_Edge c){ return c->start.lock()->getNodeType() == NodeType::MIDINODE || c->end.lock()->getNodeType() == NodeType::MIDINODE;}) | std::ranges::to<std::vector<std::shared_ptr<EDGES::Edge>>>();*/
|
||||||
std::vector<std::weak_ptr<MidiNode>> midi_nodes;
|
/* std::vector<std::weak_ptr<MidiNode>> midi_nodes;*/
|
||||||
for(auto e : midi_conns){
|
/* for(auto e : midi_conns){*/
|
||||||
if(e->start.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->start.lock()));
|
/* if(e->start.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->start.lock()));*/
|
||||||
if(e->end.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->end.lock()));
|
/* if(e->end.lock()->getNodeType() == NodeType::MIDINODE) midi_nodes.push_back(std::dynamic_pointer_cast<MidiNode>(e->end.lock()));*/
|
||||||
}
|
/* }*/
|
||||||
return midi_nodes;
|
/* return midi_nodes;*/
|
||||||
}
|
/*}*/
|
||||||
|
|
||||||
void interact(){
|
void interact(){
|
||||||
float wheel = GetMouseWheelMove();
|
float wheel = GetMouseWheelMove();
|
||||||
auto midi_nodes = getConnectedMidiNodes();
|
/*auto midi_nodes = getConnectedMidiNodes();*/
|
||||||
|
|
||||||
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 += wheel;
|
||||||
for(auto mn : midi_nodes){
|
/* for(auto mn : midi_nodes){*/
|
||||||
mn.lock()->modMidiNote(wheel);
|
/*mn.lock()->modMidiNote(wheel);*/
|
||||||
}
|
/* }*/
|
||||||
break;}
|
break;}
|
||||||
case 1:{
|
case 1:{
|
||||||
midiCC.value += wheel;
|
midiCC.value += wheel;
|
||||||
for(auto mn : midi_nodes){
|
/* for(auto mn : midi_nodes){*/
|
||||||
mn.lock()->modMidiCC(wheel);
|
/*mn.lock()->modMidiCC(wheel);*/
|
||||||
}
|
/* }*/
|
||||||
break;}
|
break;}
|
||||||
case 2:{
|
case 2:{
|
||||||
midiPitchBend.value += wheel;
|
midiPitchBend.value += wheel;
|
||||||
for(auto mn : midi_nodes){
|
/* for(auto mn : midi_nodes){*/
|
||||||
mn.lock()->modMidiPitchBend(wheel);
|
/*mn.lock()->modMidiPitchBend(wheel);*/
|
||||||
}
|
/* }*/
|
||||||
break;}
|
break;}
|
||||||
};
|
};
|
||||||
if(midiNote.note < -127 ) midiNote.note = -127;
|
if(midiNote.note < -127 ) midiNote.note = -127;
|
||||||
|
|||||||
+195
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#endif
|
#endif
|
||||||
@@ -86,6 +87,200 @@ namespace VISEQ::MIDI{
|
|||||||
int number;
|
int number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline MidiNote operator+(const MidiNote left, const MidiNote right){
|
||||||
|
MidiNote added;
|
||||||
|
added.note = left.note + right.note;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.gate = left.gate + right.gate;
|
||||||
|
added.velocity = left.velocity + right.velocity;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiCC operator+(const MidiCC left, const MidiCC right){
|
||||||
|
MidiCC added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.control = left.control + right.control;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPC operator+(const MidiPC left, const MidiPC right){
|
||||||
|
MidiPC added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.program = left.program + right.program;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPitchBend operator+(const MidiPitchBend left, const MidiPitchBend right){
|
||||||
|
MidiPitchBend added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiAftertouch operator+(const MidiAftertouch left, const MidiAftertouch right){
|
||||||
|
MidiAftertouch added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPolyPressure operator+(const MidiPolyPressure left, const MidiPolyPressure right){
|
||||||
|
MidiPolyPressure added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.note = left.note + right.note;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiNote operator-(const MidiNote left, const MidiNote right){
|
||||||
|
MidiNote added;
|
||||||
|
added.note = left.note - right.note;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.gate = left.gate - right.gate;
|
||||||
|
added.velocity = left.velocity - right.velocity;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiCC operator-(const MidiCC left, const MidiCC right){
|
||||||
|
MidiCC added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.control = left.control - right.control;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPC operator-(const MidiPC left, const MidiPC right){
|
||||||
|
MidiPC added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.program = left.program - right.program;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPitchBend operator-(const MidiPitchBend left, const MidiPitchBend right){
|
||||||
|
MidiPitchBend added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiAftertouch operator-(const MidiAftertouch left, const MidiAftertouch right){
|
||||||
|
MidiAftertouch added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPolyPressure operator-(const MidiPolyPressure left, const MidiPolyPressure right){
|
||||||
|
MidiPolyPressure added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.note = left.note - right.note;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
// UNARY
|
||||||
|
|
||||||
|
inline MidiNote operator+=(const MidiNote left, const MidiNote right){
|
||||||
|
MidiNote added;
|
||||||
|
added.note = left.note + right.note;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.gate = left.gate + right.gate;
|
||||||
|
added.velocity = left.velocity + right.velocity;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiCC operator+=(const MidiCC left, const MidiCC right){
|
||||||
|
MidiCC added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.control = left.control + right.control;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPC operator+=(const MidiPC left, const MidiPC right){
|
||||||
|
MidiPC added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.program = left.program + right.program;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPitchBend operator+=(const MidiPitchBend left, const MidiPitchBend right){
|
||||||
|
MidiPitchBend added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiAftertouch operator+=(const MidiAftertouch left, const MidiAftertouch right){
|
||||||
|
MidiAftertouch added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPolyPressure operator+=(const MidiPolyPressure left, const MidiPolyPressure right){
|
||||||
|
MidiPolyPressure added;
|
||||||
|
added.channel = left.channel + right.channel;
|
||||||
|
added.note = left.note + right.note;
|
||||||
|
added.value = left.value+ right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiNote operator-=(const MidiNote left, const MidiNote right){
|
||||||
|
MidiNote added;
|
||||||
|
added.note = left.note - right.note;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.gate = left.gate - right.gate;
|
||||||
|
added.velocity = left.velocity - right.velocity;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiCC operator-=(const MidiCC left, const MidiCC right){
|
||||||
|
MidiCC added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.control = left.control - right.control;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPC operator-=(const MidiPC left, const MidiPC right){
|
||||||
|
MidiPC added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.program = left.program - right.program;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPitchBend operator-=(const MidiPitchBend left, const MidiPitchBend right){
|
||||||
|
MidiPitchBend added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiAftertouch operator-=(const MidiAftertouch left, const MidiAftertouch right){
|
||||||
|
MidiAftertouch added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline MidiPolyPressure operator-=(const MidiPolyPressure left, const MidiPolyPressure right){
|
||||||
|
MidiPolyPressure added;
|
||||||
|
added.channel = left.channel - right.channel;
|
||||||
|
added.note = left.note - right.note;
|
||||||
|
added.value = left.value- right.value;
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Vec2D<T> operator*(const Vec2D<T> left, T scalar){*/
|
||||||
|
/* return Vec2D<T>(left.x * scalar, left.y * scalar);*/
|
||||||
|
/*};*/
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MidiOut, number)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MidiOut, number)
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MidiOutPort, number, enabled)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MidiOutPort, number, enabled)
|
||||||
|
|
||||||
|
|||||||
+90
-50
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "config-node.h"
|
#include "config-node.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
|
#include "edge.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -12,21 +13,12 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
|
|
||||||
class MidiNode : public Node{
|
class MidiNode : public Node{
|
||||||
private:
|
private:
|
||||||
int midi_note_channel = 1;
|
MIDI::MidiNote midiNote;
|
||||||
int midi_note = 48;
|
MIDI::MidiCC midiCC;
|
||||||
int midi_velocity = 60;
|
MIDI::MidiPitchBend midiPitchBend;
|
||||||
int midi_gate = 10; // gate time in milliseconds
|
MIDI::MidiAftertouch midiAftertouch;
|
||||||
|
MIDI::MidiPolyPressure midiPolyPressure;
|
||||||
int midi_cc_channel = 0;
|
MIDI::MidiPC midiPC;
|
||||||
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;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -77,7 +69,7 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
void trigger() override {
|
void trigger() override {
|
||||||
triggered = true;
|
triggered = true;
|
||||||
start = GetTime();
|
start = GetTime();
|
||||||
fade = midi_gate;
|
fade = midiNote.gate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMode(int _mode) override{
|
void SMode(int _mode) override{
|
||||||
@@ -85,7 +77,55 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int GGate(){
|
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(){
|
std::vector<std::weak_ptr<ConfigNode>> getConnectedConfigNodes(){
|
||||||
@@ -109,25 +149,25 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
for(auto cn : getConnectedConfigNodes()){
|
for(auto cn : getConnectedConfigNodes()){
|
||||||
mod_notes += cn.lock()->midiNote.note;
|
mod_notes += cn.lock()->midiNote.note;
|
||||||
}
|
}
|
||||||
return midi_note + mod_notes;
|
return midiNote.note + mod_notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void modMidiNote(int incr){
|
void modMidiNote(int incr){
|
||||||
midi_note += incr;
|
midiNote.note += incr;
|
||||||
if(midi_note < 0 ) midi_note = VISEQ::MIDI::Notes.size()-1;
|
if(midiNote.note < 0 ) midiNote.note = VISEQ::MIDI::Notes.size()-1;
|
||||||
if(midi_note >= (int)VISEQ::MIDI::Notes.size()) midi_note = 0;
|
if(midiNote.note >= (int)VISEQ::MIDI::Notes.size()) midiNote.note = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void modMidiCC(int incr){
|
void modMidiCC(int incr){
|
||||||
midi_cc += incr;
|
midiCC.control += incr;
|
||||||
if(midi_cc < 0 ) midi_cc = 127;
|
if(midiCC.control < 0 ) midiCC.control = 127;
|
||||||
if(midi_cc > 127 ) midi_cc = 0;
|
if(midiCC.control > 127 ) midiCC.control = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void modMidiPitchBend(int incr){
|
void modMidiPitchBend(int incr){
|
||||||
midi_pitch_bend += incr;
|
midiPitchBend.value += incr;
|
||||||
if(midi_pitch_bend < 0 ) midi_pitch_bend = 0;
|
if(midiPitchBend.value < 0 ) midiPitchBend.value = 0;
|
||||||
if(midi_pitch_bend > 16383 ) midi_pitch_bend = 16383;
|
if(midiPitchBend.value > 16383 ) midiPitchBend.value = 16383;
|
||||||
}
|
}
|
||||||
|
|
||||||
void interact(){
|
void interact(){
|
||||||
@@ -146,26 +186,26 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
break;}
|
break;}
|
||||||
};
|
};
|
||||||
} else if(KEYS_DOWN.shift && !KEYS_DOWN.alt) {
|
} else if(KEYS_DOWN.shift && !KEYS_DOWN.alt) {
|
||||||
midi_velocity += wheel;
|
midiNote.velocity += wheel;
|
||||||
if(midi_velocity < 0 ) midi_velocity = 127;
|
if(midiNote.velocity < 0 ) midiNote.velocity = 127;
|
||||||
if(midi_velocity > 127 ) midi_velocity = 0;
|
if(midiNote.velocity > 127 ) midiNote.velocity = 0;
|
||||||
} else if(KEYS_DOWN.alt) {
|
} else if(KEYS_DOWN.alt) {
|
||||||
switch(state->node_mode){
|
switch(state->node_mode){
|
||||||
case 0:{
|
case 0:{
|
||||||
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
||||||
midi_gate += incr;
|
midiNote.gate += incr;
|
||||||
if(midi_gate < 0 ) midi_gate = 0;
|
if(midiNote.gate < 0 ) midiNote.gate = 0;
|
||||||
break;}
|
break;}
|
||||||
case 1:{
|
case 1:{
|
||||||
midi_cc_value += wheel;
|
midiCC.value += wheel;
|
||||||
if(midi_cc_value < 0 ) midi_cc_value = 0;
|
if(midiCC.value < 0 ) midiCC.value = 0;
|
||||||
if(midi_cc_value > 127 ) midi_cc_value = 127;
|
if(midiCC.value > 127 ) midiCC.value = 127;
|
||||||
break;}
|
break;}
|
||||||
case 2:{
|
case 2:{
|
||||||
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
float incr = (float)wheel * (KEYS_DOWN.shift ? 100.0f : KEYS_DOWN.ctrl ? 1000.0f : 10.0f);
|
||||||
midi_pitch_bend += incr;
|
midiPitchBend.value += incr;
|
||||||
if(midi_pitch_bend < 0 ) midi_pitch_bend = 0;
|
if(midiPitchBend.value < 0 ) midiPitchBend.value = 0;
|
||||||
if(midi_pitch_bend > 16383 ) midi_pitch_bend = 16383;
|
if(midiPitchBend.value > 16383 ) midiPitchBend.value = 16383;
|
||||||
break;}
|
break;}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -177,7 +217,7 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
|
|
||||||
last = time;
|
last = time;
|
||||||
time = GetTime();
|
time = GetTime();
|
||||||
if(time - start >= (float)midi_gate / 1000.0f){
|
if(time - start >= (float)midiNote.gate / 1000.0f){
|
||||||
triggered = false;
|
triggered = false;
|
||||||
fade = 0;
|
fade = 0;
|
||||||
} else {
|
} 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, 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});
|
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;
|
Color gate_color = VS_COLOR_GREEN;
|
||||||
|
|
||||||
@@ -217,17 +257,17 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
int offset_gate = 0;
|
int offset_gate = 0;
|
||||||
switch(mode){
|
switch(mode){
|
||||||
case 0:
|
case 0:
|
||||||
value = (float)midi_gate/1000.0f;
|
value = (float)midiNote.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)midi_cc_value;
|
value = (float)midiCC.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)midi_pitch_bend;
|
value = (float)midiPitchBend.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;
|
||||||
@@ -235,16 +275,16 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
} else {
|
} else {
|
||||||
switch(mode){
|
switch(mode){
|
||||||
case 0:{
|
case 0:{
|
||||||
int offset = MeasureText(MIDI::Notes[(int)midi_note].c_str(), 12);
|
int offset = MeasureText(MIDI::Notes[(int)midiNote.note].c_str(), 12);
|
||||||
DrawText(MIDI::Notes[midi_note].c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
DrawText(MIDI::Notes[midiNote.note].c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||||
break;}
|
break;}
|
||||||
case 1:{
|
case 1:{
|
||||||
int offset = MeasureText(std::format("{}", midi_cc).c_str(), 12);
|
int offset = MeasureText(std::format("{}", midiCC.control).c_str(), 12);
|
||||||
DrawText(std::format("{}", midi_cc).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
DrawText(std::format("{}", midiCC.control).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||||
break;}
|
break;}
|
||||||
case 2:{
|
case 2:{
|
||||||
int offset = MeasureText(std::format("{}", midi_pitch_bend).c_str(), 12);
|
int offset = MeasureText(std::format("{}", midiPitchBend.value).c_str(), 12);
|
||||||
DrawText(std::format("{}", midi_pitch_bend).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
DrawText(std::format("{}", midiPitchBend.value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||||
break;}
|
break;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ namespace VISEQ::SIGNAL {
|
|||||||
auto midinode = std::dynamic_pointer_cast<MidiNode>(s->next.lock());
|
auto midinode = std::dynamic_pointer_cast<MidiNode>(s->next.lock());
|
||||||
for(auto &m : midinode->midi_outs){
|
for(auto &m : midinode->midi_outs){
|
||||||
if(m.second.enabled) {
|
if(m.second.enabled) {
|
||||||
if(midinode->send_note) midi.note(m.second.i, midinode->midi_note_channel, (int)Clamp(midinode->midi_note + s->midi_note_offset, 0, 127), midinode->midi_velocity, midinode->midi_gate);
|
if(midinode->send_note) midi.note(m.second.i, midinode->getNotes().channel, (int)Clamp(midinode->getNotes().note + s->midi_note_offset, 0, 127), midinode->getNotes().velocity, midinode->getNotes().gate);
|
||||||
if(midinode->send_cc) midi.cc(m.second.i, midinode->midi_cc_channel, midinode->midi_cc, (int)Clamp(midinode->midi_cc_value + s->midi_cc_offset, 0, 127));
|
if(midinode->send_cc) midi.cc(m.second.i, midinode->getCC().channel, midinode->getCC().control, (int)Clamp(midinode->getCC().value + s->midi_cc_offset, 0, 127));
|
||||||
if(midinode->send_pitch_bend) midi.pitch_bend(m.second.i, midinode->midi_pitch_bend_channel, midinode->midi_pitch_bend);
|
if(midinode->send_pitch_bend) midi.pitch_bend(m.second.i, midinode->getPitchBend().channel, midinode->getPitchBend().value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s->last = s->next;
|
s->last = s->next;
|
||||||
|
|||||||
+8
-8
@@ -77,8 +77,8 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
{"position", N.position},
|
{"position", N.position},
|
||||||
{"distributionMode", N.distributionMode},
|
{"distributionMode", N.distributionMode},
|
||||||
{"nodeType", N.nodeType},
|
{"nodeType", N.nodeType},
|
||||||
{"midi_note_channel",N.midi_note_channel},
|
{"midi_note_channel",N.getNotes().channel},
|
||||||
{"midi_note",N.midi_note},
|
{"midi_note",N.getNotes().note},
|
||||||
{"midi_velocity",N.midi_velocity},
|
{"midi_velocity",N.midi_velocity},
|
||||||
{"midi_gate",N.midi_gate},
|
{"midi_gate",N.midi_gate},
|
||||||
{"midi_cc_channel",N.midi_cc_channel},
|
{"midi_cc_channel",N.midi_cc_channel},
|
||||||
@@ -98,8 +98,8 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
j.at("position").get_to<Vec2Df>(N.position);
|
j.at("position").get_to<Vec2Df>(N.position);
|
||||||
j.at("distributionMode").get_to(N.distributionMode);
|
j.at("distributionMode").get_to(N.distributionMode);
|
||||||
j.at("nodeType").get_to(N.nodeType);
|
j.at("nodeType").get_to(N.nodeType);
|
||||||
j.at("midi_note_channel").get_to(N.midi_note_channel);
|
j.at("midi_note_channel").get_to(N.getNotes().channel);
|
||||||
j.at("midi_note").get_to(N.midi_note);
|
j.at("midi_note").get_to(N.getNotes().note);
|
||||||
j.at("midi_velocity").get_to(N.midi_velocity);
|
j.at("midi_velocity").get_to(N.midi_velocity);
|
||||||
j.at("midi_gate").get_to(N.midi_gate);
|
j.at("midi_gate").get_to(N.midi_gate);
|
||||||
j.at("midi_cc_channel").get_to(N.midi_cc_channel);
|
j.at("midi_cc_channel").get_to(N.midi_cc_channel);
|
||||||
@@ -136,8 +136,8 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
{"position", N.position},
|
{"position", N.position},
|
||||||
{"distributionMode", N.distributionMode},
|
{"distributionMode", N.distributionMode},
|
||||||
{"nodeType", N.nodeType},
|
{"nodeType", N.nodeType},
|
||||||
{"midi_note_channel",N.midiNote.channel},
|
{"midi_note_channel",N.getNotes().channel},
|
||||||
{"midi_note",N.midiNote.note},
|
{"midi_note",N.getNotes().note},
|
||||||
{"midi_cc_channel",N.midiCC.channel},
|
{"midi_cc_channel",N.midiCC.channel},
|
||||||
{"midi_cc",N.midiCC.value},
|
{"midi_cc",N.midiCC.value},
|
||||||
{"midi_pitch_bend_channel",N.midiPitchBend.channel},
|
{"midi_pitch_bend_channel",N.midiPitchBend.channel},
|
||||||
@@ -152,8 +152,8 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
j.at("position").get_to<Vec2Df>(N.position);
|
j.at("position").get_to<Vec2Df>(N.position);
|
||||||
j.at("distributionMode").get_to(N.distributionMode);
|
j.at("distributionMode").get_to(N.distributionMode);
|
||||||
j.at("nodeType").get_to(N.nodeType);
|
j.at("nodeType").get_to(N.nodeType);
|
||||||
j.at("midi_note_channel").get_to(N.midiNote.channel);
|
j.at("midi_note_channel").get_to(N.getNotes().channel);
|
||||||
j.at("midi_note").get_to(N.midiNote.note);
|
j.at("midi_note").get_to(N.getNotes().note);
|
||||||
j.at("midi_cc_channel").get_to(N.midiCC.channel);
|
j.at("midi_cc_channel").get_to(N.midiCC.channel);
|
||||||
j.at("midi_cc").get_to(N.midiCC.value);
|
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_channel").get_to(N.midiPitchBend.channel);
|
||||||
|
|||||||
Reference in New Issue
Block a user