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 |
|
#include <qcombobox.h> |
30 |
|
|
31 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
32 |
#include "gig.h" |
#include "gig.h" |
50 |
// m_sInstrumentFile = m_sInstrumentName; |
// m_sInstrumentFile = m_sInstrumentName; |
51 |
m_iInstrumentNr = -1; |
m_iInstrumentNr = -1; |
52 |
m_iInstrumentStatus = -1; |
m_iInstrumentStatus = -1; |
53 |
m_sMidiDriver = "Alsa"; // DEPRECATED. |
m_sMidiDriver = "ALSA"; |
54 |
m_iMidiDevice = -1; |
m_iMidiDevice = -1; |
55 |
m_iMidiPort = -1; |
m_iMidiPort = -1; |
56 |
m_iMidiChannel = -1; |
m_iMidiChannel = -1; |
57 |
m_sAudioDriver = "Alsa"; // DEPRECATED. |
m_sAudioDriver = "ALSA"; |
58 |
m_iAudioDevice = -1; |
m_iAudioDevice = -1; |
59 |
m_fVolume = 0.0; |
m_fVolume = 0.0; |
60 |
|
m_bMute = false; |
61 |
|
m_bSolo = false; |
62 |
} |
} |
63 |
|
|
64 |
// Default destructor. |
// Default destructor. |
132 |
m_iChannelID = -1; |
m_iChannelID = -1; |
133 |
} |
} |
134 |
} |
} |
135 |
|
|
136 |
// Return whether we've removed the channel... |
// Return whether we've removed the channel... |
137 |
return (m_iChannelID < 0); |
return (m_iChannelID < 0); |
138 |
} |
} |
169 |
return false; |
return false; |
170 |
if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName) |
if (m_iInstrumentStatus == 100 && m_sEngineName == sEngineName) |
171 |
return true; |
return true; |
172 |
|
|
173 |
if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) { |
if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) { |
174 |
appendMessagesClient("lscp_load_engine"); |
appendMessagesClient("lscp_load_engine"); |
175 |
return false; |
return false; |
222 |
|
|
223 |
appendMessages(QObject::tr("Instrument: \"%1\" (%2).") |
appendMessages(QObject::tr("Instrument: \"%1\" (%2).") |
224 |
.arg(sInstrumentFile).arg(iInstrumentNr)); |
.arg(sInstrumentFile).arg(iInstrumentNr)); |
225 |
|
|
226 |
return setInstrument(sInstrumentFile, iInstrumentNr); |
return setInstrument(sInstrumentFile, iInstrumentNr); |
227 |
} |
} |
228 |
|
|
418 |
} |
} |
419 |
|
|
420 |
|
|
421 |
|
// Sampler channel mute state. |
422 |
|
bool qsamplerChannel::channelMute (void) const |
423 |
|
{ |
424 |
|
return m_bMute; |
425 |
|
} |
426 |
|
|
427 |
|
bool qsamplerChannel::setChannelMute ( bool bMute ) |
428 |
|
{ |
429 |
|
if (client() == NULL || m_iChannelID < 0) |
430 |
|
return false; |
431 |
|
if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute))) |
432 |
|
return true; |
433 |
|
|
434 |
|
#ifdef CONFIG_MUTE_SOLO |
435 |
|
if (::lscp_set_channel_mute(client(), m_iChannelID, bMute) != LSCP_OK) { |
436 |
|
appendMessagesClient("lscp_set_channel_mute"); |
437 |
|
return false; |
438 |
|
} |
439 |
|
appendMessages(QObject::tr("Mute: %1.").arg((int) bMute)); |
440 |
|
m_bMute = bMute; |
441 |
|
return true; |
442 |
|
#else |
443 |
|
return false; |
444 |
|
#endif |
445 |
|
} |
446 |
|
|
447 |
|
|
448 |
|
// Sampler channel solo state. |
449 |
|
bool qsamplerChannel::channelSolo (void) const |
450 |
|
{ |
451 |
|
return m_bSolo; |
452 |
|
} |
453 |
|
|
454 |
|
bool qsamplerChannel::setChannelSolo ( bool bSolo ) |
455 |
|
{ |
456 |
|
if (client() == NULL || m_iChannelID < 0) |
457 |
|
return false; |
458 |
|
if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo))) |
459 |
|
return true; |
460 |
|
|
461 |
|
#ifdef CONFIG_MUTE_SOLO |
462 |
|
if (::lscp_set_channel_solo(client(), m_iChannelID, bSolo) != LSCP_OK) { |
463 |
|
appendMessagesClient("lscp_set_channel_solo"); |
464 |
|
return false; |
465 |
|
} |
466 |
|
appendMessages(QObject::tr("Solo: %1.").arg((int) bSolo)); |
467 |
|
m_bSolo = bSolo; |
468 |
|
return true; |
469 |
|
#else |
470 |
|
return false; |
471 |
|
#endif |
472 |
|
} |
473 |
|
|
474 |
|
|
475 |
|
// Audio routing accessors. |
476 |
|
int qsamplerChannel::audioChannel ( int iAudioOut ) const |
477 |
|
{ |
478 |
|
return m_audioRouting[iAudioOut]; |
479 |
|
} |
480 |
|
|
481 |
|
bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn ) |
482 |
|
{ |
483 |
|
if (client() == NULL || m_iChannelID < 0) |
484 |
|
return false; |
485 |
|
if (m_iInstrumentStatus == 100 && |
486 |
|
m_audioRouting[iAudioOut] == iAudioIn) |
487 |
|
return true; |
488 |
|
|
489 |
|
if (::lscp_set_channel_audio_channel(client(), |
490 |
|
m_iChannelID, iAudioOut, iAudioIn) != LSCP_OK) { |
491 |
|
appendMessagesClient("lscp_set_channel_audio_channel"); |
492 |
|
return false; |
493 |
|
} |
494 |
|
|
495 |
|
appendMessages(QObject::tr("Audio Channel: %1 -> %2.") |
496 |
|
.arg(iAudioOut).arg(iAudioIn)); |
497 |
|
|
498 |
|
m_audioRouting[iAudioOut] = iAudioIn; |
499 |
|
return true; |
500 |
|
} |
501 |
|
|
502 |
|
// The audio routing map itself. |
503 |
|
const qsamplerChannelRoutingMap& qsamplerChannel::audioRouting (void) const |
504 |
|
{ |
505 |
|
return m_audioRouting; |
506 |
|
} |
507 |
|
|
508 |
|
|
509 |
// Istrument name remapper. |
// Istrument name remapper. |
510 |
void qsamplerChannel::updateInstrumentName (void) |
void qsamplerChannel::updateInstrumentName (void) |
511 |
{ |
{ |
554 |
m_iMidiChannel = pChannelInfo->midi_channel; |
m_iMidiChannel = pChannelInfo->midi_channel; |
555 |
m_iAudioDevice = pChannelInfo->audio_device; |
m_iAudioDevice = pChannelInfo->audio_device; |
556 |
m_fVolume = pChannelInfo->volume; |
m_fVolume = pChannelInfo->volume; |
557 |
|
#ifdef CONFIG_MUTE_SOLO |
558 |
|
m_bMute = pChannelInfo->mute; |
559 |
|
m_bSolo = pChannelInfo->solo; |
560 |
|
#endif |
561 |
// Some sanity checks. |
// Some sanity checks. |
562 |
if (m_sEngineName == "NONE" || m_sEngineName.isEmpty()) |
if (m_sEngineName == "NONE" || m_sEngineName.isEmpty()) |
563 |
m_sEngineName = QString::null; |
m_sEngineName = QString::null; |
565 |
m_sInstrumentFile = QString::null; |
m_sInstrumentFile = QString::null; |
566 |
m_sInstrumentName = QString::null; |
m_sInstrumentName = QString::null; |
567 |
} |
} |
568 |
|
|
569 |
// FIXME: DEPRECATED... |
// Time for device info grabbing... |
570 |
lscp_device_info_t *pDeviceInfo; |
lscp_device_info_t *pDeviceInfo; |
571 |
const QString sNone = QObject::tr("(none)"); |
const QString sNone = QObject::tr("(none)"); |
572 |
// Audio device driver type. |
// Audio device driver type. |
586 |
m_sMidiDriver = pDeviceInfo->driver; |
m_sMidiDriver = pDeviceInfo->driver; |
587 |
} |
} |
588 |
|
|
589 |
|
// Set the audio routing map. |
590 |
|
m_audioRouting.clear(); |
591 |
|
char **ppszRouting = pChannelInfo->audio_routing; |
592 |
|
for (int i = 0; ppszRouting && ppszRouting[i]; i++) { |
593 |
|
m_audioRouting[i] = ::atoi(ppszRouting[i]); |
594 |
|
} |
595 |
|
|
596 |
return true; |
return true; |
597 |
} |
} |
598 |
|
|
620 |
bool bResult = false; |
bool bResult = false; |
621 |
|
|
622 |
appendMessages(QObject::tr("setup...")); |
appendMessages(QObject::tr("setup...")); |
623 |
|
|
624 |
qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent); |
qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent); |
625 |
if (pChannelForm) { |
if (pChannelForm) { |
626 |
pChannelForm->setup(this); |
pChannelForm->setup(this); |
702 |
if (isInstrumentFile(sInstrumentFile)) { |
if (isInstrumentFile(sInstrumentFile)) { |
703 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
704 |
if (bInstrumentNames) { |
if (bInstrumentNames) { |
705 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1()); |
706 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
707 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
708 |
while (pInstrument) { |
while (pInstrument) { |
733 |
sInstrumentName = QFileInfo(sInstrumentFile).fileName(); |
sInstrumentName = QFileInfo(sInstrumentFile).fileName(); |
734 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
735 |
if (bInstrumentNames) { |
if (bInstrumentNames) { |
736 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1()); |
737 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
738 |
int iIndex = 0; |
int iIndex = 0; |
739 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
769 |
return QObject::tr("(No instrument)"); |
return QObject::tr("(No instrument)"); |
770 |
} |
} |
771 |
|
|
772 |
|
QString qsamplerChannel::loadingInstrument (void) { |
773 |
|
return QObject::tr("(Loading instrument...)"); |
774 |
|
} |
775 |
|
|
776 |
|
|
777 |
|
|
778 |
|
//------------------------------------------------------------------------- |
779 |
|
// qsamplerChannelRoutingTable - Channel routing table. |
780 |
|
// |
781 |
|
|
782 |
|
// Constructor. |
783 |
|
qsamplerChannelRoutingTable::qsamplerChannelRoutingTable ( |
784 |
|
QWidget *pParent, const char *pszName ) |
785 |
|
: QTable(pParent, pszName) |
786 |
|
{ |
787 |
|
// Set fixed number of columns. |
788 |
|
QTable::setNumCols(2); |
789 |
|
QTable::setShowGrid(false); |
790 |
|
QTable::setSorting(false); |
791 |
|
QTable::setFocusStyle(QTable::FollowStyle); |
792 |
|
QTable::setSelectionMode(QTable::NoSelection); |
793 |
|
// No vertical header. |
794 |
|
QTable::verticalHeader()->hide(); |
795 |
|
QTable::setLeftMargin(0); |
796 |
|
// Initialize the fixed table column headings. |
797 |
|
QHeader *pHeader = QTable::horizontalHeader(); |
798 |
|
pHeader->setLabel(0, tr("Sampler Channel")); |
799 |
|
pHeader->setLabel(1, tr("Device Channel")); |
800 |
|
// Set read-onlyness of each column |
801 |
|
QTable::setColumnReadOnly(0, true); |
802 |
|
// QTable::setColumnReadOnly(1, false); -- of course not. |
803 |
|
QTable::setColumnStretchable(1, true); |
804 |
|
} |
805 |
|
|
806 |
|
// Default destructor. |
807 |
|
qsamplerChannelRoutingTable::~qsamplerChannelRoutingTable (void) |
808 |
|
{ |
809 |
|
} |
810 |
|
|
811 |
|
|
812 |
|
// Routing map table renderer. |
813 |
|
void qsamplerChannelRoutingTable::refresh ( qsamplerDevice *pDevice, |
814 |
|
const qsamplerChannelRoutingMap& routing ) |
815 |
|
{ |
816 |
|
if (pDevice == NULL) |
817 |
|
return; |
818 |
|
|
819 |
|
// Always (re)start it empty. |
820 |
|
QTable::setUpdatesEnabled(false); |
821 |
|
QTable::setNumRows(0); |
822 |
|
|
823 |
|
// The common device port item list. |
824 |
|
QStringList opts; |
825 |
|
qsamplerDevicePortList& ports = pDevice->ports(); |
826 |
|
qsamplerDevicePort *pPort; |
827 |
|
for (pPort = ports.first(); pPort; pPort = ports.next()) { |
828 |
|
opts.append(pDevice->deviceTypeName() |
829 |
|
+ ' ' + pDevice->driverName() |
830 |
|
+ ' ' + pPort->portName()); |
831 |
|
} |
832 |
|
|
833 |
|
// Those items shall have a proper pixmap... |
834 |
|
QPixmap pmChannel = QPixmap::fromMimeSource("qsamplerChannel.png"); |
835 |
|
QPixmap pmDevice; |
836 |
|
switch (pDevice->deviceType()) { |
837 |
|
case qsamplerDevice::Audio: |
838 |
|
pmDevice = QPixmap::fromMimeSource("audio2.png"); |
839 |
|
break; |
840 |
|
case qsamplerDevice::Midi: |
841 |
|
pmDevice = QPixmap::fromMimeSource("midi2.png"); |
842 |
|
break; |
843 |
|
case qsamplerDevice::None: |
844 |
|
break; |
845 |
|
} |
846 |
|
|
847 |
|
// Fill the routing table... |
848 |
|
QTable::insertRows(0, routing.count()); |
849 |
|
int iRow = 0; |
850 |
|
qsamplerChannelRoutingMap::ConstIterator iter; |
851 |
|
for (iter = routing.begin(); iter != routing.end(); ++iter) { |
852 |
|
QTable::setPixmap(iRow, 0, pmChannel); |
853 |
|
QTable::setText(iRow, 0, pDevice->deviceTypeName() |
854 |
|
+ ' ' + QString::number(iter.key())); |
855 |
|
qsamplerChannelRoutingComboBox *pComboItem = |
856 |
|
new qsamplerChannelRoutingComboBox(this, opts, pmDevice); |
857 |
|
pComboItem->setCurrentItem(iter.data()); |
858 |
|
QTable::setItem(iRow, 1, pComboItem); |
859 |
|
++iRow; |
860 |
|
} |
861 |
|
|
862 |
|
// Adjust optimal column widths. |
863 |
|
QTable::adjustColumn(0); |
864 |
|
QTable::adjustColumn(1); |
865 |
|
|
866 |
|
QTable::setUpdatesEnabled(true); |
867 |
|
QTable::updateContents(); |
868 |
|
} |
869 |
|
|
870 |
|
|
871 |
|
//------------------------------------------------------------------------- |
872 |
|
// qsamplerChannelRoutingComboBox - Custom combo box for routing table. |
873 |
|
// |
874 |
|
|
875 |
|
// Constructor. |
876 |
|
qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox ( |
877 |
|
QTable *pTable, const QStringList& list, const QPixmap& pixmap ) |
878 |
|
: QTableItem(pTable, QTableItem::WhenCurrent, QString::null, pixmap), |
879 |
|
m_list(list) |
880 |
|
{ |
881 |
|
m_iCurrentItem = 0; |
882 |
|
} |
883 |
|
|
884 |
|
// Public accessors. |
885 |
|
void qsamplerChannelRoutingComboBox::setCurrentItem ( int iCurrentItem ) |
886 |
|
{ |
887 |
|
m_iCurrentItem = iCurrentItem; |
888 |
|
|
889 |
|
QTableItem::setText(m_list[iCurrentItem]); |
890 |
|
} |
891 |
|
|
892 |
|
int qsamplerChannelRoutingComboBox::currentItem (void) const |
893 |
|
{ |
894 |
|
return m_iCurrentItem; |
895 |
|
} |
896 |
|
|
897 |
|
// Virtual implemetations. |
898 |
|
QWidget *qsamplerChannelRoutingComboBox::createEditor (void) const |
899 |
|
{ |
900 |
|
QComboBox *pComboBox = new QComboBox(QTableItem::table()->viewport()); |
901 |
|
QObject::connect(pComboBox, SIGNAL(activated(int)), |
902 |
|
QTableItem::table(), SLOT(doValueChanged())); |
903 |
|
for (QStringList::ConstIterator iter = m_list.begin(); |
904 |
|
iter != m_list.end(); iter++) { |
905 |
|
pComboBox->insertItem(QTableItem::pixmap(), *iter); |
906 |
|
} |
907 |
|
pComboBox->setCurrentItem(m_iCurrentItem); |
908 |
|
return pComboBox; |
909 |
|
} |
910 |
|
|
911 |
|
void qsamplerChannelRoutingComboBox::setContentFromEditor ( QWidget *pWidget ) |
912 |
|
{ |
913 |
|
if (pWidget->inherits("QComboBox")) { |
914 |
|
QComboBox *pComboBox = (QComboBox *) pWidget; |
915 |
|
m_iCurrentItem = pComboBox->currentItem(); |
916 |
|
QTableItem::setText(pComboBox->currentText()); |
917 |
|
} |
918 |
|
else QTableItem::setContentFromEditor(pWidget); |
919 |
|
} |
920 |
|
|
921 |
|
|
922 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |