--- qsampler/trunk/src/qsamplerChannel.h 2005/08/19 17:10:16 751 +++ qsampler/trunk/src/qsamplerChannel.h 2007/10/28 23:30:36 1461 @@ -1,7 +1,7 @@ // qsamplerChannel.h // /**************************************************************************** - Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -13,23 +13,33 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *****************************************************************************/ #ifndef __qsamplerChannel_h #define __qsamplerChannel_h -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include "qsamplerOptions.h" -class qsamplerMainForm; +class qsamplerDevice; + + +// Typedef'd QMap. +typedef QMap qsamplerChannelRoutingMap; //------------------------------------------------------------------------- @@ -41,19 +51,10 @@ public: // Constructor. - qsamplerChannel(qsamplerMainForm *pMainForm, int iChannelID = -1); + qsamplerChannel(int iChannelID = -1); // Default destructor. ~qsamplerChannel(); - // Main application form accessor. - qsamplerMainForm *mainForm() const; - - // Main application options accessor. - qsamplerOptions *options() const; - - // LSCP client descriptor accessor. - lscp_client_t * client() const; - // Add/remove sampler channel methods. bool addChannel(); bool removeChannel(); @@ -96,6 +97,10 @@ int midiChannel() const; bool setMidiChannel(int iMidiChannel); + // MIDI instrument map. + int midiMap() const; + bool setMidiMap(int iMidiMap); + // Audio output driver (DEPRECATED). const QString& audioDriver() const; bool setAudioDriver(const QString& sAudioDriver); @@ -116,6 +121,12 @@ bool channelSolo() const; bool setChannelSolo(bool bSolo); + // Audio routing accessors. + int audioChannel(int iAudioOut) const; + bool setAudioChannel(int iAudioOut, int iAudioIn); + // The audio routing map itself. + const qsamplerChannelRoutingMap& audioRouting() const; + // Istrument name remapper. void updateInstrumentName(); @@ -128,6 +139,9 @@ // Reset channel method. bool channelReset(); + // Spawn instrument editor method. + bool editChannel(); + // Message logging methods (brainlessly mapped to main form's). void appendMessages (const QString & s) const; void appendMessagesColor (const QString & s, const QString & c) const; @@ -154,9 +168,6 @@ private: - // Main application form reference. - qsamplerMainForm *m_pMainForm; - // Unique channel identifier. int m_iChannelID; @@ -170,12 +181,117 @@ int m_iMidiDevice; int m_iMidiPort; int m_iMidiChannel; + int m_iMidiMap; QString m_sAudioDriver; int m_iAudioDevice; float m_fVolume; bool m_bMute; bool m_bSolo; + + // The audio routing mapping. + qsamplerChannelRoutingMap m_audioRouting; +}; + + +//------------------------------------------------------------------------- +// qsamplerChannelRoutingTable - Channel routing table widget. +// + +#if 0 +class qsamplerChannelRoutingTable : public QTable +{ + Q_OBJECT + +public: + + // Constructor. + qsamplerChannelRoutingTable(QWidget *pParent = 0, const char *pszName = 0); + // Default destructor. + ~qsamplerChannelRoutingTable(); + + // Common parameter table renderer. + void refresh(qsamplerDevice *pDevice, + const qsamplerChannelRoutingMap& routing); + + // Commit any pending editing. + void flush(); +}; +#endif + +struct ChannelRoutingItem { + QStringList options; + int selection; +}; + +// so we can use it i.e. through QVariant +Q_DECLARE_METATYPE(ChannelRoutingItem) + +class ChannelRoutingModel : public QAbstractTableModel { + Q_OBJECT + public: + ChannelRoutingModel(QObject* parent = 0); + + // overridden methods from subclass(es) + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + + public slots: + void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing); + + private: + qsamplerDevice* pDevice; + qsamplerChannelRoutingMap routing; +}; + +class ChannelRoutingDelegate : public QItemDelegate { + Q_OBJECT + public: + ChannelRoutingDelegate(QObject* parent = 0); + + QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, + const QModelIndex& index) const; + + void setEditorData(QWidget* editor, const QModelIndex& index) const; + void setModelData(QWidget* editor, QAbstractItemModel* model, + const QModelIndex& index) const; + + void updateEditorGeometry(QWidget* editor, + const QStyleOptionViewItem& option, const QModelIndex& index) const; +}; + + +//------------------------------------------------------------------------- +// qsamplerChannelRoutingComboBox - Custom combo box for routing table. +// + +/* +class qsamplerChannelRoutingComboBox : public QTableWidgetItem +{ +public: + + // Constructor. + qsamplerChannelRoutingComboBox(QTableWidget *pTable, + const QStringList& list, const QPixmap& pixmap); + + // Public accessors. + void setCurrentItem(int iCurrentItem); + int currentItem() const; + +protected: + + // Virtual implemetations. + QWidget *createEditor() const; + void setContentFromEditor(QWidget *pWidget); + +private: + + // Initial value holders + QStringList m_list; + int m_iCurrentItem; }; +*/ #endif // __qsamplerChannel_h