19 |
|
|
20 |
*****************************************************************************/ |
*****************************************************************************/ |
21 |
|
|
22 |
|
#include "qsamplerAbout.h" |
23 |
#include "qsamplerChannel.h" |
#include "qsamplerChannel.h" |
24 |
|
|
25 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
26 |
#include "qsamplerChannelForm.h" |
#include "qsamplerChannelForm.h" |
27 |
|
|
|
#include "config.h" |
|
|
|
|
28 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
29 |
|
|
30 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
471 |
} |
} |
472 |
|
|
473 |
|
|
474 |
|
// Audio routing accessors. |
475 |
|
int qsamplerChannel::audioChannel ( int iAudioOut ) const |
476 |
|
{ |
477 |
|
return m_audioRouting[iAudioOut]; |
478 |
|
} |
479 |
|
|
480 |
|
bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn ) |
481 |
|
{ |
482 |
|
if (client() == NULL || m_iChannelID < 0) |
483 |
|
return false; |
484 |
|
if (m_iInstrumentStatus == 100 && |
485 |
|
m_audioRouting[iAudioOut] == iAudioIn) |
486 |
|
return true; |
487 |
|
|
488 |
|
if (::lscp_set_channel_audio_channel(client(), |
489 |
|
m_iChannelID, iAudioOut, iAudioIn) != LSCP_OK) { |
490 |
|
appendMessagesClient("lscp_set_channel_audio_channel"); |
491 |
|
return false; |
492 |
|
} |
493 |
|
|
494 |
|
appendMessages(QObject::tr("Audio Channel: %1 -> %2.") |
495 |
|
.arg(iAudioOut).arg(iAudioIn)); |
496 |
|
|
497 |
|
m_audioRouting[iAudioOut] = iAudioIn; |
498 |
|
return true; |
499 |
|
} |
500 |
|
|
501 |
|
// The audio routing map itself. |
502 |
|
const qsamplerChannelRoutingMap& qsamplerChannel::audioRouting (void) const |
503 |
|
{ |
504 |
|
return m_audioRouting; |
505 |
|
} |
506 |
|
|
507 |
|
|
508 |
// Istrument name remapper. |
// Istrument name remapper. |
509 |
void qsamplerChannel::updateInstrumentName (void) |
void qsamplerChannel::updateInstrumentName (void) |
510 |
{ |
{ |
585 |
m_sMidiDriver = pDeviceInfo->driver; |
m_sMidiDriver = pDeviceInfo->driver; |
586 |
} |
} |
587 |
|
|
588 |
|
// Set the audio routing map. |
589 |
|
m_audioRouting.clear(); |
590 |
|
char **ppszRouting = pChannelInfo->audio_routing; |
591 |
|
for (int i = 0; ppszRouting && ppszRouting[i]; i++) { |
592 |
|
m_audioRouting[i] = ::atoi(ppszRouting[i]); |
593 |
|
} |
594 |
|
|
595 |
return true; |
return true; |
596 |
} |
} |
597 |
|
|
773 |
} |
} |
774 |
|
|
775 |
|
|
776 |
|
|
777 |
|
//------------------------------------------------------------------------- |
778 |
|
// qsamplerChannelRoutingTable - Channel routing table. |
779 |
|
// |
780 |
|
|
781 |
|
// Constructor. |
782 |
|
qsamplerChannelRoutingTable::qsamplerChannelRoutingTable ( |
783 |
|
QWidget *pParent, const char *pszName ) |
784 |
|
: QTable(pParent, pszName) |
785 |
|
{ |
786 |
|
// Set fixed number of columns. |
787 |
|
QTable::setNumCols(2); |
788 |
|
QTable::setShowGrid(false); |
789 |
|
QTable::setSorting(false); |
790 |
|
QTable::setFocusStyle(QTable::FollowStyle); |
791 |
|
QTable::setSelectionMode(QTable::SingleRow); |
792 |
|
// No vertical header. |
793 |
|
QTable::verticalHeader()->hide(); |
794 |
|
QTable::setLeftMargin(0); |
795 |
|
// Initialize the fixed table column headings. |
796 |
|
QHeader *pHeader = QTable::horizontalHeader(); |
797 |
|
pHeader->setLabel(0, tr("Sampler Channel")); |
798 |
|
pHeader->setLabel(1, tr("Device Channel")); |
799 |
|
// Set read-onlyness of each column |
800 |
|
QTable::setColumnReadOnly(0, true); |
801 |
|
// QTable::setColumnReadOnly(1, false); -- of course not. |
802 |
|
QTable::setColumnStretchable(1, true); |
803 |
|
} |
804 |
|
|
805 |
|
// Default destructor. |
806 |
|
qsamplerChannelRoutingTable::~qsamplerChannelRoutingTable (void) |
807 |
|
{ |
808 |
|
} |
809 |
|
|
810 |
|
|
811 |
|
// Routing map table renderer. |
812 |
|
void qsamplerChannelRoutingTable::refresh ( qsamplerDevice *pDevice, |
813 |
|
const qsamplerChannelRoutingMap& routing ) |
814 |
|
{ |
815 |
|
if (pDevice == NULL) |
816 |
|
return; |
817 |
|
|
818 |
|
// Always (re)start it empty. |
819 |
|
QTable::setUpdatesEnabled(false); |
820 |
|
QTable::setNumRows(0); |
821 |
|
|
822 |
|
// The common device port item list. |
823 |
|
QStringList opts; |
824 |
|
qsamplerDevicePortList& ports = pDevice->ports(); |
825 |
|
qsamplerDevicePort *pPort; |
826 |
|
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
827 |
|
opts.append(pDevice->deviceTypeName() |
828 |
|
+ ' ' + pDevice->driverName() |
829 |
|
+ ' ' + pPort->portName()); |
830 |
|
} |
831 |
|
|
832 |
|
// Those items shall have a proper pixmap... |
833 |
|
QPixmap pmDevice; |
834 |
|
switch (pDevice->deviceType()) { |
835 |
|
case qsamplerDevice::Audio: |
836 |
|
pmDevice = QPixmap::fromMimeSource("audio2.png"); |
837 |
|
break; |
838 |
|
case qsamplerDevice::Midi: |
839 |
|
pmDevice = QPixmap::fromMimeSource("midi2.png"); |
840 |
|
break; |
841 |
|
case qsamplerDevice::None: |
842 |
|
break; |
843 |
|
} |
844 |
|
|
845 |
|
// Fill the routing table... |
846 |
|
QTable::insertRows(0, routing.count()); |
847 |
|
int iRow = 0; |
848 |
|
qsamplerChannelRoutingMap::ConstIterator iter; |
849 |
|
for (iter = routing.begin(); iter != routing.end(); ++iter) { |
850 |
|
QTable::setPixmap(iRow, 0, pmDevice); |
851 |
|
QTable::setText(iRow, 0, pDevice->deviceTypeName() |
852 |
|
+ ' ' + QString::number(iter.key())); |
853 |
|
QComboTableItem *pComboItem = new QComboTableItem(this, opts); |
854 |
|
pComboItem->setCurrentItem(iter.data()); |
855 |
|
QTable::setItem(iRow, 1, pComboItem); |
856 |
|
++iRow; |
857 |
|
} |
858 |
|
|
859 |
|
// Adjust optimal column widths. |
860 |
|
QTable::adjustColumn(0); |
861 |
|
QTable::adjustColumn(1); |
862 |
|
|
863 |
|
QTable::setUpdatesEnabled(true); |
864 |
|
QTable::updateContents(); |
865 |
|
} |
866 |
|
|
867 |
|
|
868 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |