Fun with config nodes that modifiy other config nodes. Circular connections lead to a crash.
This commit is contained in:
+92
-30
@@ -15,7 +15,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
ConfigNode() {std::cout << "ConfigNode Constructor std" << std::endl;}
|
||||
ConfigNode(Vec2Df position) : Node(position) {}
|
||||
|
||||
std::shared_ptr<ConfigNode> getPtr(){
|
||||
std::shared_ptr<ConfigNode> getPtr() {
|
||||
return std::static_pointer_cast<ConfigNode>(shared_from_this());
|
||||
}
|
||||
|
||||
@@ -39,28 +39,63 @@ namespace VISEQ::GRAPH::NODES {
|
||||
mode = _mode;
|
||||
}
|
||||
|
||||
MIDI::MidiNote getNotes(){
|
||||
return midiNote;
|
||||
MIDI::MidiNote getNotes() const {
|
||||
MIDI::MidiNote cNote;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cNote += cn.lock()->getNotes();
|
||||
}
|
||||
return midiNote + cNote;
|
||||
}
|
||||
|
||||
MIDI::MidiCC getCC(){
|
||||
return midiCC;
|
||||
|
||||
MIDI::MidiCC getCC() const {
|
||||
MIDI::MidiCC cCC;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cCC += cn.lock()->getCC();
|
||||
}
|
||||
return midiCC + cCC;
|
||||
}
|
||||
|
||||
MIDI::MidiPC getPC(){
|
||||
return midiPC;
|
||||
|
||||
MIDI::MidiPC getPC() const {
|
||||
MIDI::MidiPC cPC;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cPC += cn.lock()->getPC();
|
||||
}
|
||||
return midiPC + cPC;
|
||||
}
|
||||
|
||||
MIDI::MidiPitchBend getPitchBend(){
|
||||
return midiPitchBend;
|
||||
|
||||
MIDI::MidiPitchBend getPitchBend() const {
|
||||
MIDI::MidiPitchBend cPitchBend;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cPitchBend += cn.lock()->getPitchBend();
|
||||
}
|
||||
return midiPitchBend + cPitchBend;
|
||||
}
|
||||
|
||||
MIDI::MidiPolyPressure getPolyPressure(){
|
||||
return midiPolyPressure;
|
||||
|
||||
MIDI::MidiAftertouch getAftertouch() const {
|
||||
MIDI::MidiAftertouch cAftertouch;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cAftertouch += cn.lock()->getAftertouch();
|
||||
}
|
||||
return midiAftertouch + cAftertouch;
|
||||
}
|
||||
|
||||
MIDI::MidiAftertouch getAftertouch(){
|
||||
return midiAftertouch;
|
||||
|
||||
MIDI::MidiPolyPressure getPolyPressure() const {
|
||||
MIDI::MidiPolyPressure cPolyPressure;
|
||||
for(auto cn : getConnectedConfigNodes()){
|
||||
cPolyPressure += cn.lock()->getPolyPressure();
|
||||
}
|
||||
return midiPolyPressure + cPolyPressure;
|
||||
}
|
||||
|
||||
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>>>();
|
||||
std::vector<std::weak_ptr<ConfigNode>> config_nodes;
|
||||
for(auto e : config_conns){
|
||||
if(e->start.lock().get() != this && e->start.lock()->getNodeType() == NodeType::CONFIGNODE) config_nodes.push_back(std::dynamic_pointer_cast<ConfigNode>(e->start.lock()));
|
||||
//if(e->end.lock().get() != this && e->end.lock()->getNodeType() == NodeType::CONFIGNODE) config_nodes.push_back(std::dynamic_pointer_cast<ConfigNode>(e->end.lock()));
|
||||
}
|
||||
/*std::cout << "id: " << id << " n cn: " << config_nodes.size() << std::endl;*/
|
||||
return config_nodes;
|
||||
}
|
||||
|
||||
void update() override {
|
||||
@@ -148,34 +183,61 @@ namespace VISEQ::GRAPH::NODES {
|
||||
int offset_gate = 0;
|
||||
switch(mode){
|
||||
case 0:
|
||||
value = (float)midiNote.channel;
|
||||
value = (float)getNotes().channel;
|
||||
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, VS_COLOR_BLACK );
|
||||
break;
|
||||
case 1:
|
||||
value = (float)midiCC.channel;
|
||||
value = (float)getCC().channel;
|
||||
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, VS_COLOR_BLACK );
|
||||
break;
|
||||
case 2:
|
||||
value = (float)midiPitchBend.channel;
|
||||
value = (float)getPC().channel;
|
||||
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, VS_COLOR_BLACK );
|
||||
break;
|
||||
case 3:
|
||||
value = (float)getPitchBend().channel;
|
||||
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, VS_COLOR_BLACK );
|
||||
break;
|
||||
case 4:
|
||||
value = (float)getAftertouch().channel;
|
||||
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, VS_COLOR_BLACK );
|
||||
break;
|
||||
case 5:
|
||||
value = (float)getPolyPressure().channel;
|
||||
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, VS_COLOR_BLACK );
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch(mode){
|
||||
case 0:{
|
||||
int offset = MeasureText(std::format("{:+}", midiNote.note).c_str(), 12);
|
||||
DrawText(std::format("{:+}", midiNote.note).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
int offset = MeasureText(std::format("{:+}", getNotes().note).c_str(), 12);
|
||||
DrawText(std::format("{:+}", getNotes().note).c_str(), position.x-offset/2.0f, position.y-5, 12, VS_COLOR_BLACK );
|
||||
break;}
|
||||
case 1:{
|
||||
int offset = MeasureText(std::format("{:+}", midiCC.value).c_str(), 12);
|
||||
DrawText(std::format("{:+}", midiCC.value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
int offset = MeasureText(std::format("{:+}", getCC().value).c_str(), 12);
|
||||
DrawText(std::format("{:+}", getCC().value).c_str(), position.x-offset/2.0f, position.y-5, 12, VS_COLOR_BLACK );
|
||||
break;}
|
||||
case 2:{
|
||||
int offset = MeasureText(std::format("{:+}", midiPitchBend.value).c_str(), 12);
|
||||
DrawText(std::format("{:+}", midiPitchBend.value).c_str(), position.x-offset/2.0f, position.y-5, 12, WHITE );
|
||||
int offset = MeasureText(std::format("{:+}", getPC().value).c_str(), 12);
|
||||
DrawText(std::format("{:+}", getPC().value).c_str(), position.x-offset/2.0f, position.y-5, 12, VS_COLOR_BLACK );
|
||||
break;}
|
||||
case 3:{
|
||||
int offset = MeasureText(std::format("{:+}", getPitchBend().value).c_str(), 12);
|
||||
DrawText(std::format("{:+}", getPitchBend().value).c_str(), position.x-offset/2.0f, position.y-5, 12, VS_COLOR_BLACK );
|
||||
break;}
|
||||
case 4:{
|
||||
int offset = MeasureText(std::format("{:+}", getAftertouch().value).c_str(), 12);
|
||||
DrawText(std::format("{:+}", getAftertouch().value).c_str(), position.x-offset/2.0f, position.y-5, 12, VS_COLOR_BLACK );
|
||||
break;}
|
||||
case 5:{
|
||||
int offset = MeasureText(std::format("{:+}", getPolyPressure().value).c_str(), 12);
|
||||
DrawText(std::format("{:+}", getPolyPressure().value).c_str(), position.x-offset/2.0f, position.y-5, 12, VS_COLOR_BLACK );
|
||||
break;}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user