@@ -40,6 +40,7 @@ class NeuralRack : public TextEntry
4040
4141 NeuralRack () : engine() {
4242 workToDo.store (false , std::memory_order_release);
43+ presetToLoad.store (false , std::memory_order_release);
4344 processCounter = 0 ;
4445 settingsHaveChanged = false ;
4546 disableAutoConnect = false ;
@@ -54,6 +55,7 @@ class NeuralRack : public TextEntry
5455 ui->f_index = 0 ;
5556 title = " NeuralRack" ;
5657 currentPreset = " Default" ;
58+ lPreset = " Default" ;
5759 #if defined(HAVE_PA)
5860 xpa = nullptr ;
5961 #endif
@@ -358,8 +360,10 @@ class NeuralRack : public TextEntry
358360
359361 // load a saved preset
360362 void loadPreset (int v) {
361- if ( v < PresetListNames.size ())
362- readPreset (PresetListNames[v]);
363+ if (v < PresetListNames.size () && v > -1 ) {
364+ lPreset = PresetListNames[v];
365+ presetToLoad.store (true , std::memory_order_release);
366+ }
363367 }
364368
365369 void readConfig (std::string name = " Default" ) {
@@ -467,12 +471,14 @@ class NeuralRack : public TextEntry
467471 bool settingsHaveChanged;
468472 bool disableAutoConnect;
469473 std::atomic<bool > workToDo;
474+ std::atomic<bool > presetToLoad;
470475 std::string configFile;
471476 std::string presetFile;
472477 double s_time;
473478 std::vector<std::string> PresetListNames;
474479 std::string title;
475480 std::string currentPreset;
481+ std::string lPreset;
476482 std::vector<std::tuple< std::string, std::string> > connections;
477483
478484 void createPresetMenu () {
@@ -902,6 +908,21 @@ class NeuralRack : public TextEntry
902908 XUnlockDisplay (ui->main .dpy );
903909 #endif
904910 }
911+ if (presetToLoad.load (std::memory_order_acquire)) {
912+ presetToLoad.store (false , std::memory_order_release);
913+ if (lPreset.compare (currentPreset) != 0 ) {
914+ #if defined(__linux__) || defined(__FreeBSD__) || \
915+ defined (__NetBSD__) || defined (__OpenBSD__)
916+ XLockDisplay (ui->main .dpy );
917+ #endif
918+ readPreset (lPreset);
919+ #if defined(__linux__) || defined(__FreeBSD__) || \
920+ defined (__NetBSD__) || defined (__OpenBSD__)
921+ XFlush (ui->main .dpy );
922+ XUnlockDisplay (ui->main .dpy );
923+ }
924+ #endif
925+ }
905926 }
906927
907928};
0 commit comments