@@ -37,7 +37,7 @@ EditorViewport::EditorViewport()
3737 somethingIsBeingDraggedOver(false ), shiftDown(false ), canEdit(true ),
3838 lastEditorClicked(0 ), selectionIndex(0 ), borderSize(6 ), tabSize(30 ),
3939 tabButtonSize(15 ), insertionPoint(0 ), componentWantsToMove(false ),
40- indexOfMovingComponent(-1 ), currentTab(-1 )
40+ indexOfMovingComponent(-1 ), currentTab(-1 ), loadingConfig( false )
4141{
4242
4343 addMouseListener (this , true );
@@ -1141,7 +1141,7 @@ void SignalChainTabButton::paintButton(Graphics& g, bool isMouseOver, bool isBut
11411141
11421142// how about some loading and saving?
11431143
1144- XmlElement* EditorViewport::createNodeXml (GenericProcessor* source)
1144+ XmlElement* EditorViewport::createNodeXml (GenericProcessor* source, bool isStartOfSignalChain )
11451145{
11461146
11471147 XmlElement* e = new XmlElement (" PROCESSOR" );
@@ -1159,10 +1159,13 @@ XmlElement* EditorViewport::createNodeXml(GenericProcessor* source)
11591159
11601160 name += source->getEditor ()->getName ();
11611161
1162- std::cout << name << std::endl;
1162+ // std::cout << name << std::endl;
11631163
11641164 e->setAttribute (" name" , name);
1165- e->setAttribute (" insertionPoint" , 1 );
1165+ if (isStartOfSignalChain)
1166+ e->setAttribute (" insertionPoint" , 0 );
1167+ else
1168+ e->setAttribute (" insertionPoint" , 1 );
11661169 e->setAttribute (" pluginName" , source->getPluginName ());
11671170 e->setAttribute (" pluginType" , (int )(source->getPluginType ()));
11681171 e->setAttribute (" pluginIndex" , source->getIndex ());
@@ -1172,7 +1175,7 @@ XmlElement* EditorViewport::createNodeXml(GenericProcessor* source)
11721175 e->setAttribute (" isSink" , source->isSink ());
11731176
11741177 /* *Saves individual processor parameters to XML */
1175- std::cout << " Create subnodes with parameters" << std::endl;
1178+ // std::cout << "Create subnodes with parameters" << std::endl;
11761179 source->saveToXml (e);
11771180
11781181 return e;
@@ -1221,6 +1224,8 @@ const String EditorViewport::saveState(File fileToUse, String* xmlText)
12211224 // }
12221225
12231226 Array<GenericProcessor*> splitPoints;
1227+ Array<GenericProcessor*> allSplitters;
1228+ Array<int > splitterStates;
12241229 /* * Used to reset saveOrder at end, to allow saving the same processor multiple times*/
12251230 Array<GenericProcessor*> allProcessors;
12261231
@@ -1246,11 +1251,13 @@ const String EditorViewport::saveState(File fileToUse, String* xmlText)
12461251
12471252 XmlElement* machineName = info->createNewChildElement (" MACHINE" );
12481253 machineName->addTextElement (SystemStats::getComputerName ());
1249-
1254+
12501255 for (int n = 0 ; n < signalChainArray.size (); n++)
12511256 {
12521257 XmlElement* signalChain = new XmlElement (" SIGNALCHAIN" );
1253-
1258+
1259+ bool isStartOfSignalChain = true ;
1260+
12541261 GenericProcessor* processor = signalChainArray[n]->getEditor ()->getProcessor ();
12551262
12561263 while (processor != nullptr )
@@ -1261,30 +1268,33 @@ const String EditorViewport::saveState(File fileToUse, String* xmlText)
12611268 {
12621269 // add to list of splitters to come back to
12631270 splitPoints.add (processor);
1271+
1272+ // keep track of all splitters and their inital states
1273+ allSplitters.add (processor);
1274+ Splitter* sp = (Splitter*)processor;
1275+ splitterStates.add (sp->getPath ());
1276+
12641277 processor->switchIO (0 );
12651278 }
12661279
12671280 // create a new XML element
1268- signalChain->addChildElement (createNodeXml (processor));
1281+ signalChain->addChildElement (createNodeXml (processor, isStartOfSignalChain ));
12691282 processor->saveOrder = saveOrder;
12701283 allProcessors.addIfNotAlreadyThere (processor);
12711284 saveOrder++;
12721285
12731286 }
1274- else
1275- {
1276- std::cout << " Processor already saved as number " << processor->saveOrder << std::endl;
1277- }
12781287
12791288 // continue until the end of the chain
1280- std::cout << " Moving forward along signal chain." << std::endl;
1289+ // std::cout << " Moving forward along signal chain." << std::endl;
12811290 processor = processor->getDestNode ();
1291+ isStartOfSignalChain = false ;
12821292
12831293 if (processor == nullptr )
12841294 {
12851295 if (splitPoints.size () > 0 )
12861296 {
1287- std::cout << " Going back to first unswitched splitter." << std::endl;
1297+ // std::cout << " Going back to first unswitched splitter." << std::endl;
12881298
12891299 processor = splitPoints.getFirst ();
12901300 splitPoints.remove (0 );
@@ -1294,14 +1304,20 @@ const String EditorViewport::saveState(File fileToUse, String* xmlText)
12941304 }
12951305 else
12961306 {
1297- std::cout << " End of chain." << std::endl;
1307+ // std::cout << " End of chain." << std::endl;
12981308 }
12991309 }
1310+
13001311 }
13011312
13021313 xml->addChildElement (signalChain);
13031314 }
13041315
1316+ // Loop through all splitters and reset their states to original values
1317+ for (int i = 0 ; i < allSplitters.size (); i++) {
1318+ allSplitters[i]->switchIO (splitterStates[i]);
1319+ }
1320+
13051321 XmlElement* audioSettings = new XmlElement (" AUDIO" );
13061322
13071323 AccessClass::getAudioComponent ()->saveStateToXml (audioSettings);
@@ -1452,7 +1468,8 @@ const String EditorViewport::loadState(File fileToLoad)
14521468 return " Failed To Open " + fileToLoad.getFileName ();
14531469 }
14541470 clearSignalChain ();
1455-
1471+
1472+ loadingConfig = true ; // Indicate config is being loaded into the GUI
14561473 String description;// = " ";
14571474 int loadOrder = 0 ;
14581475
@@ -1620,7 +1637,9 @@ const String EditorViewport::loadState(File fileToLoad)
16201637 delete xml;
16211638
16221639 currentId=maxID+1 ; // make sure future processors don't have overlapping id numbers
1623-
1640+
1641+ loadingConfig = false ;
1642+
16241643 return error;
16251644}
16261645/* Set parameters based on XML.*/
0 commit comments