--- qsampler/trunk/src/qsamplerChannel.h 2005/03/22 12:55:29 484 +++ qsampler/trunk/src/qsamplerChannel.h 2007/11/22 14:17:24 1510 @@ -1,7 +1,8 @@ // 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. + Copyright (C) 2007, Christian Schoenebeck This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -13,23 +14,28 @@ 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 "qsamplerOptions.h" -class qsamplerMainForm; +class qsamplerDevice; + + +// Typedef'd QMap. +typedef QMap qsamplerChannelRoutingMap; //------------------------------------------------------------------------- @@ -41,19 +47,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(); @@ -74,7 +71,7 @@ int instrumentNr() const; const QString& instrumentName() const; int instrumentStatus() const; - + // Instrument file loader. bool loadInstrument(const QString& sInstrumentFile, int iInstrumentNr); // Special instrument file/name/number settler. @@ -96,6 +93,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); @@ -108,6 +109,20 @@ float volume() const; bool setVolume(float fVolume); + // Sampler channel mute state. + bool channelMute() const; + bool setChannelMute(bool bMute); + + // Sampler channel solo state. + 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(); @@ -120,6 +135,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; @@ -133,6 +151,7 @@ // Common (invalid) name-helpers. static QString noEngineName(); static QString noInstrumentName(); + static QString loadingInstrument(); // Check whether a given file is an instrument file. static bool isInstrumentFile (const QString& sInstrumentFile); @@ -145,9 +164,6 @@ private: - // Main application form reference. - qsamplerMainForm *m_pMainForm; - // Unique channel identifier. int m_iChannelID; @@ -157,16 +173,89 @@ QString m_sInstrumentFile; int m_iInstrumentNr; int m_iInstrumentStatus; - QString m_sMidiDriver; // DEPRECATED. + QString m_sMidiDriver; int m_iMidiDevice; int m_iMidiPort; int m_iMidiChannel; - QString m_sAudioDriver; // DEPRECATED. + 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; }; -#endif // __qsamplerChannel_h +//------------------------------------------------------------------------- +// ChannelRoutingModel - data model for audio routing (used for QTableView) +// + +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* pParent = NULL); + + // overridden methods from subclass(es) + int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const; + Qt::ItemFlags flags(const QModelIndex& index) const; + bool setData(const QModelIndex& index, const QVariant& value, + int role = Qt::EditRole); + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + + // own methods + qsamplerChannelRoutingMap routingMap() const { return m_routing; } + + void clear() { m_routing.clear(); } + +public slots: + + void refresh(qsamplerDevice *pDevice, + const qsamplerChannelRoutingMap& routing); + +private: + + qsamplerDevice *m_pDevice; + qsamplerChannelRoutingMap m_routing; +}; + + +//------------------------------------------------------------------------- +// ChannelRoutingDelegate - table cell renderer for audio routing +// + +class ChannelRoutingDelegate : public QItemDelegate +{ + Q_OBJECT + +public: + + ChannelRoutingDelegate(QObject* pParent = NULL); + + QWidget* createEditor(QWidget *pParent, + const QStyleOptionViewItem& option, const QModelIndex& index) const; + void setEditorData(QWidget *pEditor, const QModelIndex& index) const; + void setModelData(QWidget *pEditor, QAbstractItemModel* model, + const QModelIndex& index) const; + void updateEditorGeometry(QWidget *pEditor, + const QStyleOptionViewItem& option, const QModelIndex& index) const; +}; + +#endif // __qsamplerChannel_h // end of qsamplerChannel.h