598 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
599 |
appendMessagesClient("lscp_client_query"); |
appendMessagesClient("lscp_client_query"); |
600 |
iErrors++; |
iErrors++; |
|
break; |
|
601 |
} |
} |
602 |
} |
} |
603 |
// Try to make it snappy :) |
// Try to make it snappy :) |
607 |
// Ok. we've read it. |
// Ok. we've read it. |
608 |
file.close(); |
file.close(); |
609 |
|
|
|
// Have we any errors? |
|
|
if (iErrors > 0) |
|
|
appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
|
|
|
|
610 |
// Now we'll try to create (update) the whole GUI session. |
// Now we'll try to create (update) the whole GUI session. |
611 |
updateSession(); |
updateSession(); |
612 |
|
|
613 |
|
// Have we any errors? |
614 |
|
if (iErrors > 0) |
615 |
|
appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
616 |
|
|
617 |
// Save as default session directory. |
// Save as default session directory. |
618 |
if (m_pOptions) |
if (m_pOptions) |
619 |
m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true); |
m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true); |
620 |
// We're not dirty anymore. |
// We're not dirty anymore, if loaded without errors, |
621 |
m_iDirtyCount = 0; |
m_iDirtyCount = iErrors; |
622 |
// Stabilize form... |
// Stabilize form... |
623 |
m_sFilename = sFilename; |
m_sFilename = sFilename; |
624 |
updateRecentFiles(sFilename); |
updateRecentFiles(sFilename); |
641 |
} |
} |
642 |
|
|
643 |
// Write the file. |
// Write the file. |
644 |
int iErrors = 0; |
int iErrors = 0; |
645 |
QTextStream ts(&file); |
QTextStream ts(&file); |
646 |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl; |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl; |
647 |
ts << "# " << tr("Version") |
ts << "# " << tr("Version") |
652 |
ts << "# " << tr("File") |
ts << "# " << tr("File") |
653 |
<< ": " << QFileInfo(sFilename).fileName() << endl; |
<< ": " << QFileInfo(sFilename).fileName() << endl; |
654 |
ts << "# " << tr("Date") |
ts << "# " << tr("Date") |
655 |
<< ": " << QDate::currentDate().toString("MMMM dd yyyy") |
<< ": " << QDate::currentDate().toString("MMM dd yyyy") |
656 |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
657 |
ts << "#" << endl; |
ts << "#" << endl; |
658 |
ts << endl; |
ts << endl; |
659 |
|
// It is assumed that this new kind of device+session file |
660 |
|
// will be loaded from a complete |
661 |
|
int *piDeviceIDs; |
662 |
|
int iDevice; |
663 |
|
ts << "RESET" << endl; |
664 |
|
// Audio device mapping. |
665 |
|
QMap<int, int> audioDeviceMap; |
666 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
667 |
|
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
668 |
|
ts << endl; |
669 |
|
qsamplerDevice device(m_pClient, qsamplerDevice::Audio, piDeviceIDs[iDevice]); |
670 |
|
// Audio device specification... |
671 |
|
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
672 |
|
<< " " << tr("Device") << " " << iDevice << endl; |
673 |
|
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
674 |
|
qsamplerDeviceParamMap::ConstIterator deviceParam; |
675 |
|
for (deviceParam = device.params().begin(); |
676 |
|
deviceParam != device.params().end(); |
677 |
|
++deviceParam) { |
678 |
|
const qsamplerDeviceParam& param = deviceParam.data(); |
679 |
|
if (!param.value.isEmpty()) |
680 |
|
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
681 |
|
} |
682 |
|
ts << endl; |
683 |
|
// Audio channel parameters... |
684 |
|
int iPort = 0; |
685 |
|
for (qsamplerDevicePort *pPort = device.ports().first(); |
686 |
|
pPort; |
687 |
|
pPort = device.ports().next(), ++iPort) { |
688 |
|
qsamplerDeviceParamMap::ConstIterator portParam; |
689 |
|
for (portParam = pPort->params().begin(); |
690 |
|
portParam != pPort->params().end(); |
691 |
|
++portParam) { |
692 |
|
const qsamplerDeviceParam& param = portParam.data(); |
693 |
|
if (!param.fix && !param.value.isEmpty()) { |
694 |
|
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
695 |
|
<< " " << iPort << " " << portParam.key() |
696 |
|
<< "='" << param.value << "'" << endl; |
697 |
|
} |
698 |
|
} |
699 |
|
} |
700 |
|
// Audio device index/id mapping. |
701 |
|
audioDeviceMap[device.deviceID()] = iDevice; |
702 |
|
// Try to keep it snappy :) |
703 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
704 |
|
} |
705 |
|
// MIDI device mapping. |
706 |
|
QMap<int, int> midiDeviceMap; |
707 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
708 |
|
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
709 |
|
ts << endl; |
710 |
|
qsamplerDevice device(m_pClient, qsamplerDevice::Midi, piDeviceIDs[iDevice]); |
711 |
|
// MIDI device specification... |
712 |
|
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
713 |
|
<< " " << tr("Device") << " " << iDevice << endl; |
714 |
|
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
715 |
|
qsamplerDeviceParamMap::ConstIterator deviceParam; |
716 |
|
for (deviceParam = device.params().begin(); |
717 |
|
deviceParam != device.params().end(); |
718 |
|
++deviceParam) { |
719 |
|
const qsamplerDeviceParam& param = deviceParam.data(); |
720 |
|
if (!param.value.isEmpty()) |
721 |
|
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
722 |
|
} |
723 |
|
ts << endl; |
724 |
|
// MIDI port parameters... |
725 |
|
int iPort = 0; |
726 |
|
for (qsamplerDevicePort *pPort = device.ports().first(); |
727 |
|
pPort; |
728 |
|
pPort = device.ports().next(), ++iPort) { |
729 |
|
qsamplerDeviceParamMap::ConstIterator portParam; |
730 |
|
for (portParam = pPort->params().begin(); |
731 |
|
portParam != pPort->params().end(); |
732 |
|
++portParam) { |
733 |
|
const qsamplerDeviceParam& param = portParam.data(); |
734 |
|
if (!param.fix && !param.value.isEmpty()) { |
735 |
|
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
736 |
|
<< " " << iPort << " " << portParam.key() |
737 |
|
<< "='" << param.value << "'" << endl; |
738 |
|
} |
739 |
|
} |
740 |
|
} |
741 |
|
// MIDI device index/id mapping. |
742 |
|
midiDeviceMap[device.deviceID()] = iDevice; |
743 |
|
// Try to keep it snappy :) |
744 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
745 |
|
} |
746 |
|
ts << endl; |
747 |
|
// Sampler channel mapping. |
748 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
749 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
750 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
751 |
if (pChannelStrip) { |
if (pChannelStrip) { |
752 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
753 |
if (pChannel) { |
if (pChannel) { |
754 |
ts << "# Channel " << iChannel << endl; |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
755 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
756 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel << " " << pChannel->audioDriver() << endl; |
if (audioDeviceMap.isEmpty()) { |
757 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel << " " << pChannel->midiDriver() << endl; |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel |
758 |
// ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel << " " << pChannel->midiPort() << endl; |
<< " " << pChannel->audioDriver() << endl; |
759 |
|
} else { |
760 |
|
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel |
761 |
|
<< " " << audioDeviceMap[pChannel->audioDevice()] << endl; |
762 |
|
} |
763 |
|
if (midiDeviceMap.isEmpty()) { |
764 |
|
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel |
765 |
|
<< " " << pChannel->midiDriver() << endl; |
766 |
|
} else { |
767 |
|
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel |
768 |
|
<< " " << midiDeviceMap[pChannel->midiDevice()] << endl; |
769 |
|
} |
770 |
|
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel |
771 |
|
<< " " << pChannel->midiPort() << endl; |
772 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " "; |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " "; |
773 |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
774 |
ts << "ALL"; |
ts << "ALL"; |
1408 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1409 |
} |
} |
1410 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1411 |
|
|
1412 |
|
// Remember to refresh devices |
1413 |
|
if (m_pDeviceForm) |
1414 |
|
m_pDeviceForm->refreshDevices(); |
1415 |
} |
} |
1416 |
|
|
1417 |
|
|