2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, 2008 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
33 |
#include "qsamplerInstrumentListForm.h" |
#include "qsamplerInstrumentListForm.h" |
34 |
#include "qsamplerDeviceForm.h" |
#include "qsamplerDeviceForm.h" |
35 |
#include "qsamplerOptionsForm.h" |
#include "qsamplerOptionsForm.h" |
36 |
|
#include "qsamplerDeviceStatusForm.h" |
37 |
|
|
38 |
#include <QApplication> |
#include <QApplication> |
39 |
#include <QWorkspace> |
#include <QWorkspace> |
560 |
channelStripChanged(pChannelStrip); |
channelStripChanged(pChannelStrip); |
561 |
break; |
break; |
562 |
} |
} |
563 |
|
case LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT: |
564 |
|
DeviceStatusForm::onDevicesChanged(); |
565 |
|
updateViewMidiDeviceStatusMenu(); |
566 |
|
break; //TODO: refresh device dialog as well |
567 |
#if CONFIG_LSCP_CHANNEL_MIDI |
#if CONFIG_LSCP_CHANNEL_MIDI |
568 |
case LSCP_EVENT_CHANNEL_MIDI: { |
case LSCP_EVENT_CHANNEL_MIDI: { |
569 |
int iChannelID = pEvent->data().section(' ', 0, 0).toInt(); |
const int iChannelID = pEvent->data().section(' ', 0, 0).toInt(); |
570 |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
571 |
if (pChannelStrip) |
if (pChannelStrip) |
572 |
pChannelStrip->midiArrived(); |
pChannelStrip->midiArrived(); |
573 |
break; |
break; |
574 |
} |
} |
575 |
#endif |
#endif |
576 |
|
#if CONFIG_LSCP_DEVICE_MIDI |
577 |
|
case LSCP_EVENT_DEVICE_MIDI: { |
578 |
|
const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt(); |
579 |
|
const int iPortID = pEvent->data().section(' ', 1, 1).toInt(); |
580 |
|
DeviceStatusForm* pDeviceStatusForm = |
581 |
|
DeviceStatusForm::getInstance(iDeviceID); |
582 |
|
if (pDeviceStatusForm) |
583 |
|
pDeviceStatusForm->midiArrived(iPortID); |
584 |
|
break; |
585 |
|
} |
586 |
|
#endif |
587 |
default: |
default: |
588 |
appendMessagesColor(tr("Notify event: %1 data: %2") |
appendMessagesColor(tr("Notify event: %1 data: %2") |
589 |
.arg(::lscp_event_to_text(pEvent->event())) |
.arg(::lscp_event_to_text(pEvent->event())) |
592 |
} |
} |
593 |
} |
} |
594 |
|
|
595 |
|
void MainForm::updateViewMidiDeviceStatusMenu() { |
596 |
|
m_ui.viewMidiDeviceStatusMenu->clear(); |
597 |
|
const std::map<int, DeviceStatusForm*> statusForms = |
598 |
|
DeviceStatusForm::getInstances(); |
599 |
|
for ( |
600 |
|
std::map<int, DeviceStatusForm*>::const_iterator iter = statusForms.begin(); |
601 |
|
iter != statusForms.end(); ++iter |
602 |
|
) { |
603 |
|
DeviceStatusForm* pForm = iter->second; |
604 |
|
m_ui.viewMidiDeviceStatusMenu->addAction( |
605 |
|
pForm->visibleAction() |
606 |
|
); |
607 |
|
} |
608 |
|
} |
609 |
|
|
610 |
// Context menu event handler. |
// Context menu event handler. |
611 |
void MainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
void MainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
612 |
{ |
{ |
2650 |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK) |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK) |
2651 |
appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)"); |
appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)"); |
2652 |
|
|
2653 |
|
DeviceStatusForm::onDevicesChanged(); // initialize |
2654 |
|
updateViewMidiDeviceStatusMenu(); |
2655 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT) != LSCP_OK) |
2656 |
|
appendMessagesClient("lscp_client_subscribe(MIDI_INPUT_DEVICE_COUNT)"); |
2657 |
|
|
2658 |
#if CONFIG_LSCP_CHANNEL_MIDI |
#if CONFIG_LSCP_CHANNEL_MIDI |
2659 |
// Subscribe to channel MIDI data notifications... |
// Subscribe to channel MIDI data notifications... |
2660 |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK) |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK) |
2661 |
appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)"); |
appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)"); |
2662 |
#endif |
#endif |
2663 |
|
|
2664 |
|
#if CONFIG_LSCP_DEVICE_MIDI |
2665 |
|
// Subscribe to channel MIDI data notifications... |
2666 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI) != LSCP_OK) |
2667 |
|
appendMessagesClient("lscp_client_subscribe(DEVICE_MIDI)"); |
2668 |
|
#endif |
2669 |
|
|
2670 |
// We may stop scheduling around. |
// We may stop scheduling around. |
2671 |
stopSchedule(); |
stopSchedule(); |
2672 |
|
|
2719 |
closeSession(false); |
closeSession(false); |
2720 |
|
|
2721 |
// Close us as a client... |
// Close us as a client... |
2722 |
|
#if CONFIG_LSCP_DEVICE_MIDI |
2723 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_DEVICE_MIDI); |
2724 |
|
#endif |
2725 |
#if CONFIG_LSCP_CHANNEL_MIDI |
#if CONFIG_LSCP_CHANNEL_MIDI |
2726 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI); |
2727 |
#endif |
#endif |
2728 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_MIDI_INPUT_DEVICE_COUNT); |
2729 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
2730 |
::lscp_client_destroy(m_pClient); |
::lscp_client_destroy(m_pClient); |
2731 |
m_pClient = NULL; |
m_pClient = NULL; |