/[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 341 by capela, Tue Jan 18 11:29:01 2005 UTC revision 1461 by schoenebeck, Sun Oct 28 23:30:36 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    
6     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
7     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 13 
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.     GNU General Public License for more details.
15    
16     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
17     along with this program; if not, write to the Free Software     with this program; if not, write to the Free Software Foundation, Inc.,
18     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19    
20  *****************************************************************************/  *****************************************************************************/
21    
22  #ifndef __qsamplerChannel_h  #ifndef __qsamplerChannel_h
23  #define __qsamplerChannel_h  #define __qsamplerChannel_h
24    
25  #include <qobject.h>  #include <QTableWidgetItem>
26    #include <QAbstractTableModel>
27    #include <QMetaType>
28    #include <QItemDelegate>
29    #include <QFontMetrics>
30    #include <QModelIndex>
31    #include <QSize>
32    
33  #include <lscp/client.h>  #include <lscp/client.h>
34  #include <lscp/device.h>  #include <lscp/device.h>
35    
36  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
37    
38  class qsamplerMainForm;  class qsamplerDevice;
39    
40    
41    // Typedef'd QMap.
42    typedef QMap<int, int> qsamplerChannelRoutingMap;
43    
44    
45  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
# Line 40  class qsamplerChannel Line 50  class qsamplerChannel
50  {  {
51  public:  public:
52    
53      // Constructor.          // Constructor.
54      qsamplerChannel(qsamplerMainForm *pMainForm, int iChannelID = -1);          qsamplerChannel(int iChannelID = -1);
55      // Default destructor.          // Default destructor.
56      ~qsamplerChannel();          ~qsamplerChannel();
57    
58      // Main application options accessor.          // Add/remove sampler channel methods.
59      qsamplerOptions *options();          bool     addChannel();
60            bool     removeChannel();
61      // LSCP client descriptor accessor.  
62      lscp_client_t * client();          // Sampler channel ID accessors.
63            int      channelID() const;
64      // Add/remove sampler channel methods.          void     setChannelID(int iChannelID);
65      bool     addChannel();  
66      bool     removeChannel();          // Readable channel name.
67            QString  channelName() const;
68      // Sampler channel ID accessors.  
69      int      channelID();          // Engine name property.
70      void     setChannelID(int iChannelID);          const QString& engineName() const;
71                bool     loadEngine(const QString& sEngineName);
72      // Readable channel name.  
73      QString  channelName();          // Instrument file and index.
74            const QString& instrumentFile() const;
75      // Engine name property.          int      instrumentNr() const;
76      QString& engineName();          const QString& instrumentName() const;
77      bool     loadEngine(const QString& sEngineName);          int      instrumentStatus() const;
78        
79      // Instrument file and index.          // Instrument file loader.
80      QString& instrumentFile();          bool     loadInstrument(const QString& sInstrumentFile, int iInstrumentNr);
81      int      instrumentNr();          // Special instrument file/name/number settler.
82      int      instrumentStatus();          bool     setInstrument(const QString& sInstrumentFile, int iInstrumentNr);
83      bool     loadInstrument(const QString& sInstrumentFile, int iInstrumentNr);  
84                // MIDI input driver (DEPRECATED).
85      // MIDI input driver (DEPRECATED).          const QString& midiDriver() const;
86      QString& midiDriver();          bool     setMidiDriver(const QString& sMidiDriver);
87      bool     setMidiDriver(const QString& sMidiDriver);  
88                // MIDI input device.
89      // MIDI input device.          int      midiDevice() const;
90      int      midiDevice();          bool     setMidiDevice(int iMidiDevice);
91      bool     setMidiDevice(int iMidiDevice);  
92                // MIDI input port.
93      // MIDI input port.          int      midiPort() const;
94      int      midiPort();          bool     setMidiPort(int iMidiPort);
95      bool     setMidiPort(int iMidiPort);  
96                // MIDI input channel.
97      // MIDI input channel.          int      midiChannel() const;
98      int      midiChannel();          bool     setMidiChannel(int iMidiChannel);
99      bool     setMidiChannel(int iMidiChannel);  
100                // MIDI instrument map.
101      // Audio output driver (DEPRECATED).          int      midiMap() const;
102      QString& audioDriver();          bool     setMidiMap(int iMidiMap);
103      bool     setAudioDriver(const QString& sAudioDriver);  
104            // Audio output driver (DEPRECATED).
105      // Audio output device.          const QString& audioDriver() const;
106      int      audioDevice();          bool     setAudioDriver(const QString& sAudioDriver);
107      bool     setAudioDevice(int iAudioDevice);  
108                // Audio output device.
109      // Sampler channel volume.          int      audioDevice() const;
110      float    volume();          bool     setAudioDevice(int iAudioDevice);
111      bool     setVolume(float fVolume);  
112            // Sampler channel volume.
113      // Channel info structure map executive.          float    volume() const;
114      bool     updateChannelInfo();          bool     setVolume(float fVolume);
115    
116      // Reset channel method.          // Sampler channel mute state.
117      bool     resetChannel();          bool     channelMute() const;
118            bool     setChannelMute(bool bMute);
119      // Channel setup dialog form.  
120      bool     channelSetup(QWidget *pParent);          // Sampler channel solo state.
121            bool     channelSolo() const;
122      // Message logging methods (brainlessly mapped to main form's).          bool     setChannelSolo(bool bSolo);
123      void     appendMessages       (const QString & s);  
124      void     appendMessagesColor  (const QString & s, const QString & c);          // Audio routing accessors.
125      void     appendMessagesText   (const QString & s);          int      audioChannel(int iAudioOut) const;
126      void     appendMessagesError  (const QString & s);          bool     setAudioChannel(int iAudioOut, int iAudioIn);
127      void     appendMessagesClient (const QString & s);          // The audio routing map itself.
128            const qsamplerChannelRoutingMap& audioRouting() const;
129      // Context menu event handler.  
130      void contextMenuEvent(QContextMenuEvent *pEvent);          // Istrument name remapper.
131            void     updateInstrumentName();
132      // Retrieve the available instrument name(s) of an instrument file (.gig).  
133      static QString     getInstrumentName (const QString& sInstrumentFile, int iInstrumentNr);          // Channel info structure map executive.
134      static QStringList getInstrumentList (const QString& sInstrumentFile);          bool     updateChannelInfo();
135    
136      // Instrument name(s) retrieval mode.          // Channel setup dialog form.
137      static bool instrumentNames();          bool     channelSetup(QWidget *pParent);
138      static void setInstrumentNames (bool bInstrumentNames);  
139            // Reset channel method.
140            bool     channelReset();
141    
142            // Spawn instrument editor method.
143            bool     editChannel();
144    
145            // Message logging methods (brainlessly mapped to main form's).
146            void     appendMessages       (const QString & s) const;
147            void     appendMessagesColor  (const QString & s, const QString & c) const;
148            void     appendMessagesText   (const QString & s) const;
149            void     appendMessagesError  (const QString & s) const;
150            void     appendMessagesClient (const QString & s) const;
151    
152            // Context menu event handler.
153            void contextMenuEvent(QContextMenuEvent *pEvent);
154    
155            // Common (invalid) name-helpers.
156            static QString noEngineName();
157            static QString noInstrumentName();
158            static QString loadingInstrument();
159    
160            // Check whether a given file is an instrument file.
161            static bool isInstrumentFile (const QString& sInstrumentFile);
162    
163            // Retrieve the available instrument name(s) of an instrument file (.gig).
164            static QString getInstrumentName (const QString& sInstrumentFile,
165                                                            int iInstrumentNr, bool bInstrumentNames);
166            static QStringList getInstrumentList (const QString& sInstrumentFile,
167                                                            bool bInstrumentNames);
168    
169  private:  private:
170    
171      // Main application form reference.          // Unique channel identifier.
172      qsamplerMainForm *m_pMainForm;          int     m_iChannelID;
173    
174            // Sampler channel info map.
175            QString m_sEngineName;
176            QString m_sInstrumentName;
177            QString m_sInstrumentFile;
178            int     m_iInstrumentNr;
179            int     m_iInstrumentStatus;
180            QString m_sMidiDriver;
181            int     m_iMidiDevice;
182            int     m_iMidiPort;
183            int     m_iMidiChannel;
184            int     m_iMidiMap;
185            QString m_sAudioDriver;
186            int     m_iAudioDevice;
187            float   m_fVolume;
188            bool    m_bMute;
189            bool    m_bSolo;
190    
191            // The audio routing mapping.
192            qsamplerChannelRoutingMap m_audioRouting;
193    };
194    
195    
196    //-------------------------------------------------------------------------
197    // qsamplerChannelRoutingTable - Channel routing table widget.
198    //
199    
200      // Unique channel identifier.  #if 0
201      int     m_iChannelID;  class qsamplerChannelRoutingTable : public QTable
202    {
203            Q_OBJECT
204    
205    public:
206    
207            // Constructor.
208            qsamplerChannelRoutingTable(QWidget *pParent = 0, const char *pszName = 0);
209            // Default destructor.
210            ~qsamplerChannelRoutingTable();
211    
212            // Common parameter table renderer.
213            void refresh(qsamplerDevice *pDevice,
214                    const qsamplerChannelRoutingMap& routing);
215    
216            // Commit any pending editing.
217            void flush();
218    };
219    #endif
220    
221    struct ChannelRoutingItem {
222        QStringList options;
223        int         selection;
224    };
225    
226    // so we can use it i.e. through QVariant
227    Q_DECLARE_METATYPE(ChannelRoutingItem)
228    
229    class ChannelRoutingModel : public QAbstractTableModel {
230            Q_OBJECT
231        public:
232            ChannelRoutingModel(QObject* parent = 0);
233    
234            // overridden methods from subclass(es)
235            int rowCount(const QModelIndex &parent) const;
236            int columnCount(const QModelIndex &parent) const;
237            QVariant data(const QModelIndex &index, int role) const;
238            QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
239    
240        public slots:
241            void refresh(qsamplerDevice *pDevice, const qsamplerChannelRoutingMap& routing);
242    
243        private:
244            qsamplerDevice* pDevice;
245            qsamplerChannelRoutingMap routing;
246    };
247    
248    class ChannelRoutingDelegate : public QItemDelegate {
249            Q_OBJECT
250        public:
251            ChannelRoutingDelegate(QObject* parent = 0);
252    
253            QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
254                                  const QModelIndex& index) const;
255    
256            void setEditorData(QWidget* editor, const QModelIndex& index) const;
257            void setModelData(QWidget* editor, QAbstractItemModel* model,
258                              const QModelIndex& index) const;
259    
260            void updateEditorGeometry(QWidget* editor,
261                const QStyleOptionViewItem& option, const QModelIndex& index) const;
262    };
263    
264    
265    //-------------------------------------------------------------------------
266    // qsamplerChannelRoutingComboBox - Custom combo box for routing table.
267    //
268    
269    /*
270    class qsamplerChannelRoutingComboBox : public QTableWidgetItem
271    {
272    public:
273    
274            // Constructor.
275            qsamplerChannelRoutingComboBox(QTableWidget *pTable,
276                    const QStringList& list, const QPixmap& pixmap);
277    
278            // Public accessors.
279            void setCurrentItem(int iCurrentItem);
280            int currentItem() const;
281    
282    protected:
283    
284            // Virtual implemetations.
285            QWidget *createEditor() const;
286            void setContentFromEditor(QWidget *pWidget);
287    
288    private:
289    
290      // Sampler channel info map.          // Initial value holders
291      QString m_sEngineName;          QStringList m_list;
292      QString m_sInstrumentFile;          int m_iCurrentItem;
     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;  
   
     // Retrieve mode for available instrument name(s)  
         // from an instrument file (.gig).  
         static bool g_bInstrumentNames;  
293  };  };
294    */
295    
296  #endif  // __qsamplerChannel_h  #endif  // __qsamplerChannel_h
297    

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

  ViewVC Help
Powered by ViewVC