/[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 1558 by capela, Thu Dec 6 09:35:33 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;  namespace QSampler {
35    
36    class Device;
37    
38    // Typedef'd QMap.
39    typedef QMap<int, int> ChannelRoutingMap;
40    
41    
42  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
43  // qsamplerChannel - Sampler channel structure.  // QSampler::Channel - Sampler channel structure.
44  //  //
45    
46  class qsamplerChannel  class Channel
47  {  {
48  public:  public:
49    
50      // Constructor.          // Constructor.
51      qsamplerChannel(qsamplerMainForm *pMainForm, int iChannelID = -1);          Channel(int iChannelID = -1);
52      // Default destructor.          // Default destructor.
53      ~qsamplerChannel();          ~Channel();
54    
55      // Main application options accessor.          // Add/remove sampler channel methods.
56      qsamplerOptions *options();          bool     addChannel();
57            bool     removeChannel();
58      // LSCP client descriptor accessor.  
59      lscp_client_t * client();          // Sampler channel ID accessors.
60            int      channelID() const;
61      // Add/remove sampler channel methods.          void     setChannelID(int iChannelID);
62      bool     addChannel();  
63      bool     removeChannel();          // Readable channel name.
64            QString  channelName() const;
65      // Sampler channel ID accessors.  
66      int      channelID();          // Engine name property.
67      void     setChannelID(int iChannelID);          const QString& engineName() const;
68                bool     loadEngine(const QString& sEngineName);
69      // Readable channel name.  
70      QString  channelName();          // Instrument file and index.
71            const QString& instrumentFile() const;
72      // Engine name property.          int      instrumentNr() const;
73      QString& engineName();          const QString& instrumentName() const;
74      bool     loadEngine(const QString& sEngineName);          int      instrumentStatus() const;
75        
76      // Instrument file and index.          // Instrument file loader.
77      QString& instrumentFile();          bool     loadInstrument(const QString& sInstrumentFile, int iInstrumentNr);
78      int      instrumentNr();          // Special instrument file/name/number settler.
79      int      instrumentStatus();          bool     setInstrument(const QString& sInstrumentFile, int iInstrumentNr);
80      bool     loadInstrument(const QString& sInstrumentFile, int iInstrumentNr);  
81                // MIDI input driver (DEPRECATED).
82      // MIDI input driver (DEPRECATED).          const QString& midiDriver() const;
83      QString& midiDriver();          bool     setMidiDriver(const QString& sMidiDriver);
84      bool     setMidiDriver(const QString& sMidiDriver);  
85                // MIDI input device.
86      // MIDI input device.          int      midiDevice() const;
87      int      midiDevice();          bool     setMidiDevice(int iMidiDevice);
88      bool     setMidiDevice(int iMidiDevice);  
89                // MIDI input port.
90      // MIDI input port.          int      midiPort() const;
91      int      midiPort();          bool     setMidiPort(int iMidiPort);
92      bool     setMidiPort(int iMidiPort);  
93                // MIDI input channel.
94      // MIDI input channel.          int      midiChannel() const;
95      int      midiChannel();          bool     setMidiChannel(int iMidiChannel);
96      bool     setMidiChannel(int iMidiChannel);  
97                // MIDI instrument map.
98      // Audio output driver (DEPRECATED).          int      midiMap() const;
99      QString& audioDriver();          bool     setMidiMap(int iMidiMap);
100      bool     setAudioDriver(const QString& sAudioDriver);  
101            // Audio output driver (DEPRECATED).
102      // Audio output device.          const QString& audioDriver() const;
103      int      audioDevice();          bool     setAudioDriver(const QString& sAudioDriver);
104      bool     setAudioDevice(int iAudioDevice);  
105                // Audio output device.
106      // Sampler channel volume.          int      audioDevice() const;
107      float    volume();          bool     setAudioDevice(int iAudioDevice);
108      bool     setVolume(float fVolume);  
109            // Sampler channel volume.
110      // Channel info structure map executive.          float    volume() const;
111      bool     updateChannelInfo();          bool     setVolume(float fVolume);
112    
113      // Reset channel method.          // Sampler channel mute state.
114      bool     resetChannel();          bool     channelMute() const;
115            bool     setChannelMute(bool bMute);
116      // Channel setup dialog form.  
117      bool     channelSetup(QWidget *pParent);          // Sampler channel solo state.
118            bool     channelSolo() const;
119      // Message logging methods (brainlessly mapped to main form's).          bool     setChannelSolo(bool bSolo);
120      void     appendMessages       (const QString & s);  
121      void     appendMessagesColor  (const QString & s, const QString & c);          // Audio routing accessors.
122      void     appendMessagesText   (const QString & s);          int      audioChannel(int iAudioOut) const;
123      void     appendMessagesError  (const QString & s);          bool     setAudioChannel(int iAudioOut, int iAudioIn);
124      void     appendMessagesClient (const QString & s);          // The audio routing map itself.
125            const ChannelRoutingMap& audioRouting() const;
126      // Context menu event handler.  
127      void contextMenuEvent(QContextMenuEvent *pEvent);          // Istrument name remapper.
128            void     updateInstrumentName();
129      // Retrieve the available instrument name(s) of an instrument file (.gig).  
130      static QString     getInstrumentName (const QString& sInstrumentFile, int iInstrumentNr);          // Channel info structure map executive.
131      static QStringList getInstrumentList (const QString& sInstrumentFile);          bool     updateChannelInfo();
132    
133      // Instrument name(s) retrieval mode.          // Channel setup dialog form.
134      static bool instrumentNames();          bool     channelSetup(QWidget *pParent);
135      static void setInstrumentNames (bool bInstrumentNames);  
136            // Reset channel method.
137            bool     channelReset();
138    
139            // Spawn instrument editor method.
140            bool     editChannel();
141    
142            // Message logging methods (brainlessly mapped to main form's).
143            void     appendMessages       (const QString & s) const;
144            void     appendMessagesColor  (const QString & s, const QString & c) const;
145            void     appendMessagesText   (const QString & s) const;
146            void     appendMessagesError  (const QString & s) const;
147            void     appendMessagesClient (const QString & s) const;
148    
149            // Context menu event handler.
150            void contextMenuEvent(QContextMenuEvent *pEvent);
151    
152            // Common (invalid) name-helpers.
153            static QString noEngineName();
154            static QString noInstrumentName();
155            static QString loadingInstrument();
156    
157            // Check whether a given file is an instrument file.
158            static bool isInstrumentFile (const QString& sInstrumentFile);
159    
160            // Retrieve the available instrument name(s) of an instrument file (.gig).
161            static QString getInstrumentName (const QString& sInstrumentFile,
162                                                            int iInstrumentNr, bool bInstrumentNames);
163            static QStringList getInstrumentList (const QString& sInstrumentFile,
164                                                            bool bInstrumentNames);
165    
166  private:  private:
167    
168      // Main application form reference.          // Unique channel identifier.
169      qsamplerMainForm *m_pMainForm;          int     m_iChannelID;
170    
171      // Unique channel identifier.          // Sampler channel info map.
172      int     m_iChannelID;          QString m_sEngineName;
173            QString m_sInstrumentName;
174            QString m_sInstrumentFile;
175            int     m_iInstrumentNr;
176            int     m_iInstrumentStatus;
177            QString m_sMidiDriver;
178            int     m_iMidiDevice;
179            int     m_iMidiPort;
180            int     m_iMidiChannel;
181            int     m_iMidiMap;
182            QString m_sAudioDriver;
183            int     m_iAudioDevice;
184            float   m_fVolume;
185            bool    m_bMute;
186            bool    m_bSolo;
187    
188      // Sampler channel info map.          // The audio routing mapping.
189      QString m_sEngineName;          ChannelRoutingMap m_audioRouting;
     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;  
   
     // Retrieve mode for available instrument name(s)  
         // from an instrument file (.gig).  
         static bool g_bInstrumentNames;  
190  };  };
191    
192    
193    //-------------------------------------------------------------------------
194    // QSampler::ChannelRoutingModel - data model for audio routing
195    //                                 (used for QTableView)
196    //
197    
198    struct ChannelRoutingItem {
199            QStringList options;
200            int         selection;
201    };
202    
203    class ChannelRoutingModel : public QAbstractTableModel
204    {
205            Q_OBJECT
206    public:
207    
208            ChannelRoutingModel(QObject* pParent = NULL);
209    
210            // overridden methods from subclass(es)
211            int rowCount(const QModelIndex& parent = QModelIndex()) const;
212            int columnCount(const QModelIndex& parent = QModelIndex()) const;
213            Qt::ItemFlags flags(const QModelIndex& index) const;
214            bool setData(const QModelIndex& index, const QVariant& value,
215                    int role = Qt::EditRole);
216            QVariant data(const QModelIndex &index, int role) const;
217            QVariant headerData(int section, Qt::Orientation orientation,
218                    int role = Qt::DisplayRole) const;
219    
220            // own methods
221            ChannelRoutingMap routingMap() const { return m_routing; }
222    
223            void clear() { m_routing.clear(); }
224    
225    public slots:
226    
227            void refresh(Device *pDevice,
228                    const ChannelRoutingMap& routing);
229    
230    private:
231    
232            Device *m_pDevice;
233            ChannelRoutingMap m_routing;
234    };
235    
236    
237    //-------------------------------------------------------------------------
238    // QSampler::ChannelRoutingDelegate - table cell renderer for audio routing
239    //
240    
241    class ChannelRoutingDelegate : public QItemDelegate
242    {
243            Q_OBJECT
244    
245    public:
246    
247            ChannelRoutingDelegate(QObject* pParent = NULL);
248    
249            QWidget* createEditor(QWidget *pParent,
250                    const QStyleOptionViewItem& option, const QModelIndex& index) const;
251            void setEditorData(QWidget *pEditor, const QModelIndex& index) const;
252            void setModelData(QWidget *pEditor, QAbstractItemModel* model,
253                    const QModelIndex& index) const;
254            void updateEditorGeometry(QWidget *pEditor,
255                    const QStyleOptionViewItem& option, const QModelIndex& index) const;
256    };
257    
258    } // namespace QSampler
259    
260    // So we can use it i.e. through QVariant
261    Q_DECLARE_METATYPE(QSampler::ChannelRoutingItem)
262    
263  #endif  // __qsamplerChannel_h  #endif  // __qsamplerChannel_h
264    
265    

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

  ViewVC Help
Powered by ViewVC