Skip to content

Commit 15df2f9

Browse files
committed
some cleanup and fixed auto reconnect audio output on load new patch or change audio settings
1 parent 453dd5a commit 15df2f9

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

src/objects/scripting/ShaderObject.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ void ShaderObject::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchOb
244244

245245
//--------------------------------------------------------------
246246
void ShaderObject::drawObjectContent(ofTrueTypeFont *font, shared_ptr<ofBaseGLRenderer>& glRenderer){
247+
unusedArgs(font,glRenderer);
247248

248249
///////////////////////////////////////////
249250
// SHADER UPDATE
@@ -516,7 +517,7 @@ void ShaderObject::drawObjectNodeConfig(){
516517

517518
//--------------------------------------------------------------
518519
void ShaderObject::removeObjectContent(bool removeFileFromData){
519-
520+
unusedArgs(removeFileFromData);
520521
}
521522

522523
//--------------------------------------------------------------

src/objects/sound/AudioDevice.cpp

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ void AudioDevice::audioOutObject(ofSoundBuffer &outputBuffer){
199199

200200
//--------------------------------------------------------------
201201
void AudioDevice::resetSystemObject(){
202+
203+
vector<bool> tempInletsConn;
204+
for(int i=0;i<this->numInlets;i++){
205+
if(this->inletsConnected[i]){
206+
tempInletsConn.push_back(true);
207+
}else{
208+
tempInletsConn.push_back(false);
209+
}
210+
}
211+
202212
ofxXmlSettings XML;
203213

204214
deviceLoaded = false;
@@ -263,6 +273,18 @@ void AudioDevice::resetSystemObject(){
263273
this->inletsConnected.clear();
264274
this->initInletsState();
265275

276+
for(int i=0;i<this->numInlets;i++){
277+
if(i<static_cast<int>(tempInletsConn.size())){
278+
if(tempInletsConn.at(i)){
279+
this->inletsConnected.push_back(true);
280+
}else{
281+
this->inletsConnected.push_back(false);
282+
}
283+
}else{
284+
this->inletsConnected.push_back(false);
285+
}
286+
}
287+
266288
this->height = OBJECT_HEIGHT;
267289

268290
if(this->numInlets > 6 || this->numOutlets > 6){
@@ -291,7 +313,7 @@ void AudioDevice::resetSystemObject(){
291313
XML.popTag();
292314
}
293315
}else{
294-
// remove links to the this object
316+
// remove links to this object if exceed new inlets number
295317
if(XML.pushTag("outlets")){
296318
int totalLinks = XML.getNumTags("link");
297319
for(int l=0;l<totalLinks;l++){
@@ -300,7 +322,7 @@ void AudioDevice::resetSystemObject(){
300322
vector<bool> delLinks;
301323
for(int t=0;t<totalTo;t++){
302324
if(XML.pushTag("to",t)){
303-
if(XML.getValue("id", -1) == this->nId){
325+
if(XML.getValue("id", -1) == this->nId && XML.getValue("inlet", -1) > this->getNumInlets()-1){
304326
delLinks.push_back(true);
305327
}else{
306328
delLinks.push_back(false);
@@ -333,6 +355,16 @@ void AudioDevice::resetSystemObject(){
333355

334356
//--------------------------------------------------------------
335357
void AudioDevice::loadDeviceInfo(){
358+
359+
vector<bool> tempInletsConn;
360+
for(int i=0;i<this->numInlets;i++){
361+
if(this->inletsConnected[i]){
362+
tempInletsConn.push_back(true);
363+
}else{
364+
tempInletsConn.push_back(false);
365+
}
366+
}
367+
336368
ofxXmlSettings XML;
337369

338370
if (XML.loadFile(patchFile)){
@@ -407,6 +439,18 @@ void AudioDevice::loadDeviceInfo(){
407439
this->inletsConnected.clear();
408440
this->initInletsState();
409441

442+
for(int i=0;i<this->numInlets;i++){
443+
if(i<static_cast<int>(tempInletsConn.size())){
444+
if(tempInletsConn.at(i)){
445+
this->inletsConnected.push_back(true);
446+
}else{
447+
this->inletsConnected.push_back(false);
448+
}
449+
}else{
450+
this->inletsConnected.push_back(false);
451+
}
452+
}
453+
410454
this->height = OBJECT_HEIGHT;
411455

412456
if(this->numInlets > 6 || this->numOutlets > 6){

src/ofxVisualProgramming.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,6 @@ void ofxVisualProgramming::removeObject(int &id){
10801080
void ofxVisualProgramming::duplicateObject(int &id){
10811081
// disable duplicate for hardware&system related objects
10821082
if(!patchObjects[id]->getIsHardwareObject()){
1083-
//if(patchObjects[id]->getName() != "audio device" && patchObjects[id]->getName() != "kinect grabber" && patchObjects[id]->getName() != "live patching"){
1084-
//ofVec2f newPos = ofVec2f(patchObjects[id]->getPos().x + patchObjects[id]->getObjectWidth(),patchObjects[id]->getPos().y);
10851083
addObject(patchObjects[id]->getName(),patchObjects[id]->getPos());
10861084
}else{
10871085
ofLog(OF_LOG_NOTICE,"'%s' is one of the Mosaic objects that can't (for now) be duplicated due to hardware/system related issues.",patchObjects[id]->getName().c_str());
@@ -1094,7 +1092,7 @@ bool ofxVisualProgramming::connect(int fromID, int fromOutlet, int toID,int toIn
10941092

10951093
if((fromID != -1) && (patchObjects[fromID] != nullptr) && (toID != -1) && (patchObjects[toID] != nullptr) && (patchObjects[fromID]->getOutletType(fromOutlet) == patchObjects[toID]->getInletType(toInlet)) && !patchObjects[toID]->inletsConnected[toInlet]){
10961094

1097-
//cout << "Mosaic :: "<< "Connect object " << patchObjects[fromID]->getName().c_str() << ":" << ofToString(fromID) << " to object " << patchObjects[toID]->getName().c_str() << ":" << ofToString(toID) << endl;
1095+
//std::cout << "Mosaic :: "<< "Connect object " << patchObjects[fromID]->getName().c_str() << ":" << ofToString(fromID) << " to object " << patchObjects[toID]->getName().c_str() << ":" << ofToString(toID) << std::endl;
10981096

10991097
shared_ptr<PatchLink> tempLink = shared_ptr<PatchLink>(new PatchLink());
11001098

@@ -1108,6 +1106,7 @@ bool ofxVisualProgramming::connect(int fromID, int fromOutlet, int toID,int toIn
11081106
tempLink->toObjectID = toID;
11091107
tempLink->toInletID = toInlet;
11101108
tempLink->isDisabled = false;
1109+
tempLink->isDeactivated = false;
11111110

11121111
patchObjects[fromID]->outPut.push_back(tempLink);
11131112

@@ -1165,7 +1164,9 @@ void ofxVisualProgramming::resetSystemObjects(){
11651164
for(map<int,shared_ptr<PatchObject>>::iterator it = patchObjects.begin(); it != patchObjects.end(); it++ ){
11661165
if(it->second->getIsSystemObject()){
11671166
it->second->resetSystemObject();
1168-
resetObject(it->second->getId());
1167+
if(it->second->getName() != "audio device"){
1168+
resetObject(it->second->getId());
1169+
}
11691170
if(it->second->getIsAudioOUTObject()){
11701171
it->second->setupAudioOutObjectContent(*engine);
11711172
}

0 commit comments

Comments
 (0)