77 |
} |
} |
78 |
#endif |
#endif |
79 |
|
|
80 |
|
|
81 |
|
// All winsock apps needs this. |
82 |
|
#if defined(WIN32) |
83 |
|
static WSADATA _wsaData; |
84 |
|
#endif |
85 |
|
|
86 |
|
|
87 |
|
namespace QSampler { |
88 |
|
|
89 |
// Timer constant stuff. |
// Timer constant stuff. |
90 |
#define QSAMPLER_TIMER_MSECS 200 |
#define QSAMPLER_TIMER_MSECS 200 |
91 |
|
|
96 |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
97 |
|
|
98 |
|
|
|
// All winsock apps needs this. |
|
|
#if defined(WIN32) |
|
|
static WSADATA _wsaData; |
|
|
#endif |
|
|
|
|
|
|
|
99 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
100 |
// qsamplerCustomEvent -- specialty for callback comunication. |
// CustomEvent -- specialty for callback comunication. |
101 |
|
|
102 |
#define QSAMPLER_CUSTOM_EVENT QEvent::Type(QEvent::User + 0) |
#define QSAMPLER_CUSTOM_EVENT QEvent::Type(QEvent::User + 0) |
103 |
|
|
104 |
class qsamplerCustomEvent : public QEvent |
class CustomEvent : public QEvent |
105 |
{ |
{ |
106 |
public: |
public: |
107 |
|
|
108 |
// Constructor. |
// Constructor. |
109 |
qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData) |
CustomEvent(lscp_event_t event, const char *pchData, int cchData) |
110 |
: QEvent(QSAMPLER_CUSTOM_EVENT) |
: QEvent(QSAMPLER_CUSTOM_EVENT) |
111 |
{ |
{ |
112 |
m_event = event; |
m_event = event; |
129 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
130 |
// qsamplerMainForm -- Main window form implementation. |
// qsamplerMainForm -- Main window form implementation. |
131 |
|
|
|
namespace QSampler { |
|
|
|
|
132 |
// Kind of singleton reference. |
// Kind of singleton reference. |
133 |
MainForm* MainForm::g_pMainForm = NULL; |
MainForm* MainForm::g_pMainForm = NULL; |
134 |
|
|
367 |
|
|
368 |
|
|
369 |
// Make and set a proper setup options step. |
// Make and set a proper setup options step. |
370 |
void MainForm::setup ( qsamplerOptions *pOptions ) |
void MainForm::setup ( Options *pOptions ) |
371 |
{ |
{ |
372 |
// We got options? |
// We got options? |
373 |
m_pOptions = pOptions; |
m_pOptions = pOptions; |
383 |
if (m_pOptions->bKeepOnTop) |
if (m_pOptions->bKeepOnTop) |
384 |
wflags |= Qt::Tool; |
wflags |= Qt::Tool; |
385 |
// Some child forms are to be created right now. |
// Some child forms are to be created right now. |
386 |
m_pMessages = new qsamplerMessages(this); |
m_pMessages = new Messages(this); |
387 |
m_pDeviceForm = new DeviceForm(this, wflags); |
m_pDeviceForm = new DeviceForm(this, wflags); |
388 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
389 |
m_pInstrumentListForm = new InstrumentListForm(this, wflags); |
m_pInstrumentListForm = new InstrumentListForm(this, wflags); |
512 |
QListIterator<QUrl> iter(pMimeData->urls()); |
QListIterator<QUrl> iter(pMimeData->urls()); |
513 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
514 |
const QString& sPath = iter.next().toLocalFile(); |
const QString& sPath = iter.next().toLocalFile(); |
515 |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
if (Channel::isInstrumentFile(sPath)) { |
516 |
// Try to create a new channel from instrument file... |
// Try to create a new channel from instrument file... |
517 |
qsamplerChannel *pChannel = new qsamplerChannel(); |
Channel *pChannel = new Channel(); |
518 |
if (pChannel == NULL) |
if (pChannel == NULL) |
519 |
return; |
return; |
520 |
// Start setting the instrument filename... |
// Start setting the instrument filename... |
550 |
{ |
{ |
551 |
// For the time being, just pump it to messages. |
// For the time being, just pump it to messages. |
552 |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
553 |
qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent; |
CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent); |
554 |
if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) { |
if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) { |
555 |
int iChannelID = pEvent->data().toInt(); |
int iChannelID = pEvent->data().toInt(); |
556 |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
577 |
// qsamplerMainForm -- Brainless public property accessors. |
// qsamplerMainForm -- Brainless public property accessors. |
578 |
|
|
579 |
// The global options settings property. |
// The global options settings property. |
580 |
qsamplerOptions *MainForm::options (void) const |
Options *MainForm::options (void) const |
581 |
{ |
{ |
582 |
return m_pOptions; |
return m_pOptions; |
583 |
} |
} |
738 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
739 |
ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
740 |
if (pChannelStrip) { |
if (pChannelStrip) { |
741 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
742 |
if (bForce && pChannel) |
if (bForce && pChannel) |
743 |
pChannel->removeChannel(); |
pChannel->removeChannel(); |
744 |
delete pChannelStrip; |
delete pChannelStrip; |
878 |
|
|
879 |
// Audio device mapping. |
// Audio device mapping. |
880 |
QMap<int, int> audioDeviceMap; |
QMap<int, int> audioDeviceMap; |
881 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Audio); |
882 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
883 |
ts << endl; |
ts << endl; |
884 |
qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]); |
Device device(Device::Audio, piDeviceIDs[iDevice]); |
885 |
// Audio device specification... |
// Audio device specification... |
886 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
887 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
888 |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
889 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
890 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
891 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
892 |
++deviceParam) { |
++deviceParam) { |
893 |
const qsamplerDeviceParam& param = deviceParam.value(); |
const DeviceParam& param = deviceParam.value(); |
894 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
895 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
896 |
} |
} |
897 |
ts << endl; |
ts << endl; |
898 |
// Audio channel parameters... |
// Audio channel parameters... |
899 |
int iPort = 0; |
int iPort = 0; |
900 |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
901 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
902 |
qsamplerDevicePort *pPort = iter.next(); |
DevicePort *pPort = iter.next(); |
903 |
qsamplerDeviceParamMap::ConstIterator portParam; |
DeviceParamMap::ConstIterator portParam; |
904 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
905 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
906 |
++portParam) { |
++portParam) { |
907 |
const qsamplerDeviceParam& param = portParam.value(); |
const DeviceParam& param = portParam.value(); |
908 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
909 |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
910 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
920 |
|
|
921 |
// MIDI device mapping. |
// MIDI device mapping. |
922 |
QMap<int, int> midiDeviceMap; |
QMap<int, int> midiDeviceMap; |
923 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Midi); |
924 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
925 |
ts << endl; |
ts << endl; |
926 |
qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]); |
Device device(Device::Midi, piDeviceIDs[iDevice]); |
927 |
// MIDI device specification... |
// MIDI device specification... |
928 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
929 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
930 |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
931 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
932 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
933 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
934 |
++deviceParam) { |
++deviceParam) { |
935 |
const qsamplerDeviceParam& param = deviceParam.value(); |
const DeviceParam& param = deviceParam.value(); |
936 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
937 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
938 |
} |
} |
939 |
ts << endl; |
ts << endl; |
940 |
// MIDI port parameters... |
// MIDI port parameters... |
941 |
int iPort = 0; |
int iPort = 0; |
942 |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
943 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
944 |
qsamplerDevicePort *pPort = iter.next(); |
DevicePort *pPort = iter.next(); |
945 |
qsamplerDeviceParamMap::ConstIterator portParam; |
DeviceParamMap::ConstIterator portParam; |
946 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
947 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
948 |
++portParam) { |
++portParam) { |
949 |
const qsamplerDeviceParam& param = portParam.value(); |
const DeviceParam& param = portParam.value(); |
950 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
951 |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
952 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
1038 |
ChannelStrip* pChannelStrip |
ChannelStrip* pChannelStrip |
1039 |
= static_cast<ChannelStrip *> (wlist.at(iChannel)); |
= static_cast<ChannelStrip *> (wlist.at(iChannel)); |
1040 |
if (pChannelStrip) { |
if (pChannelStrip) { |
1041 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1042 |
if (pChannel) { |
if (pChannel) { |
1043 |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
1044 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
1070 |
ts << "LOAD INSTRUMENT NON_MODAL '" |
ts << "LOAD INSTRUMENT NON_MODAL '" |
1071 |
<< pChannel->instrumentFile() << "' " |
<< pChannel->instrumentFile() << "' " |
1072 |
<< pChannel->instrumentNr() << " " << iChannel << endl; |
<< pChannel->instrumentNr() << " " << iChannel << endl; |
1073 |
qsamplerChannelRoutingMap::ConstIterator audioRoute; |
ChannelRoutingMap::ConstIterator audioRoute; |
1074 |
for (audioRoute = pChannel->audioRouting().begin(); |
for (audioRoute = pChannel->audioRouting().begin(); |
1075 |
audioRoute != pChannel->audioRouting().end(); |
audioRoute != pChannel->audioRouting().end(); |
1076 |
++audioRoute) { |
++audioRoute) { |
1315 |
return; |
return; |
1316 |
|
|
1317 |
// Just create the channel instance... |
// Just create the channel instance... |
1318 |
qsamplerChannel *pChannel = new qsamplerChannel(); |
Channel *pChannel = new Channel(); |
1319 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1320 |
return; |
return; |
1321 |
|
|
1353 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1354 |
return; |
return; |
1355 |
|
|
1356 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1357 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1358 |
return; |
return; |
1359 |
|
|
1925 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1926 |
// Check if theres already a channel strip for this one... |
// Check if theres already a channel strip for this one... |
1927 |
if (!channelStrip(piChannelIDs[iChannel])) |
if (!channelStrip(piChannelIDs[iChannel])) |
1928 |
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
createChannelStrip(new Channel(piChannelIDs[iChannel])); |
1929 |
} |
} |
1930 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1931 |
} |
} |
2177 |
// qsamplerMainForm -- MDI channel strip management. |
// qsamplerMainForm -- MDI channel strip management. |
2178 |
|
|
2179 |
// The channel strip creation executive. |
// The channel strip creation executive. |
2180 |
ChannelStrip* MainForm::createChannelStrip ( qsamplerChannel *pChannel ) |
ChannelStrip* MainForm::createChannelStrip ( Channel *pChannel ) |
2181 |
{ |
{ |
2182 |
if (m_pClient == NULL || pChannel == NULL) |
if (m_pClient == NULL || pChannel == NULL) |
2183 |
return NULL; |
return NULL; |
2249 |
ChannelStrip* pChannelStrip |
ChannelStrip* pChannelStrip |
2250 |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
2251 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2252 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
2253 |
if (pChannel && pChannel->channelID() == iChannelID) |
if (pChannel && pChannel->channelID() == iChannelID) |
2254 |
return pChannelStrip; |
return pChannelStrip; |
2255 |
} |
} |
2531 |
// as this is run under some other thread context. |
// as this is run under some other thread context. |
2532 |
// A custom event must be posted here... |
// A custom event must be posted here... |
2533 |
QApplication::postEvent(pMainForm, |
QApplication::postEvent(pMainForm, |
2534 |
new qsamplerCustomEvent(event, pchData, cchData)); |
new CustomEvent(event, pchData, cchData)); |
2535 |
|
|
2536 |
return LSCP_OK; |
return LSCP_OK; |
2537 |
} |
} |