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

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

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

revision 400 by capela, Mon Feb 21 15:02:58 2005 UTC revision 1499 by capela, Tue Nov 20 16:48:04 2007 UTC
# Line 1  Line 1 
1  // qsamplerChannel.h  // qsamplerChannel.h
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5       Copyright (C) 2007, Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 13  Line 14 
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.     GNU General Public License for more details.
16    
17     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License along
18     along with this program; if not, write to the Free Software     with this program; if not, write to the Free Software Foundation, Inc.,
19     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20    
21  *****************************************************************************/  *****************************************************************************/
22    
23  #ifndef __qsamplerChannel_h  #ifndef __qsamplerChannel_h
24  #define __qsamplerChannel_h  #define __qsamplerChannel_h
25    
26  #include <qobject.h>  #include <QTableWidgetItem>
27    #include <QItemDelegate>
28    
29  #include <lscp/client.h>  #include <lscp/client.h>
30  #include <lscp/device.h>  #include <lscp/device.h>
31    
32  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
33    
34  class qsamplerMainForm;  class qsamplerDevice;
35    
36    
37    // Typedef'd QMap.
38    typedef QMap<int, int> qsamplerChannelRoutingMap;
39    
40    
41  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
# Line 40  class qsamplerChannel Line 46  class qsamplerChannel
46  {  {
47  public:  public:
48    
49      // Constructor.          // Constructor.
50      qsamplerChannel(qsamplerMainForm *pMainForm, int iChannelID = -1);          qsamplerChannel(int iChannelID = -1);
51      // Default destructor.          // Default destructor.
52      ~qsamplerChannel();          ~qsamplerChannel();
53    
54      // Main application options accessor.          // Add/remove sampler channel methods.
55      qsamplerOptions *options();          bool     addChannel();
56            bool     removeChannel();
57      // LSCP client descriptor accessor.  
58      lscp_client_t * client();          // Sampler channel ID accessors.
59            int      channelID() const;
60      // Add/remove sampler channel methods.          void     setChannelID(int iChannelID);
61      bool     addChannel();  
62      bool     removeChannel();          // Readable channel name.
63            QString  channelName() const;
64      // Sampler channel ID accessors.  
65      int      channelID();          // Engine name property.
66      void     setChannelID(int iChannelID);          const QString& engineName() const;
67                bool     loadEngine(const QString& sEngineName);
68      // Readable channel name.  
69      QString  channelName();          // Instrument file and index.
70            const QString& instrumentFile() const;
71      // Engine name property.          int      instrumentNr() const;
72      QString& engineName();          const QString& instrumentName() const;
73      bool     loadEngine(const QString& sEngineName);          int      instrumentStatus() const;
74        
75      // Instrument file and index.          // Instrument file loader.
76      QString& instrumentFile();          bool     loadInstrument(const QString& sInstrumentFile, int iInstrumentNr);
     int      instrumentNr();  
     QString& instrumentName();  
     int      instrumentStatus();  
     bool     loadInstrument(const QString& sInstrumentFile, int iInstrumentNr);  
77          // Special instrument file/name/number settler.          // Special instrument file/name/number settler.
78      bool     setInstrument(const QString& sInstrumentFile, int iInstrumentNr);          bool     setInstrument(const QString& sInstrumentFile, int iInstrumentNr);
79    
80      // MIDI input driver (DEPRECATED).          // MIDI input driver (DEPRECATED).
81      QString& midiDriver();          const QString& midiDriver() const;
82      bool     setMidiDriver(const QString& sMidiDriver);          bool     setMidiDriver(const QString& sMidiDriver);
83        
84      // MIDI input device.          // MIDI input device.
85      int      midiDevice();          int      midiDevice() const;
86      bool     setMidiDevice(int iMidiDevice);          bool     setMidiDevice(int iMidiDevice);
87        
88      // MIDI input port.          // MIDI input port.
89      int      midiPort();          int      midiPort() const;
90      bool     setMidiPort(int iMidiPort);          bool     setMidiPort(int iMidiPort);
91        
92      // MIDI input channel.          // MIDI input channel.
93      int      midiChannel();          int      midiChannel() const;
94      bool     setMidiChannel(int iMidiChannel);          bool     setMidiChannel(int iMidiChannel);
95        
96      // Audio output driver (DEPRECATED).          // MIDI instrument map.
97      QString& audioDriver();          int      midiMap() const;
98      bool     setAudioDriver(const QString& sAudioDriver);          bool     setMidiMap(int iMidiMap);
99    
100      // Audio output device.          // Audio output driver (DEPRECATED).
101      int      audioDevice();          const QString& audioDriver() const;
102      bool     setAudioDevice(int iAudioDevice);          bool     setAudioDriver(const QString& sAudioDriver);
103        
104      // Sampler channel volume.          // Audio output device.
105      float    volume();          int      audioDevice() const;
106      bool     setVolume(float fVolume);          bool     setAudioDevice(int iAudioDevice);
107    
108      // Istrument name remapper.          // Sampler channel volume.
109      void     updateInstrumentName();          float    volume() const;
110            bool     setVolume(float fVolume);
111      // Channel info structure map executive.  
112      bool     updateChannelInfo();          // Sampler channel mute state.
113            bool     channelMute() const;
114      // Channel setup dialog form.          bool     setChannelMute(bool bMute);
115      bool     channelSetup(QWidget *pParent);  
116            // Sampler channel solo state.
117      // Reset channel method.          bool     channelSolo() const;
118      bool     channelReset();          bool     setChannelSolo(bool bSolo);
119    
120      // Message logging methods (brainlessly mapped to main form's).          // Audio routing accessors.
121      void     appendMessages       (const QString & s);          int      audioChannel(int iAudioOut) const;
122      void     appendMessagesColor  (const QString & s, const QString & c);          bool     setAudioChannel(int iAudioOut, int iAudioIn);
123      void     appendMessagesText   (const QString & s);          // The audio routing map itself.
124      void     appendMessagesError  (const QString & s);          const qsamplerChannelRoutingMap& audioRouting() const;
125      void     appendMessagesClient (const QString & s);  
126            // Istrument name remapper.
127            void     updateInstrumentName();
128    
129            // Channel info structure map executive.
130            bool     updateChannelInfo();
131    
132            // Channel setup dialog form.
133            bool     channelSetup(QWidget *pParent);
134    
135            // Reset channel method.
136            bool     channelReset();
137    
138            // Spawn instrument editor method.
139            bool     editChannel();
140    
141            // Message logging methods (brainlessly mapped to main form's).
142            void     appendMessages       (const QString & s) const;
143            void     appendMessagesColor  (const QString & s, const QString & c) const;
144            void     appendMessagesText   (const QString & s) const;
145            void     appendMessagesError  (const QString & s) const;
146            void     appendMessagesClient (const QString & s) const;
147    
148      // Context menu event handler.          // Context menu event handler.
149      void contextMenuEvent(QContextMenuEvent *pEvent);          void contextMenuEvent(QContextMenuEvent *pEvent);
150    
151          // Common (invalid) name-helpers.          // Common (invalid) name-helpers.
152      static QString noEngineName();          static QString noEngineName();
153      static QString noInstrumentName();          static QString noInstrumentName();
154            static QString loadingInstrument();
155    
156          // Check whether a given file is an instrument file.          // Check whether a given file is an instrument file.
157          static bool isInstrumentFile (const QString& sInstrumentFile);          static bool isInstrumentFile (const QString& sInstrumentFile);
158    
159      // Retrieve the available instrument name(s) of an instrument file (.gig).          // Retrieve the available instrument name(s) of an instrument file (.gig).
160      static QString getInstrumentName (const QString& sInstrumentFile,          static QString getInstrumentName (const QString& sInstrumentFile,
161                                                          int iInstrumentNr, bool bInstrumentNames);                                                          int iInstrumentNr, bool bInstrumentNames);
162      static QStringList getInstrumentList (const QString& sInstrumentFile,          static QStringList getInstrumentList (const QString& sInstrumentFile,
163                                                          bool bInstrumentNames);                                                          bool bInstrumentNames);
164    
165  private:  private:
166    
167      // Main application form reference.          // Unique channel identifier.
168      qsamplerMainForm *m_pMainForm;          int     m_iChannelID;
169    
170      // Unique channel identifier.          // Sampler channel info map.
171      int     m_iChannelID;          QString m_sEngineName;
172            QString m_sInstrumentName;
173            QString m_sInstrumentFile;
174            int     m_iInstrumentNr;
175            int     m_iInstrumentStatus;
176            QString m_sMidiDriver;
177            int     m_iMidiDevice;
178            int     m_iMidiPort;
179            int     m_iMidiChannel;
180            int     m_iMidiMap;
181            QString m_sAudioDriver;
182            int     m_iAudioDevice;
183            float   m_fVolume;
184            bool    m_bMute;
185            bool    m_bSolo;
186    
187      // Sampler channel info map.          // The audio routing mapping.
188      QString m_sEngineName;          qsamplerChannelRoutingMap m_audioRouting;
     QString m_sInstrumentName;  
     QString m_sInstrumentFile;  
     int     m_iInstrumentNr;  
     int     m_iInstrumentStatus;  
     QString m_sMidiDriver;          // DEPRECATED.  
     int     m_iMidiDevice;  
     int     m_iMidiPort;  
     int     m_iMidiChannel;  
     QString m_sAudioDriver;         // DEPRECATED.  
     int     m_iAudioDevice;  
     float   m_fVolume;  
189  };  };
190    
 #endif  // __qsamplerChannel_h  
