/[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 1460 by capela, Fri Oct 12 22:50:47 2007 UTC revision 1461 by schoenebeck, Sun Oct 28 23:30:36 2007 UTC
# Line 35  Line 35 
35    
36  #define QSAMPLER_INSTRUMENT_MAX 100  #define QSAMPLER_INSTRUMENT_MAX 100
37    
38    using namespace QSampler;
39    
40  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
41  // qsamplerChannel - Sampler channel structure.  // qsamplerChannel - Sampler channel structure.
# Line 71  qsamplerChannel::~qsamplerChannel (void) Line 72  qsamplerChannel::~qsamplerChannel (void)
72  // Create a new sampler channel, if not already.  // Create a new sampler channel, if not already.
73  bool qsamplerChannel::addChannel (void)  bool qsamplerChannel::addChannel (void)
74  {  {
75          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm* pMainForm = MainForm::getInstance();
76          if (pMainForm == NULL)          if (pMainForm == NULL)
77                  return false;                  return false;
78          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 96  bool qsamplerChannel::addChannel (void) Line 97  bool qsamplerChannel::addChannel (void)
97  // Remove sampler channel.  // Remove sampler channel.
98  bool qsamplerChannel::removeChannel (void)  bool qsamplerChannel::removeChannel (void)
99  {  {
100          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
101          if (pMainForm == NULL)          if (pMainForm == NULL)
102                  return false;                  return false;
103          if (pMainForm->client() == NULL)          if (pMainForm->client() == NULL)
# Line 146  const QString& qsamplerChannel::engineNa Line 147  const QString& qsamplerChannel::engineNa
147    
148  bool qsamplerChannel::loadEngine ( const QString& sEngineName )  bool qsamplerChannel::loadEngine ( const QString& sEngineName )
149  {  {
150          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
151          if (pMainForm == NULL)          if (pMainForm == NULL)
152                  return false;                  return false;
153          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 193  int qsamplerChannel::instrumentStatus (v Line 194  int qsamplerChannel::instrumentStatus (v
194  // Instrument file loader.  // Instrument file loader.
195  bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )  bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr )
196  {  {
197          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
198          if (pMainForm == NULL)          if (pMainForm == NULL)
199                  return false;                  return false;
200          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 245  const QString& qsamplerChannel::midiDriv Line 246  const QString& qsamplerChannel::midiDriv
246    
247  bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver )  bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver )
248  {  {
249          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
250          if (pMainForm == NULL)          if (pMainForm == NULL)
251                  return false;                  return false;
252          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 273  int qsamplerChannel::midiDevice (void) c Line 274  int qsamplerChannel::midiDevice (void) c
274    
275  bool qsamplerChannel::setMidiDevice ( int iMidiDevice )  bool qsamplerChannel::setMidiDevice ( int iMidiDevice )
276  {  {
277          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
278          if (pMainForm == NULL)          if (pMainForm == NULL)
279                  return false;                  return false;
280          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 301  int qsamplerChannel::midiPort (void) con Line 302  int qsamplerChannel::midiPort (void) con
302    
303  bool qsamplerChannel::setMidiPort ( int iMidiPort )  bool qsamplerChannel::setMidiPort ( int iMidiPort )
304  {  {
305          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
306          if (pMainForm == NULL)          if (pMainForm == NULL)
307                  return false;                  return false;
308          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 329  int qsamplerChannel::midiChannel (void) Line 330  int qsamplerChannel::midiChannel (void)
330    
331  bool qsamplerChannel::setMidiChannel ( int iMidiChannel )  bool qsamplerChannel::setMidiChannel ( int iMidiChannel )
332  {  {
333          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
334          if (pMainForm == NULL)          if (pMainForm == NULL)
335                  return false;                  return false;
336          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 357  int qsamplerChannel::midiMap (void) cons Line 358  int qsamplerChannel::midiMap (void) cons
358    
359  bool qsamplerChannel::setMidiMap ( int iMidiMap )  bool qsamplerChannel::setMidiMap ( int iMidiMap )
360  {  {
361          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
362          if (pMainForm == NULL)          if (pMainForm == NULL)
363                  return false;                  return false;
364          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 385  int qsamplerChannel::audioDevice (void) Line 386  int qsamplerChannel::audioDevice (void)
386    
387  bool qsamplerChannel::setAudioDevice ( int iAudioDevice )  bool qsamplerChannel::setAudioDevice ( int iAudioDevice )
388  {  {
389          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
390          if (pMainForm == NULL)          if (pMainForm == NULL)
391                  return false;                  return false;
392          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 413  const QString& qsamplerChannel::audioDri Line 414  const QString& qsamplerChannel::audioDri
414    
415  bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver )  bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver )
416  {  {
417          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
418          if (pMainForm == NULL)          if (pMainForm == NULL)
419                  return false;                  return false;
420          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 441  float qsamplerChannel::volume (void) con Line 442  float qsamplerChannel::volume (void) con
442    
443  bool qsamplerChannel::setVolume ( float fVolume )  bool qsamplerChannel::setVolume ( float fVolume )
444  {  {
445          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
446          if (pMainForm == NULL)          if (pMainForm == NULL)
447                  return false;                  return false;
448          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 469  bool qsamplerChannel::channelMute (void) Line 470  bool qsamplerChannel::channelMute (void)
470    
471  bool qsamplerChannel::setChannelMute ( bool bMute )  bool qsamplerChannel::setChannelMute ( bool bMute )
472  {  {
473          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
474          if (pMainForm == NULL)          if (pMainForm == NULL)
475                  return false;                  return false;
476          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 499  bool qsamplerChannel::channelSolo (void) Line 500  bool qsamplerChannel::channelSolo (void)
500    
501  bool qsamplerChannel::setChannelSolo ( bool bSolo )  bool qsamplerChannel::setChannelSolo ( bool bSolo )
502  {  {
503          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
504          if (pMainForm == NULL)          if (pMainForm == NULL)
505                  return false;                  return false;
506          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 529  int qsamplerChannel::audioChannel ( int Line 530  int qsamplerChannel::audioChannel ( int
530    
531  bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn )  bool qsamplerChannel::setAudioChannel ( int iAudioOut, int iAudioIn )
532  {  {
533          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
534          if (pMainForm == NULL)          if (pMainForm == NULL)
535                  return false;                  return false;
536          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 571  void qsamplerChannel::updateInstrumentNa Line 572  void qsamplerChannel::updateInstrumentNa
572  // Update whole channel info state.  // Update whole channel info state.
573  bool qsamplerChannel::updateChannelInfo (void)  bool qsamplerChannel::updateChannelInfo (void)
574  {  {
575          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
576          if (pMainForm == NULL)          if (pMainForm == NULL)
577                  return false;                  return false;
578          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 665  bool qsamplerChannel::updateChannelInfo Line 666  bool qsamplerChannel::updateChannelInfo
666  // Reset channel method.  // Reset channel method.
667  bool qsamplerChannel::channelReset (void)  bool qsamplerChannel::channelReset (void)
668  {  {
669          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
670          if (pMainForm == NULL)          if (pMainForm == NULL)
671                  return false;                  return false;
672          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 687  bool qsamplerChannel::editChannel (void) Line 688  bool qsamplerChannel::editChannel (void)
688  {  {
689  #ifdef CONFIG_EDIT_INSTRUMENT  #ifdef CONFIG_EDIT_INSTRUMENT
690    
691          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
692          if (pMainForm == NULL)          if (pMainForm == NULL)
693                  return false;                  return false;
694          if (pMainForm->client() == NULL || m_iChannelID < 0)          if (pMainForm->client() == NULL || m_iChannelID < 0)
# Line 728  bool qsamplerChannel::editChannel (void) Line 729  bool qsamplerChannel::editChannel (void)
729  // Channel setup dialog form.  // Channel setup dialog form.
730  bool qsamplerChannel::channelSetup ( QWidget *pParent )  bool qsamplerChannel::channelSetup ( QWidget *pParent )
731  {  {
732          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
733          if (pMainForm == NULL)          if (pMainForm == NULL)
734                  return false;                  return false;
735    
# Line 736  bool qsamplerChannel::channelSetup ( QWi Line 737  bool qsamplerChannel::channelSetup ( QWi
737    
738          appendMessages(QObject::tr("setup..."));          appendMessages(QObject::tr("setup..."));
739    
740          qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent);          ChannelForm *pChannelForm = new ChannelForm(pParent);
741          if (pChannelForm) {          if (pChannelForm) {
742                  pChannelForm->setup(this);                  pChannelForm->setup(this);
743                  bResult = pChannelForm->exec();                  bResult = pChannelForm->exec();
# Line 750  bool qsamplerChannel::channelSetup ( QWi Line 751  bool qsamplerChannel::channelSetup ( QWi
751  // Redirected messages output methods.  // Redirected messages output methods.
752  void qsamplerChannel::appendMessages( const QString& s ) const  void qsamplerChannel::appendMessages( const QString& s ) const
753  {  {
754          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
755          if (pMainForm)          if (pMainForm)
756                  pMainForm->appendMessages(channelName() + ' ' + s);                  pMainForm->appendMessages(channelName() + ' ' + s);
757  }  }
# Line 758  void qsamplerChannel::appendMessages( co Line 759  void qsamplerChannel::appendMessages( co
759  void qsamplerChannel::appendMessagesColor( const QString& s,  void qsamplerChannel::appendMessagesColor( const QString& s,
760          const QString& c ) const          const QString& c ) const
761  {  {
762          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
763          if (pMainForm)          if (pMainForm)
764                  pMainForm->appendMessagesColor(channelName() + ' ' + s, c);                  pMainForm->appendMessagesColor(channelName() + ' ' + s, c);
765  }  }
766    
767  void qsamplerChannel::appendMessagesText( const QString& s ) const  void qsamplerChannel::appendMessagesText( const QString& s ) const
768  {  {
769          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
770          if (pMainForm)          if (pMainForm)
771                  pMainForm->appendMessagesText(channelName() + ' ' + s);                  pMainForm->appendMessagesText(channelName() + ' ' + s);
772  }  }
773    
774  void qsamplerChannel::appendMessagesError( const QString& s ) const  void qsamplerChannel::appendMessagesError( const QString& s ) const
775  {  {
776          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
777          if (pMainForm)          if (pMainForm)
778                  pMainForm->appendMessagesError(channelName() + "\n\n" + s);                  pMainForm->appendMessagesError(channelName() + "\n\n" + s);
779  }  }
780    
781  void qsamplerChannel::appendMessagesClient( const QString& s ) const  void qsamplerChannel::appendMessagesClient( const QString& s ) const
782  {  {
783          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
784          if (pMainForm)          if (pMainForm)
785                  pMainForm->appendMessagesClient(channelName() + ' ' + s);                  pMainForm->appendMessagesClient(channelName() + ' ' + s);
786  }  }
# Line 788  void qsamplerChannel::appendMessagesClie Line 789  void qsamplerChannel::appendMessagesClie
789  // Context menu event handler.  // Context menu event handler.
790  void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent )  void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent )
791  {  {
792          qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance();          MainForm *pMainForm = MainForm::getInstance();
793          if (pMainForm)          if (pMainForm)
794                  pMainForm->contextMenuEvent(pEvent);                  pMainForm->contextMenuEvent(pEvent);
795  }  }
# Line 899  QString qsamplerChannel::loadingInstrume Line 900  QString qsamplerChannel::loadingInstrume
900  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
901  // qsamplerChannelRoutingTable - Channel routing table.  // qsamplerChannelRoutingTable - Channel routing table.
902  //  //
903    #if 0
904  // Constructor.  // Constructor.
905  qsamplerChannelRoutingTable::qsamplerChannelRoutingTable (  qsamplerChannelRoutingTable::qsamplerChannelRoutingTable (
906          QWidget *pParent, const char *pszName )          QWidget *pParent, const char *pszName )
# Line 995  void qsamplerChannelRoutingTable::flush Line 996  void qsamplerChannelRoutingTable::flush
996          if (QTable::isEditing())          if (QTable::isEditing())
997              QTable::endEdit(QTable::currEditRow(), QTable::currEditCol(), true, true);              QTable::endEdit(QTable::currEditRow(), QTable::currEditCol(), true, true);
998  }  }
999    #endif
1000    
1001    ChannelRoutingModel::ChannelRoutingModel(QObject* parent) : QAbstractTableModel(parent), pDevice(NULL) {
1002    }
1003    
1004    int ChannelRoutingModel::rowCount(const QModelIndex& /*parent*/) const {
1005        return routing.size();
1006    }
1007    
1008    int ChannelRoutingModel::columnCount(const QModelIndex& /*parent*/) const {
1009        return 1;
1010    }
1011    
1012    QVariant ChannelRoutingModel::data(const QModelIndex &index, int role) const {
1013        if (!index.isValid())
1014            return QVariant();
1015        if (role != Qt::DisplayRole)
1016            return QVariant();
1017    
1018        ChannelRoutingItem item;
1019    
1020        // The common device port item list.
1021        qsamplerDevicePortList& ports = pDevice->ports();
1022        qsamplerDevicePort* pPort;
1023        for (pPort = ports.first(); pPort; pPort = ports.next()) {
1024            item.options.append(
1025                pDevice->deviceTypeName()
1026                + ' ' + pDevice->driverName()
1027                + ' ' + pPort->portName()
1028            );
1029        }
1030    
1031        item.selection = routing[index.column()];
1032    
1033        return QVariant::fromValue(item);
1034    }
1035    
1036    QVariant ChannelRoutingModel::headerData(int section, Qt::Orientation orientation, int role) const {
1037        if (role != Qt::DisplayRole) return QVariant();
1038    
1039        if (orientation == Qt::Horizontal)
1040            return QObject::tr("Device Channel");
1041    
1042        if (orientation == Qt::Vertical)
1043            return QObject::tr("Sampler Channel Output ") +
1044                   QString(section);
1045    
1046        return QVariant();
1047    }
1048    
1049    void ChannelRoutingModel::refresh ( qsamplerDevice *pDevice,
1050            const qsamplerChannelRoutingMap& routing )
1051    {
1052        this->pDevice = pDevice;
1053        this->routing = routing;
1054    }
1055    
1056    
1057    
1058    
1059    ChannelRoutingDelegate::ChannelRoutingDelegate(QObject *parent) : QItemDelegate(parent) {
1060    }
1061    
1062    QWidget* ChannelRoutingDelegate::createEditor(QWidget *parent,
1063            const QStyleOptionViewItem &/* option */,
1064            const QModelIndex& index) const
1065    {
1066        ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>();
1067    
1068        QComboBox* editor = new QComboBox(parent);
1069        editor->addItems(item.options);
1070        editor->setCurrentIndex(item.selection);
1071        editor->installEventFilter(const_cast<ChannelRoutingDelegate*>(this));
1072        return editor;
1073    }
1074    
1075    void ChannelRoutingDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
1076        ChannelRoutingItem item = index.model()->data(index, Qt::DisplayRole).value<ChannelRoutingItem>();
1077        QComboBox* comboBox = static_cast<QComboBox*>(editor);
1078        comboBox->setCurrentIndex(item.selection);
1079    }
1080    
1081    void ChannelRoutingDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
1082        QComboBox* comboBox = static_cast<QComboBox*>(editor);
1083        model->setData(index, comboBox->currentIndex());
1084    }
1085    
1086    void ChannelRoutingDelegate::updateEditorGeometry(QWidget *editor,
1087            const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
1088    {
1089        editor->setGeometry(option.rect);
1090    }
1091    
1092    
1093    
1094  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1095  // qsamplerChannelRoutingComboBox - Custom combo box for routing table.  // qsamplerChannelRoutingComboBox - Custom combo box for routing table.
1096  //  //
1097    
1098    #if 0
1099  // Constructor.  // Constructor.
1100  qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox (  qsamplerChannelRoutingComboBox::qsamplerChannelRoutingComboBox (
1101          QTable *pTable, const QStringList& list, const QPixmap& pixmap )          QTable *pTable, const QStringList& list, const QPixmap& pixmap )
# Line 1047  void qsamplerChannelRoutingComboBox::set Line 1142  void qsamplerChannelRoutingComboBox::set
1142          else QTableItem::setContentFromEditor(pWidget);          else QTableItem::setContentFromEditor(pWidget);
1143  }  }
1144    
1145    #endif
 // end of qsamplerChannel.cpp  

Legend:
Removed from v.1460  
changed lines
  Added in v.1461

  ViewVC Help
Powered by ViewVC