554 |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
555 |
CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent); |
CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent); |
556 |
switch (pEvent->event()) { |
switch (pEvent->event()) { |
557 |
|
case LSCP_EVENT_CHANNEL_COUNT: |
558 |
|
updateAllChannelStrips(true); |
559 |
|
break; |
560 |
case LSCP_EVENT_CHANNEL_INFO: { |
case LSCP_EVENT_CHANNEL_INFO: { |
561 |
int iChannelID = pEvent->data().toInt(); |
int iChannelID = pEvent->data().toInt(); |
562 |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
575 |
DeviceStatusForm::onDeviceChanged(iDeviceID); |
DeviceStatusForm::onDeviceChanged(iDeviceID); |
576 |
break; |
break; |
577 |
} |
} |
578 |
|
case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT: |
579 |
|
if (m_pDeviceForm) m_pDeviceForm->refreshDevices(); |
580 |
|
break; |
581 |
|
case LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO: |
582 |
|
if (m_pDeviceForm) m_pDeviceForm->refreshDevices(); |
583 |
|
break; |
584 |
#if CONFIG_LSCP_CHANNEL_MIDI |
#if CONFIG_LSCP_CHANNEL_MIDI |
585 |
case LSCP_EVENT_CHANNEL_MIDI: { |
case LSCP_EVENT_CHANNEL_MIDI: { |
586 |
const int iChannelID = pEvent->data().section(' ', 0, 0).toInt(); |
const int iChannelID = pEvent->data().section(' ', 0, 0).toInt(); |
1971 |
} |
} |
1972 |
#endif |
#endif |
1973 |
|
|
1974 |
|
updateAllChannelStrips(false); |
1975 |
|
|
1976 |
|
// Do we auto-arrange? |
1977 |
|
if (m_pOptions && m_pOptions->bAutoArrange) |
1978 |
|
channelsArrange(); |
1979 |
|
|
1980 |
|
// Remember to refresh devices and instruments... |
1981 |
|
if (m_pInstrumentListForm) |
1982 |
|
m_pInstrumentListForm->refreshInstruments(); |
1983 |
|
if (m_pDeviceForm) |
1984 |
|
m_pDeviceForm->refreshDevices(); |
1985 |
|
} |
1986 |
|
|
1987 |
|
void MainForm::updateAllChannelStrips(bool bRemoveDeadStrips) { |
1988 |
// Retrieve the current channel list. |
// Retrieve the current channel list. |
1989 |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1990 |
if (piChannelIDs == NULL) { |
if (piChannelIDs == NULL) { |
2001 |
if (!channelStrip(piChannelIDs[iChannel])) |
if (!channelStrip(piChannelIDs[iChannel])) |
2002 |
createChannelStrip(new Channel(piChannelIDs[iChannel])); |
createChannelStrip(new Channel(piChannelIDs[iChannel])); |
2003 |
} |
} |
|
m_pWorkspace->setUpdatesEnabled(true); |
|
|
} |
|
2004 |
|
|
2005 |
// Do we auto-arrange? |
// Do we auto-arrange? |
2006 |
if (m_pOptions && m_pOptions->bAutoArrange) |
if (m_pOptions && m_pOptions->bAutoArrange) |
2007 |
channelsArrange(); |
channelsArrange(); |
2008 |
|
|
2009 |
// Remember to refresh devices and instruments... |
stabilizeForm(); |
|
if (m_pInstrumentListForm) |
|
|
m_pInstrumentListForm->refreshInstruments(); |
|
|
if (m_pDeviceForm) |
|
|
m_pDeviceForm->refreshDevices(); |
|
|
} |
|
2010 |
|
|
2011 |
|
// remove dead channel strips |
2012 |
|
if (bRemoveDeadStrips) { |
2013 |
|
for (int i = 0; channelStripAt(i); ++i) { |
2014 |
|
ChannelStrip* pChannelStrip = channelStripAt(i); |
2015 |
|
bool bExists = false; |
2016 |
|
for (int j = 0; piChannelIDs[j] >= 0; ++j) { |
2017 |
|
if (!pChannelStrip->channel()) break; |
2018 |
|
if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) { |
2019 |
|
// strip exists, don't touch it |
2020 |
|
bExists = true; |
2021 |
|
break; |
2022 |
|
} |
2023 |
|
} |
2024 |
|
if (!bExists) destroyChannelStrip(pChannelStrip); |
2025 |
|
} |
2026 |
|
} |
2027 |
|
m_pWorkspace->setUpdatesEnabled(true); |
2028 |
|
} |
2029 |
|
} |
2030 |
|
|
2031 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
2032 |
void MainForm::updateRecentFiles ( const QString& sFilename ) |
void MainForm::updateRecentFiles ( const QString& sFilename ) |
2305 |
return pChannelStrip; |
return pChannelStrip; |
2306 |
} |
} |
2307 |
|
|
2308 |
|
void MainForm::destroyChannelStrip(ChannelStrip* pChannelStrip) { |
2309 |
|
// Just delete the channel strip. |
2310 |
|
delete pChannelStrip; |
2311 |
|
|
2312 |
|
// Do we auto-arrange? |
2313 |
|
if (m_pOptions && m_pOptions->bAutoArrange) |
2314 |
|
channelsArrange(); |
2315 |
|
|
2316 |
|
stabilizeForm(); |
2317 |
|
} |
2318 |
|
|
2319 |
// Retrieve the active channel strip. |
// Retrieve the active channel strip. |
2320 |
ChannelStrip* MainForm::activeChannelStrip (void) |
ChannelStrip* MainForm::activeChannelStrip (void) |
2326 |
// Retrieve a channel strip by index. |
// Retrieve a channel strip by index. |
2327 |
ChannelStrip* MainForm::channelStripAt ( int iChannel ) |
ChannelStrip* MainForm::channelStripAt ( int iChannel ) |
2328 |
{ |
{ |
2329 |
|
if (!m_pWorkspace) return NULL; |
2330 |
|
|
2331 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
2332 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2333 |
return NULL; |
return NULL; |
2334 |
|
|
2335 |
return static_cast<ChannelStrip *> (wlist.at(iChannel)); |
if (iChannel < 0 || iChannel >= wlist.size()) |
2336 |
|
return NULL; |
2337 |
|
|
2338 |
|
return dynamic_cast<ChannelStrip *> (wlist.at(iChannel)); |
2339 |
} |
} |
2340 |
|
|
2341 |
|
|
2705 |
.arg(::lscp_client_get_timeout(m_pClient))); |
.arg(::lscp_client_get_timeout(m_pClient))); |
2706 |
|
|
2707 |
// Subscribe to channel info change notifications... |
// Subscribe to channel info change notifications... |
2708 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT) != LSCP_OK) |
2709 |
|
appendMessagesClient("lscp_client_subscribe(CHANNEL_COUNT)"); |
2710 |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK) |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK) |
2711 |
appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)"); |
appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)"); |
2712 |
|
|
2716 |
appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)"); |
appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)"); |
2717 |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO) != LSCP_OK) |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO) != LSCP_OK) |
2718 |
appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_INFO)"); |
appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_INFO)"); |
2719 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT) != LSCP_OK) |
2720 |
|
appendMessagesClient("lscp_client_subscribe(AUDIO_OUTPUT_DEVICE_COUNT)"); |
2721 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO) != LSCP_OK) |
2722 |
|
appendMessagesClient("lscp_client_subscribe(AUDIO_OUTPUT_DEVICE_INFO)"); |
2723 |
|
|
2724 |
#if CONFIG_LSCP_CHANNEL_MIDI |
#if CONFIG_LSCP_CHANNEL_MIDI |
2725 |
// Subscribe to channel MIDI data notifications... |
// Subscribe to channel MIDI data notifications... |
2791 |
#if CONFIG_LSCP_CHANNEL_MIDI |
#if CONFIG_LSCP_CHANNEL_MIDI |
2792 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI); |
2793 |
#endif |
#endif |
2794 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_INFO); |
2795 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_AUDIO_OUTPUT_DEVICE_COUNT); |
2796 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_INFO); |
2797 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT); |
2798 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
2799 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_COUNT); |
2800 |
::lscp_client_destroy(m_pClient); |
::lscp_client_destroy(m_pClient); |
2801 |
m_pClient = NULL; |
m_pClient = NULL; |
2802 |
|
|