191    
192    //-------------------------------------------------------------------------
193    // ChannelRoutingModel - data model for audio routing (used for QTableView)
194    //
195    
196    struct ChannelRoutingItem {
197        QStringList options;
198        int         selection;
199    };
200    
201    // so we can use it i.e. through QVariant
202    Q_DECLARE_METATYPE(ChannelRoutingItem)
203    
204    class ChannelRoutingModel : public QAbstractTableModel {
205            Q_OBJECT
206        public:
207            ChannelRoutingModel(QObject* parent = 0);
208    
209            // overridden methods from subclass(es)
210            int rowCount(const QModelIndex &parent = QModelIndex()) const;
211            int columnCount(const QModelIndex &parent = QModelIndex()) const;
212            Qt::ItemFlags flags(const QModelIndex& index) const;
213            bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
214            QVariant data(const QModelIndex &index, int role) const;
215            QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
216    
217            // own methods
218            qsamplerChannelRoutingMap routingMap() const {
219                return routing;
220            }
221    
222            void clear() { routing.clear(); }
223    
224        public slots:
225            void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing);
226    
227        private:
228            qsamplerDevice* pDevice;
229            qsamplerChannelRoutingMap routing;
230    };
231    
232    
233    //-------------------------------------------------------------------------
234    // ChannelRoutingDelegate - table cell renderer for audio routing
235    //
236    
237    class ChannelRoutingDelegate : public QItemDelegate {
238            Q_OBJECT
239        public:
240            ChannelRoutingDelegate(QObject* parent = 0);
241            QWidget* createEditor(QWidget* parent,
242                                  const QStyleOptionViewItem& option,
243                                  const QModelIndex& index) const;
244            void setEditorData(QWidget* editor, const QModelIndex& index) const;
245            void setModelData(QWidget* editor, QAbstractItemModel* model,
246                              const QModelIndex& index) const;
247            void updateEditorGeometry(QWidget* editor,
248                                      const QStyleOptionViewItem& option,
249                                      const QModelIndex& index) const;
250    };
251    
252    #endif  // __qsamplerChannel_h
253    
254  // end of qsamplerChannel.h  // end of qsamplerChannel.h

Legend:
Removed from v.400  
changed lines
  Added in v.1499

  ViewVC Help
Powered by ViewVC