/[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 759 by capela, Sun Aug 28 11:44:10 2005 UTC revision 3518 by capela, Sun Jun 30 16:58:30 2019 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-2019, 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 <qtable.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 qsamplerDevice;  namespace QSampler {
 class qsamplerMainForm;  
35    
36    class Device;
37    
38  // Typedef'd QMap.  // Typedef'd QMap.
39  typedef QMap<int, int> qsamplerChannelRoutingMap;  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();
   
         // Main application form accessor.  
         qsamplerMainForm *mainForm() const;  
   
         // Main application options accessor.  
         qsamplerOptions *options() const;  
   
         // LSCP client descriptor accessor.  
         lscp_client_t * client() const;  
54    
55          // Add/remove sampler channel methods.          // Add/remove sampler channel methods.
56          bool     addChannel();          bool     addChannel();
# Line 101  public: Line 94  public:
94          int      midiChannel() const;          int      midiChannel() const;
95          bool     setMidiChannel(int iMidiChannel);          bool     setMidiChannel(int iMidiChannel);
96    
97            // MIDI instrument map.
98            int      midiMap() const;
99            bool     setMidiMap(int iMidiMap);
100    
101          // Audio output driver (DEPRECATED).          // Audio output driver (DEPRECATED).
102          const QString& audioDriver() const;          const QString& audioDriver() const;
103          bool     setAudioDriver(const QString& sAudioDriver);          bool     setAudioDriver(const QString& sAudioDriver);
# Line 125  public: Line 122  public:
122          int      audioChannel(int iAudioOut) const;          int      audioChannel(int iAudioOut) const;
123          bool     setAudioChannel(int iAudioOut, int iAudioIn);          bool     setAudioChannel(int iAudioOut, int iAudioIn);
124          // The audio routing map itself.          // The audio routing map itself.
125          const qsamplerChannelRoutingMap& audioRouting() const;          const ChannelRoutingMap& audioRouting() const;
126    
127          // Istrument name remapper.          // Istrument name remapper.
128          void     updateInstrumentName();          void     updateInstrumentName();
# Line 139  public: Line 136  public:
136          // Reset channel method.          // Reset channel method.
137          bool     channelReset();          bool     channelReset();
138    
139            // Spawn instrument editor method.
140            bool     editChannel();
141    
142          // Message logging methods (brainlessly mapped to main form's).          // Message logging methods (brainlessly mapped to main form's).
143          void     appendMessages       (const QString & s) const;          void     appendMessages       (const QString & s) const;
144          void     appendMessagesColor  (const QString & s, const QString & c) const;          void     appendMessagesColor  (const QString & s, const QString & c) const;
# Line 155  public: Line 155  public:
155          static QString loadingInstrument();          static QString loadingInstrument();
156    
157          // Check whether a given file is an instrument file.          // Check whether a given file is an instrument file.
158          static bool isInstrumentFile (const QString& sInstrumentFile);          static bool isDlsInstrumentFile (const QString& sInstrumentFile);
159            static bool isSf2InstrumentFile (const QString& sInstrumentFile);
160    
161          // Retrieve the available instrument name(s) of an instrument file (.gig).          // Retrieve the available instrument name(s) of an instrument file (.gig).
162          static QString getInstrumentName (const QString& sInstrumentFile,          static QString getInstrumentName (const QString& sInstrumentFile,
# Line 165  public: Line 166  public:
166    
167  private:  private:
168    
         // Main application form reference.  
         qsamplerMainForm *m_pMainForm;  
   
169          // Unique channel identifier.          // Unique channel identifier.
170          int     m_iChannelID;          int     m_iChannelID;
171    
# Line 181  private: Line 179  private:
179          int     m_iMidiDevice;          int     m_iMidiDevice;
180          int     m_iMidiPort;          int     m_iMidiPort;
181          int     m_iMidiChannel;          int     m_iMidiChannel;
182            int     m_iMidiMap;
183          QString m_sAudioDriver;          QString m_sAudioDriver;
184          int     m_iAudioDevice;          int     m_iAudioDevice;
185          float   m_fVolume;          float   m_fVolume;
# Line 188  private: Line 187  private:
187          bool    m_bSolo;          bool    m_bSolo;
188    
189          // The audio routing mapping.          // The audio routing mapping.
190          qsamplerChannelRoutingMap m_audioRouting;          ChannelRoutingMap m_audioRouting;
191  };  };
192    
193    
194  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
195  // qsamplerChannelRoutingTable - Channel routing table widget.  // QSampler::ChannelRoutingModel - data model for audio routing
196    //                                 (used for QTableView)
197  //  //
198    
199  class qsamplerChannelRoutingTable : public QTable  struct ChannelRoutingItem {
200            QStringList options;
201            int         selection;
202    };
203    
204    class ChannelRoutingModel : public QAbstractTableModel
205  {  {
206          Q_OBJECT          Q_OBJECT
   
207  public:  public:
208    
209          // Constructor.          ChannelRoutingModel(QObject* pParent = NULL);
210          qsamplerChannelRoutingTable(QWidget *pParent = 0, const char *pszName = 0);  
211          // Default destructor.          // overridden methods from subclass(es)
212          ~qsamplerChannelRoutingTable();          int rowCount(const QModelIndex& parent = QModelIndex()) const;
213            int columnCount(const QModelIndex& parent = QModelIndex()) const;
214            Qt::ItemFlags flags(const QModelIndex& index) const;
215            bool setData(const QModelIndex& index, const QVariant& value,
216                    int role = Qt::EditRole);
217            QVariant data(const QModelIndex &index, int role) const;
218            QVariant headerData(int section, Qt::Orientation orientation,
219                    int role = Qt::DisplayRole) const;
220    
221            // own methods
222            ChannelRoutingMap routingMap() const { return m_routing; }
223    
224          // Common parameter table renderer.          void clear() { m_routing.clear(); }
225          void refresh(qsamplerDevice *pDevice,  
226                  const qsamplerChannelRoutingMap& routing);  public slots:
227    
228            void refresh(Device *pDevice,
229                    const ChannelRoutingMap& routing);
230    
231    private:
232    
233            Device *m_pDevice;
234            ChannelRoutingMap m_routing;
235  };  };
236    
237    
238  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
239  // qsamplerChannelRoutingComboBox - Custom combo box for routing table.  // QSampler::ChannelRoutingDelegate - table cell renderer for audio routing
240  //  //
241    
242  class qsamplerChannelRoutingComboBox : public QTableItem  class ChannelRoutingDelegate : public QItemDelegate
243  {  {
244  public:          Q_OBJECT
   
         // Constructor.  
         qsamplerChannelRoutingComboBox(QTable *pTable,  
                 const QStringList& list, const QPixmap& pixmap);  
245    
246          // Public accessors.  public:
         void setCurrentItem(int iCurrentItem);  
         int currentItem() const;  
   
 protected:  
   
         // Virtual implemetations.  
         QWidget *createEditor() const;  
         void setContentFromEditor(QWidget *pWidget);  
247    
248  private:          ChannelRoutingDelegate(QObject* pParent = NULL);
249    
250          // Initial value holders          QWidget* createEditor(QWidget *pParent,
251          QStringList m_list;                  const QStyleOptionViewItem& option, const QModelIndex& index) const;
252          int m_iCurrentItem;          void setEditorData(QWidget *pEditor, const QModelIndex& index) const;
253            void setModelData(QWidget *pEditor, QAbstractItemModel* model,
254                    const QModelIndex& index) const;
255            void updateEditorGeometry(QWidget *pEditor,
256                    const QStyleOptionViewItem& option, const QModelIndex& index) const;
257  };  };
258    
259    } // namespace QSampler
260    
261    // So we can use it i.e. through QVariant
262    Q_DECLARE_METATYPE(QSampler::ChannelRoutingItem)
263    
264  #endif  // __qsamplerChannel_h  #endif  // __qsamplerChannel_h
265    

Legend:
Removed from v.759  
changed lines
  Added in v.3518

  ViewVC Help
Powered by ViewVC