/[svn]/qsampler/trunk/src/qsamplerMainForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3758 by capela, Fri Mar 27 17:57:40 2020 UTC revision 3759 by capela, Sat Mar 28 00:28:13 2020 UTC
# Line 70  const WindowFlags WindowCloseButtonHint Line 70  const WindowFlags WindowCloseButtonHint
70  }  }
71  #endif  #endif
72    
73    // Deprecated QTextStreamFunctions/Qt namespaces workaround.
74    #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
75    #define endl    Qt::endl
76    #endif
77    
78    
79  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
80  #include <gig.h>  #include <gig.h>
81  #endif  #endif
# Line 1091  bool MainForm::saveSessionFile ( const Q Line 1097  bool MainForm::saveSessionFile ( const Q
1097          // Write the file.          // Write the file.
1098          int iErrors = 0;          int iErrors = 0;
1099          QTextStream ts(&file);          QTextStream ts(&file);
1100          ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << Qt::endl;          ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;
1101          ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << Qt::endl;          ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << endl;
1102  //      ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << Qt::endl;  //      ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << endl;
1103          ts << "#"  << Qt::endl;          ts << "#"  << endl;
1104          ts << "# " << tr("File")          ts << "# " << tr("File")
1105          << ": " << QFileInfo(sFilename).fileName() << Qt::endl;          << ": " << QFileInfo(sFilename).fileName() << endl;
1106          ts << "# " << tr("Date")          ts << "# " << tr("Date")
1107          << ": " << QDate::currentDate().toString("MMM dd yyyy")          << ": " << QDate::currentDate().toString("MMM dd yyyy")
1108          << " "  << QTime::currentTime().toString("hh:mm:ss") << Qt::endl;          << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;
1109          ts << "#"  << Qt::endl;          ts << "#"  << endl;
1110          ts << Qt::endl;          ts << endl;
1111    
1112          // It is assumed that this new kind of device+session file          // It is assumed that this new kind of device+session file
1113          // will be loaded from a complete initialized server...          // will be loaded from a complete initialized server...
1114          int *piDeviceIDs;          int *piDeviceIDs;
1115          int  i, iDevice;          int  i, iDevice;
1116          ts << "RESET" << Qt::endl;          ts << "RESET" << endl;
1117    
1118          // Audio device mapping.          // Audio device mapping.
1119          QMap<int, int> audioDeviceMap; iDevice = 0;          QMap<int, int> audioDeviceMap; iDevice = 0;
# Line 1118  bool MainForm::saveSessionFile ( const Q Line 1124  bool MainForm::saveSessionFile ( const Q
1124                  if (device.driverName().toUpper() == "PLUGIN")                  if (device.driverName().toUpper() == "PLUGIN")
1125                          continue;                          continue;
1126                  // Audio device specification...                  // Audio device specification...
1127                  ts << Qt::endl;                  ts << endl;
1128                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
1129                          << " " << tr("Device") << " " << iDevice << Qt::endl;                          << " " << tr("Device") << " " << iDevice << endl;
1130                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();                  ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();
1131                  DeviceParamMap::ConstIterator deviceParam;                  DeviceParamMap::ConstIterator deviceParam;
1132                  for (deviceParam = device.params().begin();                  for (deviceParam = device.params().begin();
# Line 1130  bool MainForm::saveSessionFile ( const Q Line 1136  bool MainForm::saveSessionFile ( const Q
1136                          if (param.value.isEmpty()) ts << "# ";                          if (param.value.isEmpty()) ts << "# ";
1137                          ts << " " << deviceParam.key() << "='" << param.value << "'";                          ts << " " << deviceParam.key() << "='" << param.value << "'";
1138                  }                  }
1139                  ts << Qt::endl;                  ts << endl;
1140                  // Audio channel parameters...                  // Audio channel parameters...
1141                  int iPort = 0;                  int iPort = 0;
1142                  QListIterator<DevicePort *> iter(device.ports());                  QListIterator<DevicePort *> iter(device.ports());
# Line 1144  bool MainForm::saveSessionFile ( const Q Line 1150  bool MainForm::saveSessionFile ( const Q
1150                                  if (param.fix || param.value.isEmpty()) ts << "# ";                                  if (param.fix || param.value.isEmpty()) ts << "# ";
1151                                  ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice                                  ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice
1152                                          << " " << iPort << " " << portParam.key()                                          << " " << iPort << " " << portParam.key()
1153                                          << "='" << param.value << "'" << Qt::endl;                                          << "='" << param.value << "'" << endl;
1154                          }                          }
1155                          iPort++;                          iPort++;
1156                  }                  }
# Line 1163  bool MainForm::saveSessionFile ( const Q Line 1169  bool MainForm::saveSessionFile ( const Q
1169                  if (device.driverName().toUpper() == "PLUGIN")                  if (device.driverName().toUpper() == "PLUGIN")
1170                          continue;                          continue;
1171                  // MIDI device specification...                  // MIDI device specification...
1172                  ts << Qt::endl;                  ts << endl;
1173                  ts << "# " << device.deviceTypeName() << " " << device.driverName()                  ts << "# " << device.deviceTypeName() << " " << device.driverName()
1174                          << " " << tr("Device") << " " << iDevice << Qt::endl;                          << " " << tr("Device") << " " << iDevice << endl;
1175                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();                  ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();
1176                  DeviceParamMap::ConstIterator deviceParam;                  DeviceParamMap::ConstIterator deviceParam;
1177                  for (deviceParam = device.params().begin();                  for (deviceParam = device.params().begin();
# Line 1175  bool MainForm::saveSessionFile ( const Q Line 1181  bool MainForm::saveSessionFile ( const Q
1181                          if (param.value.isEmpty()) ts << "# ";                          if (param.value.isEmpty()) ts << "# ";
1182                          ts << " " << deviceParam.key() << "='" << param.value << "'";                          ts << " " << deviceParam.key() << "='" << param.value << "'";
1183                  }                  }
1184                  ts << Qt::endl;                  ts << endl;
1185                  // MIDI port parameters...                  // MIDI port parameters...
1186                  int iPort = 0;                  int iPort = 0;
1187                  QListIterator<DevicePort *> iter(device.ports());                  QListIterator<DevicePort *> iter(device.ports());
# Line 1189  bool MainForm::saveSessionFile ( const Q Line 1195  bool MainForm::saveSessionFile ( const Q
1195                                  if (param.fix || param.value.isEmpty()) ts << "# ";                                  if (param.fix || param.value.isEmpty()) ts << "# ";
1196                                  ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice                                  ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice
1197                                  << " " << iPort << " " << portParam.key()                                  << " " << iPort << " " << portParam.key()
1198                                  << "='" << param.value << "'" << Qt::endl;                                  << "='" << param.value << "'" << endl;
1199                          }                          }
1200                          iPort++;                          iPort++;
1201                  }                  }
# Line 1198  bool MainForm::saveSessionFile ( const Q Line 1204  bool MainForm::saveSessionFile ( const Q
1204                  // Try to keep it snappy :)                  // Try to keep it snappy :)
1205                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                  QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1206          }          }
1207          ts << Qt::endl;          ts << endl;
1208    
1209  #ifdef CONFIG_MIDI_INSTRUMENT  #ifdef CONFIG_MIDI_INSTRUMENT
1210          // MIDI instrument mapping...          // MIDI instrument mapping...
# Line 1211  bool MainForm::saveSessionFile ( const Q Line 1217  bool MainForm::saveSessionFile ( const Q
1217                  ts << "# " << tr("MIDI instrument map") << " " << iMap;                  ts << "# " << tr("MIDI instrument map") << " " << iMap;
1218                  if (pszMapName)                  if (pszMapName)
1219                          ts << " - " << pszMapName;                          ts << " - " << pszMapName;
1220                  ts << Qt::endl;                  ts << endl;
1221                  ts << "ADD MIDI_INSTRUMENT_MAP";                  ts << "ADD MIDI_INSTRUMENT_MAP";
1222                  if (pszMapName)                  if (pszMapName)
1223                          ts << " '" << pszMapName << "'";                          ts << " '" << pszMapName << "'";
1224                  ts << Qt::endl;                  ts << endl;
1225                  // MIDI instrument mapping...                  // MIDI instrument mapping...
1226                  lscp_midi_instrument_t *pInstrs                  lscp_midi_instrument_t *pInstrs
1227                          = ::lscp_list_midi_instruments(m_pClient, iMidiMap);                          = ::lscp_list_midi_instruments(m_pClient, iMidiMap);
# Line 1246  bool MainForm::saveSessionFile ( const Q Line 1252  bool MainForm::saveSessionFile ( const Q
1252                                  }                                  }
1253                                  if (pInstrInfo->name)                                  if (pInstrInfo->name)
1254                                          ts << " '" << pInstrInfo->name << "'";                                          ts << " '" << pInstrInfo->name << "'";
1255                                  ts << Qt::endl;                                  ts << endl;
1256                          }       // Check for errors...                          }       // Check for errors...
1257                          else if (::lscp_client_get_errno(m_pClient)) {                          else if (::lscp_client_get_errno(m_pClient)) {
1258                                  appendMessagesClient("lscp_get_midi_instrument_info");                                  appendMessagesClient("lscp_get_midi_instrument_info");
# Line 1255  bool MainForm::saveSessionFile ( const Q Line 1261  bool MainForm::saveSessionFile ( const Q
1261                          // Try to keep it snappy :)                          // Try to keep it snappy :)
1262                          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);                          QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1263                  }                  }
1264                  ts << Qt::endl;                  ts << endl;
1265                  // Check for errors...                  // Check for errors...
1266                  if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) {                  if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) {
1267                          appendMessagesClient("lscp_list_midi_instruments");                          appendMessagesClient("lscp_list_midi_instruments");
# Line 1289  bool MainForm::saveSessionFile ( const Q Line 1295  bool MainForm::saveSessionFile ( const Q
1295                                  if (!midiDeviceMap.contains(iMidiDevice))                                  if (!midiDeviceMap.contains(iMidiDevice))
1296                                          continue;                                          continue;
1297                                  // Go for regular, canonical devices...                                  // Go for regular, canonical devices...
1298                                  ts << "# " << tr("Channel") << " " << iChannelID << Qt::endl;                                  ts << "# " << tr("Channel") << " " << iChannelID << endl;
1299                                  ts << "ADD CHANNEL" << Qt::endl;                                  ts << "ADD CHANNEL" << endl;
1300                                  if (audioDeviceMap.isEmpty()) {                                  if (audioDeviceMap.isEmpty()) {
1301                                          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID                                          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID
1302                                                  << " " << pChannel->audioDriver() << Qt::endl;                                                  << " " << pChannel->audioDriver() << endl;
1303                                  } else {                                  } else {
1304                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID                                          ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID
1305                                                  << " " << audioDeviceMap.value(iAudioDevice) << Qt::endl;                                                  << " " << audioDeviceMap.value(iAudioDevice) << endl;
1306                                  }                                  }
1307                                  if (midiDeviceMap.isEmpty()) {                                  if (midiDeviceMap.isEmpty()) {
1308                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID                                          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID
1309                                                  << " " << pChannel->midiDriver() << Qt::endl;                                                  << " " << pChannel->midiDriver() << endl;
1310                                  } else {                                  } else {
1311                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID                                          ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID
1312                                                  << " " << midiDeviceMap.value(iMidiDevice) << Qt::endl;                                                  << " " << midiDeviceMap.value(iMidiDevice) << endl;
1313                                  }                                  }
1314                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID                                  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID
1315                                          << " " << pChannel->midiPort() << Qt::endl;                                          << " " << pChannel->midiPort() << endl;
1316                                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";                                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
1317                                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)                                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
1318                                          ts << "ALL";                                          ts << "ALL";
1319                                  else                                  else
1320                                          ts << pChannel->midiChannel();                                          ts << pChannel->midiChannel();
1321                                  ts << Qt::endl;                                  ts << endl;
1322                                  ts << "LOAD ENGINE " << pChannel->engineName()                                  ts << "LOAD ENGINE " << pChannel->engineName()
1323                                          << " " << iChannelID << Qt::endl;                                          << " " << iChannelID << endl;
1324                                  if (pChannel->instrumentStatus() < 100) ts << "# ";                                  if (pChannel->instrumentStatus() < 100) ts << "# ";
1325                                  ts << "LOAD INSTRUMENT NON_MODAL '"                                  ts << "LOAD INSTRUMENT NON_MODAL '"
1326                                          << pChannel->instrumentFile() << "' "                                          << pChannel->instrumentFile() << "' "
1327                                          << pChannel->instrumentNr() << " " << iChannelID << Qt::endl;                                          << pChannel->instrumentNr() << " " << iChannelID << endl;
1328                                  ChannelRoutingMap::ConstIterator audioRoute;                                  ChannelRoutingMap::ConstIterator audioRoute;
1329                                  for (audioRoute = pChannel->audioRouting().begin();                                  for (audioRoute = pChannel->audioRouting().begin();
1330                                                  audioRoute != pChannel->audioRouting().end();                                                  audioRoute != pChannel->audioRouting().end();
1331                                                          ++audioRoute) {                                                          ++audioRoute) {
1332                                          ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannelID                                          ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannelID
1333                                                  << " " << audioRoute.key()                                                  << " " << audioRoute.key()
1334                                                  << " " << audioRoute.value() << Qt::endl;                                                  << " " << audioRoute.value() << endl;
1335                                  }                                  }
1336                                  ts << "SET CHANNEL VOLUME " << iChannelID                                  ts << "SET CHANNEL VOLUME " << iChannelID
1337                                          << " " << pChannel->volume() << Qt::endl;                                          << " " << pChannel->volume() << endl;
1338                                  if (pChannel->channelMute())                                  if (pChannel->channelMute())
1339                                          ts << "SET CHANNEL MUTE " << iChannelID << " 1" << Qt::endl;                                          ts << "SET CHANNEL MUTE " << iChannelID << " 1" << endl;
1340                                  if (pChannel->channelSolo())                                  if (pChannel->channelSolo())
1341                                          ts << "SET CHANNEL SOLO " << iChannelID << " 1" << Qt::endl;                                          ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl;
1342                          #ifdef CONFIG_MIDI_INSTRUMENT                          #ifdef CONFIG_MIDI_INSTRUMENT
1343                                  const int iMidiMap = pChannel->midiMap();                                  const int iMidiMap = pChannel->midiMap();
1344                                  if (midiInstrumentMap.contains(iMidiMap)) {                                  if (midiInstrumentMap.contains(iMidiMap)) {
1345                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID                                          ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID
1346                                                  << " " << midiInstrumentMap.value(iMidiMap) << Qt::endl;                                                  << " " << midiInstrumentMap.value(iMidiMap) << endl;
1347                                  }                                  }
1348                          #endif                          #endif
1349                          #ifdef CONFIG_FXSEND                          #ifdef CONFIG_FXSEND
# Line 1352  bool MainForm::saveSessionFile ( const Q Line 1358  bool MainForm::saveSessionFile ( const Q
1358                                                          << " " << pFxSendInfo->midi_controller;                                                          << " " << pFxSendInfo->midi_controller;
1359                                                  if (pFxSendInfo->name)                                                  if (pFxSendInfo->name)
1360                                                          ts << " '" << pFxSendInfo->name << "'";                                                          ts << " '" << pFxSendInfo->name << "'";
1361                                                  ts << Qt::endl;                                                  ts << endl;
1362                                                  int *piRouting = pFxSendInfo->audio_routing;                                                  int *piRouting = pFxSendInfo->audio_routing;
1363                                                  for (int iAudioSrc = 0;                                                  for (int iAudioSrc = 0;
1364                                                                  piRouting && piRouting[iAudioSrc] >= 0;                                                                  piRouting && piRouting[iAudioSrc] >= 0;
# Line 1361  bool MainForm::saveSessionFile ( const Q Line 1367  bool MainForm::saveSessionFile ( const Q
1367                                                                  << iChannelID                                                                  << iChannelID
1368                                                                  << " " << iFxSend                                                                  << " " << iFxSend
1369                                                                  << " " << iAudioSrc                                                                  << " " << iAudioSrc
1370                                                                  << " " << piRouting[iAudioSrc] << Qt::endl;                                                                  << " " << piRouting[iAudioSrc] << endl;
1371                                                  }                                                  }
1372                                          #ifdef CONFIG_FXSEND_LEVEL                                          #ifdef CONFIG_FXSEND_LEVEL
1373                                                  ts << "SET FX_SEND LEVEL " << iChannelID                                                  ts << "SET FX_SEND LEVEL " << iChannelID
1374                                                          << " " << iFxSend                                                          << " " << iFxSend
1375                                                          << " " << pFxSendInfo->level << Qt::endl;                                                          << " " << pFxSendInfo->level << endl;
1376                                          #endif                                          #endif
1377                                          }       // Check for errors...                                          }       // Check for errors...
1378                                          else if (::lscp_client_get_errno(m_pClient)) {                                          else if (::lscp_client_get_errno(m_pClient)) {
# Line 1375  bool MainForm::saveSessionFile ( const Q Line 1381  bool MainForm::saveSessionFile ( const Q
1381                                          }                                          }
1382                                  }                                  }
1383                          #endif                          #endif
1384                                  ts << Qt::endl;                                  ts << endl;
1385                                  // Go for next channel...                                  // Go for next channel...
1386                                  ++iChannelID;                                  ++iChannelID;
1387                          }                          }
# Line 1385  bool MainForm::saveSessionFile ( const Q Line 1391  bool MainForm::saveSessionFile ( const Q
1391          }          }
1392    
1393  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
1394          ts << "# " << tr("Global volume level") << Qt::endl;          ts << "# " << tr("Global volume level") << endl;
1395          ts << "SET VOLUME " << ::lscp_get_volume(m_pClient) << Qt::endl;          ts << "SET VOLUME " << ::lscp_get_volume(m_pClient) << endl;
1396          ts << Qt::endl;          ts << endl;
1397  #endif  #endif
1398    
1399          // Ok. we've wrote it.          // Ok. we've wrote it.

Legend:
Removed from v.3758  
changed lines
  Added in v.3759

  ViewVC Help
Powered by ViewVC