/[svn]/qsampler/trunk/src/qsamplerChannel.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerChannel.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 736 by schoenebeck, Tue Aug 16 10:19:25 2005 UTC revision 758 by capela, Sun Aug 28 00:31:34 2005 UTC
# Line 19  Line 19 
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
# Line 57  qsamplerChannel::qsamplerChannel ( qsamp Line 56  qsamplerChannel::qsamplerChannel ( qsamp
56          m_sAudioDriver      = "ALSA";          m_sAudioDriver      = "ALSA";
57          m_iAudioDevice      = -1;          m_iAudioDevice      = -1;
58          m_fVolume           = 0.0;          m_fVolume           = 0.0;
59            m_bMute             = false;
60            m_bSolo             = false;
61  }  }
62    
63  // Default destructor.  // Default destructor.
# Line 417  bool qsamplerChannel::setVolume ( float Line 417  bool qsamplerChannel::setVolume ( float
417  }  }
418    
419    
420    // Sampler channel mute state.
421    bool qsamplerChannel::channelMute (void) const
422    {
423            return m_bMute;
424    }
425    
426    bool qsamplerChannel::setChannelMute ( bool bMute )
427    {
428            if (client() == NULL || m_iChannelID < 0)
429                    return false;
430            if (m_iInstrumentStatus == 100 && ((m_bMute && bMute) || (!m_bMute && !bMute)))
431                    return true;
432    
433    #ifdef CONFIG_MUTE_SOLO
434            if (::lscp_set_channel_mute(client(), m_iChannelID, bMute) != LSCP_OK) {
435                    appendMessagesClient("lscp_set_channel_mute");
436                    return false;
437            }
438            appendMessages(QObject::tr("Mute: %1.").arg((int) bMute));
439            m_bMute = bMute;
440            return true;
441    #else
442            return false;
443    #endif
444    }
445    
446    
447    // Sampler channel solo state.
448    bool qsamplerChannel::channelSolo (void) const
449    {
450            return m_bSolo;
451    }
452    
453    bool qsamplerChannel::setChannelSolo ( bool bSolo )
454    {
455            if (client() == NULL || m_iChannelID < 0)
456                    return false;
457            if (m_iInstrumentStatus == 100 && ((m_bSolo && bSolo) || (!m_bSolo && !bSolo)))
458                    return true;
459    
460    #ifdef CONFIG_MUTE_SOLO
461            if (::lscp_set_channel_solo(client(), m_iChannelID, bSolo) != LSCP_OK) {
462                    appendMessagesClient("lscp_set_channel_solo");
463                    return false;
464            }
465            appendMessages(QObject::tr("Solo: %1.").arg((int) bSolo));
466            m_bSolo = bSolo;
467            return true;
468    #else
469            return false;
470    #endif
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  {  {
# Line 465  bool qsamplerChannel::updateChannelInfo Line 553  bool qsamplerChannel::updateChannelInfo
553          m_iMidiChannel      = pChannelInfo->midi_channel;          m_iMidiChannel      = pChannelInfo->midi_channel;
554          m_iAudioDevice      = pChannelInfo->audio_device;          m_iAudioDevice      = pChannelInfo->audio_device;
555          m_fVolume           = pChannelInfo->volume;          m_fVolume           = pChannelInfo->volume;
556    #ifdef CONFIG_MUTE_SOLO
557            m_bMute             = pChannelInfo->mute;
558            m_bSolo             = pChannelInfo->solo;
559    #endif
560          // Some sanity checks.          // Some sanity checks.
561          if (m_sEngineName == "NONE" || m_sEngineName.isEmpty())          if (m_sEngineName == "NONE" || m_sEngineName.isEmpty())
562                  m_sEngineName = QString::null;                  m_sEngineName = QString::null;
# Line 493  bool qsamplerChannel::updateChannelInfo Line 585  bool qsamplerChannel::updateChannelInfo
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    
# Line 602  QStringList qsamplerChannel::getInstrume Line 701  QStringList qsamplerChannel::getInstrume
701          if (isInstrumentFile(sInstrumentFile)) {          if (isInstrumentFile(sInstrumentFile)) {
702  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
703                  if (bInstrumentNames) {                  if (bInstrumentNames) {
704                          RIFF::File *pRiff = new RIFF::File((const RIFF::String&) sInstrumentFile);                          RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1());
705                          gig::File  *pGig  = new gig::File(pRiff);                          gig::File  *pGig  = new gig::File(pRiff);
706                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();
707                          while (pInstrument) {                          while (pInstrument) {
# Line 633  QString qsamplerChannel::getInstrumentNa Line 732  QString qsamplerChannel::getInstrumentNa
732                  sInstrumentName = QFileInfo(sInstrumentFile).fileName();                  sInstrumentName = QFileInfo(sInstrumentFile).fileName();
733  #ifdef CONFIG_LIBGIG  #ifdef CONFIG_LIBGIG
734                  if (bInstrumentNames) {                  if (bInstrumentNames) {
735                          RIFF::File *pRiff = new RIFF::File((const RIFF::String&) sInstrumentFile);                          RIFF::File *pRiff = new RIFF::File(sInstrumentFile.latin1());
736                          gig::File  *pGig  = new gig::File(pRiff);                          gig::File  *pGig  = new gig::File(pRiff);
737                          int iIndex = 0;                          int iIndex = 0;
738                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();                          gig::Instrument *pInstrument = pGig->GetFirstInstrument();
# Line 674  QString qsamplerChannel::loadingInstrume Line 773  QString qsamplerChannel::loadingInstrume
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

Legend:
Removed from v.736  
changed lines
  Added in v.758

  ViewVC Help
Powered by ViewVC