686 |
// Save current session to specific file path. |
// Save current session to specific file path. |
687 |
bool qsamplerMainForm::saveSessionFile ( const QString& sFilename ) |
bool qsamplerMainForm::saveSessionFile ( const QString& sFilename ) |
688 |
{ |
{ |
689 |
|
if (m_pClient == NULL) |
690 |
|
return false; |
691 |
|
|
692 |
|
// Check whether server is apparently OK... |
693 |
|
if (::lscp_get_channels(m_pClient) < 0) { |
694 |
|
appendMessagesClient("lscp_get_channels"); |
695 |
|
return false; |
696 |
|
} |
697 |
|
|
698 |
// Open and write into real file. |
// Open and write into real file. |
699 |
QFile file(sFilename); |
QFile file(sFilename); |
700 |
if (!file.open(IO_WriteOnly | IO_Truncate)) { |
if (!file.open(IO_WriteOnly | IO_Truncate)) { |
718 |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
719 |
ts << "#" << endl; |
ts << "#" << endl; |
720 |
ts << endl; |
ts << endl; |
721 |
|
|
722 |
// It is assumed that this new kind of device+session file |
// It is assumed that this new kind of device+session file |
723 |
// will be loaded from a complete |
// will be loaded from a complete initialized server... |
724 |
int *piDeviceIDs; |
int *piDeviceIDs; |
725 |
int iDevice; |
int iDevice; |
726 |
ts << "RESET" << endl; |
ts << "RESET" << endl; |
727 |
|
|
728 |
// Audio device mapping. |
// Audio device mapping. |
729 |
QMap<int, int> audioDeviceMap; |
QMap<int, int> audioDeviceMap; |
730 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
762 |
} |
} |
763 |
// Audio device index/id mapping. |
// Audio device index/id mapping. |
764 |
audioDeviceMap[device.deviceID()] = iDevice; |
audioDeviceMap[device.deviceID()] = iDevice; |
765 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
766 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
767 |
} |
} |
768 |
|
|
769 |
// MIDI device mapping. |
// MIDI device mapping. |
770 |
QMap<int, int> midiDeviceMap; |
QMap<int, int> midiDeviceMap; |
771 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
803 |
} |
} |
804 |
// MIDI device index/id mapping. |
// MIDI device index/id mapping. |
805 |
midiDeviceMap[device.deviceID()] = iDevice; |
midiDeviceMap[device.deviceID()] = iDevice; |
806 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
807 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
808 |
} |
} |
809 |
ts << endl; |
ts << endl; |
810 |
|
|
811 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
812 |
|
// MIDI instrument mapping... |
813 |
|
int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient); |
814 |
|
for (int iMap = 0; piMaps && piMaps[iMap] >= 0; iMap++) { |
815 |
|
int iMidiMap = piMaps[iMap]; |
816 |
|
const char *pszMapName |
817 |
|
= ::lscp_get_midi_instrument_map_name(m_pClient, iMidiMap); |
818 |
|
ts << "# " << tr("MIDI instrument map") << " " << iMidiMap; |
819 |
|
if (pszMapName) |
820 |
|
ts << " - " << pszMapName; |
821 |
|
ts << endl; |
822 |
|
ts << "ADD MIDI_INSTRUMENT_MAP"; |
823 |
|
if (pszMapName) |
824 |
|
ts << " '" << pszMapName << "'"; |
825 |
|
ts << endl; |
826 |
|
// MIDI instrument mapping... |
827 |
|
lscp_midi_instrument_t *pInstrs |
828 |
|
= ::lscp_list_midi_instruments(m_pClient, iMidiMap); |
829 |
|
for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; iInstr++) { |
830 |
|
lscp_midi_instrument_info_t *pInstrInfo |
831 |
|
= ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]); |
832 |
|
if (pInstrInfo) { |
833 |
|
ts << "MAP MIDI_INSTRUMENT " |
834 |
|
<< pInstrs[iInstr].map << " " |
835 |
|
<< pInstrs[iInstr].bank << " " |
836 |
|
<< pInstrs[iInstr].prog << " " |
837 |
|
<< pInstrInfo->engine_name << " '" |
838 |
|
<< pInstrInfo->instrument_file << "' " |
839 |
|
<< pInstrInfo->instrument_nr << " " |
840 |
|
<< pInstrInfo->volume << " "; |
841 |
|
switch (pInstrInfo->load_mode) { |
842 |
|
case LSCP_LOAD_PERSISTENT: |
843 |
|
ts << "PERSISTENT"; |
844 |
|
break; |
845 |
|
case LSCP_LOAD_ON_DEMAND_HOLD: |
846 |
|
ts << "ON_DEMAND_HOLD"; |
847 |
|
break; |
848 |
|
case LSCP_LOAD_ON_DEMAND: |
849 |
|
case LSCP_LOAD_DEFAULT: |
850 |
|
default: |
851 |
|
ts << "ON_DEMAND"; |
852 |
|
break; |
853 |
|
} |
854 |
|
if (pInstrInfo->name) |
855 |
|
ts << " '" << pInstrInfo->name << "'"; |
856 |
|
ts << endl; |
857 |
|
} |
858 |
|
// Try to keep it snappy :) |
859 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
860 |
|
} |
861 |
|
if (pInstrs) |
862 |
|
ts << endl; |
863 |
|
} |
864 |
|
#endif // CONFIG_MIDI_INSTRUMENT |
865 |
|
|
866 |
// Sampler channel mapping. |
// Sampler channel mapping. |
867 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
868 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
895 |
ts << pChannel->midiChannel(); |
ts << pChannel->midiChannel(); |
896 |
ts << endl; |
ts << endl; |
897 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
898 |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl; |
if (pChannel->instrumentStatus() < 100) ts << "# "; |
899 |
|
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " |
900 |
|
<< pChannel->instrumentNr() << " " << iChannel << endl; |
901 |
qsamplerChannelRoutingMap::ConstIterator audioRoute; |
qsamplerChannelRoutingMap::ConstIterator audioRoute; |
902 |
for (audioRoute = pChannel->audioRouting().begin(); |
for (audioRoute = pChannel->audioRouting().begin(); |
903 |
audioRoute != pChannel->audioRouting().end(); |
audioRoute != pChannel->audioRouting().end(); |
906 |
<< " " << audioRoute.key() |
<< " " << audioRoute.key() |
907 |
<< " " << audioRoute.data() << endl; |
<< " " << audioRoute.data() << endl; |
908 |
} |
} |
909 |
ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl; |
ts << "SET CHANNEL VOLUME " << iChannel |
910 |
|
<< " " << pChannel->volume() << endl; |
911 |
if (pChannel->channelMute()) |
if (pChannel->channelMute()) |
912 |
ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl; |
ts << "SET CHANNEL MUTE " << iChannel << " 1" << endl; |
913 |
if (pChannel->channelSolo()) |
if (pChannel->channelSolo()) |
914 |
ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl; |
ts << "SET CHANNEL SOLO " << iChannel << " 1" << endl; |
915 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
916 |
|
if (pChannel->midiMap() >= 0) { |
917 |
|
ts << "SET CHANNEL MIDI_INSTRUMENT_MAP " << iChannel |
918 |
|
<< " " << pChannel->midiChannel() << endl; |
919 |
|
} |
920 |
|
#endif |
921 |
ts << endl; |
ts << endl; |
922 |
} |
} |
923 |
} |
} |
925 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
926 |
} |
} |
927 |
|
|
|
#ifdef CONFIG_MIDI_INSTRUMENT |
|
|
// MIDI instrument mapping... |
|
|
lscp_midi_instrument_t *pInstrs = ::lscp_list_midi_instruments(m_pClient); |
|
|
if (pInstrs) |
|
|
ts << "# " << tr("MIDI instrument mapping") << endl; |
|
|
for (int iInstr = 0; pInstrs && pInstrs[iInstr].program >= 0; iInstr++) { |
|
|
lscp_midi_instrument_info_t *pInstrInfo |
|
|
= ::lscp_get_midi_instrument_info(m_pClient, &pInstrs[iInstr]); |
|
|
if (pInstrInfo) { |
|
|
ts << "MAP MIDI_INSTRUMENT " |
|
|
<< pInstrs[iInstr].bank_msb << " " |
|
|
<< pInstrs[iInstr].bank_lsb << " " |
|
|
<< pInstrs[iInstr].program << " " |
|
|
<< pInstrInfo->engine_name << " '" |
|
|
<< pInstrInfo->instrument_file << "' " |
|
|
<< pInstrInfo->instrument_nr << " " |
|
|
<< pInstrInfo->volume << " "; |
|
|
switch (pInstrInfo->load_mode) { |
|
|
case LSCP_LOAD_PERSISTENT: |
|
|
ts << "PERSISTENT"; |
|
|
break; |
|
|
case LSCP_LOAD_ON_DEMAND_HOLD: |
|
|
ts << "ON_DEMAND_HOLD"; |
|
|
break; |
|
|
case LSCP_LOAD_ON_DEMAND: |
|
|
case LSCP_LOAD_DEFAULT: |
|
|
default: |
|
|
ts << "ON_DEMAND"; |
|
|
break; |
|
|
} |
|
|
if (pInstrInfo->name) |
|
|
ts << " '" << pInstrInfo->name << "'"; |
|
|
ts << endl; |
|
|
} |
|
|
// Try to keep it snappy :) |
|
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
|
|
} |
|
|
if (pInstrs) |
|
|
ts << endl; |
|
|
#endif // CONFIG_MIDI_INSTRUMENT |
|
|
|
|
928 |
// Ok. we've wrote it. |
// Ok. we've wrote it. |
929 |
file.close(); |
file.close(); |
930 |
|
|
1574 |
// Grab and restore current sampler channels session. |
// Grab and restore current sampler channels session. |
1575 |
void qsamplerMainForm::updateSession (void) |
void qsamplerMainForm::updateSession (void) |
1576 |
{ |
{ |
1577 |
|
#ifdef CONFIG_MIDI_INSTRUMENT |
1578 |
|
// FIXME Make some room for default instrument maps... |
1579 |
|
int iMaps = ::lscp_get_midi_instrument_maps(m_pClient); |
1580 |
|
if (iMaps < 0) |
1581 |
|
appendMessagesClient("lscp_get_midi_instrument_maps"); |
1582 |
|
else if (iMaps < 1) { |
1583 |
|
::lscp_add_midi_instrument_map(m_pClient, tr("Chromatic").latin1()); |
1584 |
|
::lscp_add_midi_instrument_map(m_pClient, tr("Drum Kits").latin1()); |
1585 |
|
} |
1586 |
|
#endif |
1587 |
|
|
1588 |
// Retrieve the current channel list. |
// Retrieve the current channel list. |
1589 |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1590 |
if (piChannelIDs == NULL) { |
if (piChannelIDs == NULL) { |
1605 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1606 |
} |
} |
1607 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1608 |
|
|
1609 |
// Remember to refresh devices and instruments... |
// Remember to refresh devices and instruments... |
1610 |
if (m_pInstrumentListForm) |
if (m_pInstrumentListForm) |
1611 |
m_pInstrumentListForm->refreshInstruments(); |
m_pInstrumentListForm->refreshInstruments(); |