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

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

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

revision 426 by capela, Mon Mar 7 11:09:32 2005 UTC revision 462 by capela, Tue Mar 15 11:39:12 2005 UTC
# Line 1  Line 1 
1  // qsamplerDevice.h  // qsamplerDevice.h
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2005, 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 22  Line 22 
22  #ifndef __qsamplerDevice_h  #ifndef __qsamplerDevice_h
23  #define __qsamplerDevice_h  #define __qsamplerDevice_h
24    
25    #include <qlistview.h>
26  #include <qtable.h>  #include <qtable.h>
27    
28  #include <lscp/client.h>  #include <lscp/client.h>
# Line 30  Line 31 
31  #include "qsamplerOptions.h"  #include "qsamplerOptions.h"
32    
33    
34    // Special QListViewItem::rtti() unique return value.
35    #define QSAMPLER_DEVICE_ITEM    1001
36    
37    
38    //-------------------------------------------------------------------------
39    // qsamplerDeviceParam - MIDI/Audio Device parameter structure.
40    //
41    class qsamplerDeviceParam
42    {
43    public:
44    
45            // Constructor.
46            qsamplerDeviceParam(lscp_param_info_t *pParamInfo = NULL,
47                    const char *pszValue = NULL);
48            // Default destructor.
49            ~qsamplerDeviceParam();
50    
51            // Initializer.
52            void setParam(lscp_param_info_t *pParamInfo,
53                    const char *pszValue = NULL);
54    
55            // Info structure field members.
56            lscp_type_t     type;
57            QString         description;
58            bool            mandatory;
59            bool            fix;
60            bool            multiplicity;
61            QStringList depends;
62            QString         defaultv;
63            QString         range_min;
64            QString         range_max;
65            QStringList possibilities;
66            // The current parameter value.
67            QString         value;
68    };
69    
70    // A typedef'd parameter QMap.
71    typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;
72    
73    
74    //-------------------------------------------------------------------------
75    // qsamplerDevice - MIDI/Audio Device structure.
76    //
77    
78    class qsamplerDevice
79    {
80    public:
81    
82            // We use the same class for MIDI and audio device management
83            enum qsamplerDeviceType { None, Midi, Audio };
84    
85            // Constructor.
86            qsamplerDevice(lscp_client_t *pClient,
87                    qsamplerDeviceType deviceType, int iDeviceID = -1);
88            // Default destructor.
89            ~qsamplerDevice();
90    
91            // Initializer.
92            void setDevice(lscp_client_t *pClient,
93                    qsamplerDeviceType deviceType, int iDeviceID = -1);
94    
95            // Driver name initializer.
96            void setDriver(lscp_client_t *pClient,
97                    const QString& sDriverName);
98    
99            // Device property accessors.
100            int                 deviceID()   const;
101            qsamplerDeviceType  deviceType() const;
102            const QString&      deviceTypeName() const;
103            const QString&      driverName() const;
104            const QString&      deviceName() const;
105    
106            // Device parameters accessor.
107            const qsamplerDeviceParamMap& params() const;
108    
109            // Set the proper device parameter value.
110            void setParam (const QString& sParam, const QString& sValue);
111    
112            // Device ids enumerator.
113            static int *getDevices(lscp_client_t *pClient,
114                    qsamplerDeviceType deviceType);
115    
116            // Driver names enumerator.
117            static QStringList getDrivers(lscp_client_t *pClient,
118                    qsamplerDeviceType deviceType);
119    
120    private:
121    
122            // Instance variables.
123            int                m_iDeviceID;
124            qsamplerDeviceType m_deviceType;
125            QString            m_sDeviceType;
126            QString            m_sDriverName;
127            QString            m_sDeviceName;
128    
129            // Device parameter list.
130            qsamplerDeviceParamMap m_params;
131    };
132    
133    
134    //-------------------------------------------------------------------------
135    // qsamplerDevicePort - MIDI/Audio Device port/channel structure.
136    //
137    
138    class qsamplerDevicePort
139    {
140    public:
141    
142            // Constructor.
143            qsamplerDevicePort(lscp_client_t *pClient,
144                    const qsamplerDevice& device, int iPortID);
145            // Default destructor.
146            ~qsamplerDevicePort();
147    
148            // Initializer.
149            void setDevicePort(lscp_client_t *pClient,
150                    const qsamplerDevice& device, int iPortID);
151    
152            // Device port property accessors.
153            int            portID()   const;
154            const QString& portName() const;
155    
156            // Device port parameters accessor.
157            const qsamplerDeviceParamMap& params() const;
158    
159            // Set the proper device port/channel parameter value.
160            void setParam (const QString& sParam, const QString& sValue);
161    
162    private:
163    
164            // Instance variables.
165            int     m_iPortID;
166            QString m_sPortName;
167    
168            // Device port parameter list.
169            qsamplerDeviceParamMap m_params;
170    };
171    
172    
173    //-------------------------------------------------------------------------
174    // qsamplerDeviceItem - QListView device item.
175    //
176    
177    class qsamplerDeviceItem : public QListViewItem
178    {
179    public:
180    
181            // Constructors.
182            qsamplerDeviceItem(QListView *pListView, lscp_client_t *pClient,
183                    qsamplerDevice::qsamplerDeviceType deviceType);
184            qsamplerDeviceItem(QListViewItem *pItem, lscp_client_t *pClient,
185                    qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID);
186            // Default destructor.
187            ~qsamplerDeviceItem();
188    
189            // Instance accessors.
190            qsamplerDevice& device();
191    
192            // To virtually distinguish between list view items.
193            virtual int rtti() const;
194    
195    private:
196    
197            // Instance variables.
198            qsamplerDevice m_device;
199    };
200    
201    
202  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
203  // qsamplerDeviceParameterTable - Device parameter view table.  // qsamplerDeviceParamTable - Device parameter view table.
204  //  //
205    
206  class qsamplerDeviceParameterTable : public QTable  class qsamplerDeviceParamTable : public QTable
207  {  {
208      Q_OBJECT          Q_OBJECT
209    
210  public:  public:
211    
212      // Constructor.          // Constructor.
213      qsamplerDeviceParameterTable(QWidget *pParent = 0, const char *pszName = 0);          qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0);
214      // Default destructor.          // Default destructor.
215      ~qsamplerDeviceParameterTable();          ~qsamplerDeviceParamTable();
216    
217      // LSCP client descriptor accessor.          // Common parameter table renderer.
218      void setClient(lscp_client_t *pClient);          void refresh(const qsamplerDeviceParamMap& params, bool bEditable);
219      lscp_client_t * client();  };
220    
221    
222    //-------------------------------------------------------------------------
223    // qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table.
224    //
225    
226    class qsamplerDeviceParamTableSpinBox : public QTableItem
227    {
228    public:
229    
230            // Constructor.
231            qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType,
232                    const QString& sText);
233    
234            // Public accessors.
235            void setMinValue(int iMinValue);
236            void setMaxValue(int iMaxValue);
237            void setValue(int iValue);
238    
239    protected:
240    
241            // Virtual implemetations.
242            QWidget *createEditor() const;
243            void setContentFromEditor(QWidget *pWidget);
244    
245  private:  private:
246    
247      // LSCP client reference.          // Initial value holders.
248      lscp_client_t *m_pClient;          int m_iValue;
249            int m_iMinValue;
250            int m_iMaxValue;
251    };
252    
253    
254    //-------------------------------------------------------------------------
255    // qsamplerDeviceParamTableEditBox - Custom edit box for parameter table.
256    //
257    
258    class qsamplerDeviceParamTableEditBox : public QTableItem
259    {
260    public:
261    
262            // Constructor.
263            qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType,
264                    const QString& sText);
265    
266    protected:
267    
268            // Virtual implemetations.
269            QWidget *createEditor() const;
270            void setContentFromEditor(QWidget *pWidget);
271  };  };
272    
273    

Legend:
Removed from v.426  
changed lines
  Added in v.462

  ViewVC Help
Powered by ViewVC