From 2dd0d37b7d0ff8a4cccd5fb0cfd6b79306b69d4f Mon Sep 17 00:00:00 2001 From: bbond007 Date: Wed, 12 Dec 2018 22:15:27 -0500 Subject: [PATCH] System Menu SoftSynth fix --- menu.cpp | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/menu.cpp b/menu.cpp index 64e974e..2377cc0 100644 --- a/menu.cpp +++ b/menu.cpp @@ -166,7 +166,8 @@ const char *joy_button_map[] = { "RIGHT", "LEFT", "DOWN", "UP", "BUTTON 1", "BUT const char *config_stereo_msg[] = { "0%", "25%", "50%", "100%" }; const char *config_uart_msg[] = { " None", " PPP", " Console", " MIDI", "MIDI-38K" }; const char *config_scaler_msg[] = { "Internal","Custom" }; -const char *config_softsynth_msg[] = {" MUNT", "FluidSynth", " UDP"}; +const char *config_softsynth_msg[] = {" UDP", " MUNT", "FluidSynth"}; + char joy_bnames[12][32]; int joy_bcount = 0; @@ -215,9 +216,9 @@ int GetUARTMode() int GetSoftSynthMode() { struct stat filestat; - if (!stat("/tmp/ML_MUNT", &filestat)) return 0; - if (!stat("/tmp/ML_FSYNTH", &filestat)) return 1; - if (!stat("/tmp/ML_UDP", &filestat)) return 2; + if (!stat("/tmp/ML_UDP", &filestat)) return 0; + if (!stat("/tmp/ML_MUNT", &filestat)) return 1; + if (!stat("/tmp/ML_FSYNTH", &filestat)) return 2; return 0; } @@ -225,18 +226,18 @@ void SetSoftSynthMode(int mode) { switch (mode) { - case 0: system("echo 1 > /tmp/ML_MUNT"); + case 0: system("echo 1 > /tmp/ML_UDP"); + remove("/tmp/ML_MUNT"); + remove("/tmp/ML_FSYNTH"); + break; + case 1: system("echo 1 > /tmp/ML_MUNT"); remove("/tmp/ML_FSYNTH"); remove("/tmp/ML_UDP"); break; - case 1: system("echo 1 > /tmp/ML_FSYNTH"); + case 2: system("echo 1 > /tmp/ML_FSYNTH"); remove("/tmp/ML_MUNT"); remove("/tmp/ML_UDP"); break; - case 2: system("echo 1 > /tmp/ML_UDP"); - remove("/tmp/ML_MUNT"); - remove("/tmp/ML_FSYNTH"); - break; } } @@ -1335,15 +1336,9 @@ void HandleUI(void) menumask |= 0x18; sprintf(s, " UART connection %s", config_uart_msg[mode]); OsdWrite(3, s, menusub == 3, 0); - - if((mode == 3 || mode == 4) && stat("/dev/midi", &filestat) != 0) - { - sprintf(s, " Softsynth %s", config_softsynth_msg[GetSoftSynthMode()]); - OsdWrite(4, s, menusub == 4 , 0); - } - else - OsdWrite(4," Softsynth N/A", menusub == 4 , 1); - } + sprintf(s, " Softsynth %s", config_softsynth_msg[GetSoftSynthMode()]); + OsdWrite(4, s, menusub == 4 , (mode == 3 || mode == 4) && stat("/dev/midi", &filestat)?0:1); + } else { OsdWrite(m++, "", 0, 0); @@ -1458,14 +1453,12 @@ void HandleUI(void) { struct stat filestat; int softsynth = GetSoftSynthMode(); - softsynth++; - //if(softsynth == 0 || softsynth == 1) - // if (stat("/dev/pcmC0D0p", &filestat) != 0) - // softsynth = 2; + if ((stat("/dev/snd/pcmC0D0p", &filestat) == 0)) + softsynth++; + else + softsynth = 0; if (softsynth > 2) softsynth = 0; - SetSoftSynthMode(softsynth); - sprintf(s, "uartmode %d", 0); system(s); sprintf(s, "uartmode %d", mode);