1091 |
// Write the file. |
// Write the file. |
1092 |
int iErrors = 0; |
int iErrors = 0; |
1093 |
QTextStream ts(&file); |
QTextStream ts(&file); |
1094 |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl; |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << Qt::endl; |
1095 |
ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << endl; |
ts << "# " << tr("Version") << ": " CONFIG_BUILD_VERSION << Qt::endl; |
1096 |
// ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << endl; |
// ts << "# " << tr("Build") << ": " CONFIG_BUILD_DATE << Qt::endl; |
1097 |
ts << "#" << endl; |
ts << "#" << Qt::endl; |
1098 |
ts << "# " << tr("File") |
ts << "# " << tr("File") |
1099 |
<< ": " << QFileInfo(sFilename).fileName() << endl; |
<< ": " << QFileInfo(sFilename).fileName() << Qt::endl; |
1100 |
ts << "# " << tr("Date") |
ts << "# " << tr("Date") |
1101 |
<< ": " << QDate::currentDate().toString("MMM dd yyyy") |
<< ": " << QDate::currentDate().toString("MMM dd yyyy") |
1102 |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
<< " " << QTime::currentTime().toString("hh:mm:ss") << Qt::endl; |
1103 |
ts << "#" << endl; |
ts << "#" << Qt::endl; |
1104 |
ts << endl; |
ts << Qt::endl; |
1105 |
|
|
1106 |
// It is assumed that this new kind of device+session file |
// It is assumed that this new kind of device+session file |
1107 |
// will be loaded from a complete initialized server... |
// will be loaded from a complete initialized server... |
1108 |
int *piDeviceIDs; |
int *piDeviceIDs; |
1109 |
int i, iDevice; |
int i, iDevice; |
1110 |
ts << "RESET" << endl; |
ts << "RESET" << Qt::endl; |
1111 |
|
|
1112 |
// Audio device mapping. |
// Audio device mapping. |
1113 |
QMap<int, int> audioDeviceMap; iDevice = 0; |
QMap<int, int> audioDeviceMap; iDevice = 0; |
1118 |
if (device.driverName().toUpper() == "PLUGIN") |
if (device.driverName().toUpper() == "PLUGIN") |
1119 |
continue; |
continue; |
1120 |
// Audio device specification... |
// Audio device specification... |
1121 |
ts << endl; |
ts << Qt::endl; |
1122 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
1123 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << Qt::endl; |
1124 |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
1125 |
DeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
1126 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
1130 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
1131 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
1132 |
} |
} |
1133 |
ts << endl; |
ts << Qt::endl; |
1134 |
// Audio channel parameters... |
// Audio channel parameters... |
1135 |
int iPort = 0; |
int iPort = 0; |
1136 |
QListIterator<DevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
1144 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
1145 |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
1146 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
1147 |
<< "='" << param.value << "'" << endl; |
<< "='" << param.value << "'" << Qt::endl; |
1148 |
} |
} |
1149 |
iPort++; |
iPort++; |
1150 |
} |
} |
1163 |
if (device.driverName().toUpper() == "PLUGIN") |
if (device.driverName().toUpper() == "PLUGIN") |
1164 |
continue; |
continue; |
1165 |
// MIDI device specification... |
// MIDI device specification... |
1166 |
ts << endl; |
ts << Qt::endl; |
1167 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
1168 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << Qt::endl; |
1169 |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
1170 |
DeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
1171 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
1175 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
1176 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
1177 |
} |
} |
1178 |
ts << endl; |
ts << Qt::endl; |
1179 |
// MIDI port parameters... |
// MIDI port parameters... |
1180 |
int iPort = 0; |
int iPort = 0; |
1181 |
QListIterator<DevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
1189 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
1190 |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
1191 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
1192 |
<< "='" << param.value << "'" << endl; |
<< "='" << param.value << "'" << Qt::endl; |
1193 |
} |
} |
1194 |
iPort++; |
iPort++; |
1195 |
} |
} |
1198 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
1199 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
1200 |
} |
} |
1201 |
ts << endl; |
ts << Qt::endl; |
1202 |
|
|
1203 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1204 |
// MIDI instrument mapping... |
// MIDI instrument mapping... |
1211 |
ts << "# " << tr("MIDI instrument map") << " " << iMap; |
ts << "# " << tr("MIDI instrument map") << " " << iMap; |
1212 |
if (pszMapName) |
if (pszMapName) |
1213 |
ts << " - " << pszMapName; |
ts << " - " << pszMapName; |
1214 |
ts << endl; |
ts << Qt::endl; |
1215 |
ts << "ADD MIDI_INSTRUMENT_MAP"; |
ts << "ADD MIDI_INSTRUMENT_MAP"; |
1216 |
if (pszMapName) |
if (pszMapName) |
1217 |
ts << " '" << pszMapName << "'"; |
ts << " '" << pszMapName << "'"; |
1218 |
ts << endl; |
ts << Qt::endl; |
1219 |
// MIDI instrument mapping... |
// MIDI instrument mapping... |
1220 |
lscp_midi_instrument_t *pInstrs |
lscp_midi_instrument_t *pInstrs |
1221 |
= ::lscp_list_midi_instruments(m_pClient, iMidiMap); |
= ::lscp_list_midi_instruments(m_pClient, iMidiMap); |
1246 |
} |
} |
1247 |
if (pInstrInfo->name) |
if (pInstrInfo->name) |
1248 |
ts << " '" << pInstrInfo->name << "'"; |
ts << " '" << pInstrInfo->name << "'"; |
1249 |
ts << endl; |
ts << Qt::endl; |
1250 |
} // Check for errors... |
} // Check for errors... |
1251 |
else if (::lscp_client_get_errno(m_pClient)) { |
else if (::lscp_client_get_errno(m_pClient)) { |
1252 |
appendMessagesClient("lscp_get_midi_instrument_info"); |
appendMessagesClient("lscp_get_midi_instrument_info"); |
1255 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
1256 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
1257 |
} |
} |
1258 |
ts << endl; |
ts << Qt::endl; |
1259 |
// Check for errors... |
// Check for errors... |
1260 |
if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) { |
if (pInstrs == nullptr && ::lscp_client_get_errno(m_pClient)) { |
1261 |
appendMessagesClient("lscp_list_midi_instruments"); |
appendMessagesClient("lscp_list_midi_instruments"); |
1289 |
if (!midiDeviceMap.contains(iMidiDevice)) |
if (!midiDeviceMap.contains(iMidiDevice)) |
1290 |
continue; |
continue; |
1291 |
// Go for regular, canonical devices... |
// Go for regular, canonical devices... |
1292 |
ts << "# " << tr("Channel") << " " << iChannelID << endl; |
ts << "# " << tr("Channel") << " " << iChannelID << Qt::endl; |
1293 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << Qt::endl; |
1294 |
if (audioDeviceMap.isEmpty()) { |
if (audioDeviceMap.isEmpty()) { |
1295 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID |
1296 |
<< " " << pChannel->audioDriver() << endl; |
<< " " << pChannel->audioDriver() << Qt::endl; |
1297 |
} else { |
} else { |
1298 |
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID |
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannelID |
1299 |
<< " " << audioDeviceMap.value(iAudioDevice) << endl; |
<< " " << audioDeviceMap.value(iAudioDevice) << Qt::endl; |
1300 |
} |
} |
1301 |
if (midiDeviceMap.isEmpty()) { |
if (midiDeviceMap.isEmpty()) { |
1302 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID |
1303 |
<< " " << pChannel->midiDriver() << endl; |
<< " " << pChannel->midiDriver() << Qt::endl; |
1304 |
} else { |
} else { |
1305 |
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID |
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannelID |
1306 |
<< " " << midiDeviceMap.value(iMidiDevice) << endl; |
<< " " << midiDeviceMap.value(iMidiDevice) << Qt::endl; |
1307 |
} |
} |
1308 |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID |
1309 |
<< " " << pChannel->midiPort() << endl; |
<< " " << pChannel->midiPort() << Qt::endl; |
1310 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " "; |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " "; |
1311 |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
1312 |
ts << "ALL"; |
ts << "ALL"; |
1313 |
else |
else |
1314 |
ts << pChannel->midiChannel(); |
ts << pChannel->midiChannel(); |
1315 |
ts << endl; |
ts << Qt::endl; |
1316 |
ts << "LOAD ENGINE " << pChannel->engineName() |
ts << "LOAD ENGINE " << pChannel->engineName() |
1317 |
<< " " << iChannelID << endl; |
<< " " << iChannelID << Qt::endl; |
1318 |
if (pChannel->instrumentStatus() < 100) ts << "# "; |
if (pChannel->instrumentStatus() < 100) ts << "# "; |
1319 |
ts << "LOAD INSTRUMENT NON_MODAL '" |
ts << "LOAD INSTRUMENT NON_MODAL '" |
1320 |
<< pChannel->instrumentFile() << "' " |
<< pChannel->instrumentFile() << "' " |
1321 |
<< pChannel->instrumentNr() << " " << iChannelID << endl; |
<< pChannel->instrumentNr() << " " << iChannelID << Qt::endl; |
1322 |
ChannelRoutingMap::ConstIterator audioRoute; |
ChannelRoutingMap::ConstIterator audioRoute; |
1323 |
for (audioRoute = pChannel->audioRouting().begin(); |
for (audioRoute = pChannel->audioRouting().begin(); |
1324 |
audioRoute != pChannel->audioRouting().end(); |
audioRoute != pChannel->audioRouting().end(); |
1325 |
++audioRoute) { |
++audioRoute) { |
1326 |
ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannelID |
ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannelID |
1327 |
<< " " << audioRoute.key() |
<< " " << audioRoute.key() |
1328 |
<< " " << audioRoute.value() << endl; |
<< " " << audioRoute.value() << Qt::endl; |
1329 |
} |
} |
1330 |
ts << "SET CHANNEL VOLUME " << iChannelID |
ts << "SET CHANNEL VOLUME " << iChannelID |
1331 |
<< " " << pChannel->volume() << endl; |
<< " " << pChannel->volume() << Qt::endl; |
1332 |
if (pChannel->channelMute()) |
if (pChannel->channelMute()) |
1333 |
ts << "SET CHANNEL MUTE " << iChannelID << " 1" << endl; |
ts << "SET CHANNEL MUTE " << iChannelID << " 1" << Qt::endl; |
1334 |
if (pChannel->channelSolo()) |
if (pChannel->channelSolo()) |
1335 |
ts << "SET CHANNEL SOLO " << iChannelID << " 1" << endl; |
ts << "SET CHANNEL SOLO " << iChannelID << " 1" << Qt::endl; |
1336 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1337 |
const int iMidiMap = pChannel->midiMap(); |
const int iMidiMap = pChannel->midiMap(); |
1338 |
if (midiInstrumentMap.contains(iMidiMap)) { |
if (midiInstrumentMap.contains(iMidiMap)) { |
1339 |
ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID |
ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannelID |
1340 |
<< " " << midiInstrumentMap.value(iMidiMap) << endl; |
<< " " << midiInstrumentMap.value(iMidiMap) << Qt::endl; |
1341 |
} |
} |
1342 |
#endif |
#endif |
1343 |
#ifdef CONFIG_FXSEND |
#ifdef CONFIG_FXSEND |
1352 |
<< " " << pFxSendInfo->midi_controller; |
<< " " << pFxSendInfo->midi_controller; |
1353 |
if (pFxSendInfo->name) |
if (pFxSendInfo->name) |
1354 |
ts << " '" << pFxSendInfo->name << "'"; |
ts << " '" << pFxSendInfo->name << "'"; |
1355 |
ts << endl; |
ts << Qt::endl; |
1356 |
int *piRouting = pFxSendInfo->audio_routing; |
int *piRouting = pFxSendInfo->audio_routing; |
1357 |
for (int iAudioSrc = 0; |
for (int iAudioSrc = 0; |
1358 |
piRouting && piRouting[iAudioSrc] >= 0; |
piRouting && piRouting[iAudioSrc] >= 0; |
1361 |
<< iChannelID |
<< iChannelID |
1362 |
<< " " << iFxSend |
<< " " << iFxSend |
1363 |
<< " " << iAudioSrc |
<< " " << iAudioSrc |
1364 |
<< " " << piRouting[iAudioSrc] << endl; |
<< " " << piRouting[iAudioSrc] << Qt::endl; |
1365 |
} |
} |
1366 |
#ifdef CONFIG_FXSEND_LEVEL |
#ifdef CONFIG_FXSEND_LEVEL |
1367 |
ts << "SET FX_SEND LEVEL " << iChannelID |
ts << "SET FX_SEND LEVEL " << iChannelID |
1368 |
<< " " << iFxSend |
<< " " << iFxSend |
1369 |
<< " " << pFxSendInfo->level << endl; |
<< " " << pFxSendInfo->level << Qt::endl; |
1370 |
#endif |
#endif |
1371 |
} // Check for errors... |
} // Check for errors... |
1372 |
else if (::lscp_client_get_errno(m_pClient)) { |
else if (::lscp_client_get_errno(m_pClient)) { |
1375 |
} |
} |
1376 |
} |
} |
1377 |
#endif |
#endif |
1378 |
ts << endl; |
ts << Qt::endl; |
1379 |
// Go for next channel... |
// Go for next channel... |
1380 |
++iChannelID; |
++iChannelID; |
1381 |
} |
} |
1385 |
} |
} |
1386 |
|
|
1387 |
#ifdef CONFIG_VOLUME |
#ifdef CONFIG_VOLUME |
1388 |
ts << "# " << tr("Global volume level") << endl; |
ts << "# " << tr("Global volume level") << Qt::endl; |
1389 |
ts << "SET VOLUME " << ::lscp_get_volume(m_pClient) << endl; |
ts << "SET VOLUME " << ::lscp_get_volume(m_pClient) << Qt::endl; |
1390 |
ts << endl; |
ts << Qt::endl; |
1391 |
#endif |
#endif |
1392 |
|
|
1393 |
// Ok. we've wrote it. |
// Ok. we've wrote it. |