/[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 492 by capela, Sat Apr 2 12:23:18 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    // Early forward declarations.
38    class qsamplerMainForm;
39    class qsamplerDevicePort;
40    
41    
42    //-------------------------------------------------------------------------
43    // qsamplerDeviceParam - MIDI/Audio Device parameter structure.
44    //
45    class qsamplerDeviceParam
46    {
47    public:
48    
49            // Constructor.
50            qsamplerDeviceParam(lscp_param_info_t *pParamInfo = NULL,
51                    const char *pszValue = NULL);
52            // Default destructor.
53            ~qsamplerDeviceParam();
54    
55            // Initializer.
56            void setParam(lscp_param_info_t *pParamInfo,
57                    const char *pszValue = NULL);
58    
59            // Info structure field members.
60            lscp_type_t     type;
61            QString         description;
62            bool            mandatory;
63            bool            fix;
64            bool            multiplicity;
65            QStringList depends;
66            QString         defaultv;
67            QString         range_min;
68            QString         range_max;
69            QStringList possibilities;
70            // The current parameter value.
71            QString         value;
72    };
73    
74    // Typedef'd parameter QMap.
75    typedef QMap<QString, qsamplerDeviceParam> qsamplerDeviceParamMap;
76    
77    // Typedef'd device port/channels QptrList.
78    typedef QPtrList<qsamplerDevicePort> qsamplerDevicePortList;
79    
80    
81    //-------------------------------------------------------------------------
82    // qsamplerDevice - MIDI/Audio Device structure.
83    //
84    
85    class qsamplerDevice
86    {
87    public:
88    
89            // We use the same class for MIDI and audio device management
90            enum qsamplerDeviceType { None, Midi, Audio };
91    
92            // Constructor.
93            qsamplerDevice(qsamplerMainForm *pMainForm,
94                    qsamplerDeviceType deviceType, int iDeviceID = -1);
95            // Copy constructor.
96        qsamplerDevice(const qsamplerDevice& device);
97            // Default destructor.
98            ~qsamplerDevice();
99    
100            // Initializer.
101            void setDevice(qsamplerDeviceType deviceType, int iDeviceID = -1);
102    
103            // Driver name initializer.
104            void setDriver(const QString& sDriverName);
105    
106            // LSCP client descriptor accessor.
107            lscp_client_t *client() const;
108    
109            // Device property accessors.
110            int                 deviceID()   const;
111            qsamplerDeviceType  deviceType() const;
112            const QString&      deviceTypeName() const;
113            const QString&      driverName() const;
114            // Special device name formatter.
115            QString deviceName() const;
116    
117            // Set the proper device parameter value.
118            bool setParam (const QString& sParam, const QString& sValue);
119    
120            // Device parameters accessor.
121            const qsamplerDeviceParamMap& params() const;
122    
123            // Device port/channel list accessor.
124            qsamplerDevicePortList& ports();
125    
126            // Device parameter dependency list refreshner.
127            int refreshParams();
128            // Device port/channel list refreshner.
129            int refreshPorts();
130            // Refresh/set dependencies given that some parameter has changed.
131            int refreshDepends(const QString& sParam);
132    
133            // Create/destroy device methods.
134            bool createDevice();
135            bool deleteDevice();
136    
137            // Message logging methods (brainlessly mapped to main form's).
138            void appendMessages       (const QString& s) const;
139            void appendMessagesColor  (const QString& s, const QString & c) const;
140            void appendMessagesText   (const QString& s) const;
141            void appendMessagesError  (const QString& s) const;
142            void appendMessagesClient (const QString& s) const;
143    
144            // Device ids enumerator.
145            static int *getDevices(lscp_client_t *pClient,
146                    qsamplerDeviceType deviceType);
147    
148            // Driver names enumerator.
149            static QStringList getDrivers(lscp_client_t *pClient,
150                    qsamplerDeviceType deviceType);
151    
152    private:
153    
154            // Refresh/set given parameter based on driver supplied dependencies.
155            int refreshParam(const QString& sParam);
156    
157            // Main application form reference.
158            qsamplerMainForm  *m_pMainForm;
159    
160            // Instance variables.
161            int                m_iDeviceID;
162            qsamplerDeviceType m_deviceType;
163            QString            m_sDeviceType;
164            QString            m_sDriverName;
165            QString            m_sDeviceName;
166    
167            // Device parameter list.
168            qsamplerDeviceParamMap m_params;
169    
170            // Device port/channel list.
171            qsamplerDevicePortList m_ports;
172    };
173    
174    
175    //-------------------------------------------------------------------------
176    // qsamplerDevicePort - MIDI/Audio Device port/channel structure.
177    //
178    
179    class qsamplerDevicePort
180    {
181    public:
182    
183            // Constructor.
184            qsamplerDevicePort(qsamplerDevice& device, int iPortID);
185            // Default destructor.
186            ~qsamplerDevicePort();
187    
188            // Initializer.
189            void setDevicePort(int iPortID);
190    
191            // Device port property accessors.
192            int            portID()   const;
193            const QString& portName() const;
194    
195            // Device port parameters accessor.
196            const qsamplerDeviceParamMap& params() const;
197    
198            // Set the proper device port/channel parameter value.
199            bool setParam (const QString& sParam, const QString& sValue);
200    
201    private:
202    
203            // Device reference.
204            qsamplerDevice& m_device;
205    
206            // Instance variables.
207            int     m_iPortID;
208            QString m_sPortName;
209    
210            // Device port parameter list.
211            qsamplerDeviceParamMap m_params;
212    };
213    
214    
215  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
216  // qsamplerDeviceParameterTable - Device parameter view table.  // qsamplerDeviceItem - QListView device item.
217  //  //
218    
219  class qsamplerDeviceParameterTable : public QTable  class qsamplerDeviceItem : public QListViewItem
220  {  {
221      Q_OBJECT  public:
222    
223            // Constructors.
224            qsamplerDeviceItem(QListView *pListView, qsamplerMainForm *pMainForm,
225                    qsamplerDevice::qsamplerDeviceType deviceType);
226            qsamplerDeviceItem(QListViewItem *pItem, qsamplerMainForm *pMainForm,
227                    qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID);
228            // Default destructor.
229            ~qsamplerDeviceItem();
230    
231            // Instance accessors.
232            qsamplerDevice& device();
233    
234            // To virtually distinguish between list view items.
235            virtual int rtti() const;
236    
237    private:
238    
239            // Instance variables.
240            qsamplerDevice m_device;
241    };
242    
243    
244    //-------------------------------------------------------------------------
245    // qsamplerDeviceParamTable - Device parameter view table.
246    //
247    
248    class qsamplerDeviceParamTable : public QTable
249    {
250            Q_OBJECT
251    
252  public:  public:
253    
254      // Constructor.          // Constructor.
255      qsamplerDeviceParameterTable(QWidget *pParent = 0, const char *pszName = 0);          qsamplerDeviceParamTable(QWidget *pParent = 0, const char *pszName = 0);
256      // Default destructor.          // Default destructor.
257      ~qsamplerDeviceParameterTable();          ~qsamplerDeviceParamTable();
258    
259            // Common parameter table renderer.
260            void refresh(const qsamplerDeviceParamMap& params, bool bEditable);
261    };
262    
263    
264    //-------------------------------------------------------------------------
265    // qsamplerDeviceParamTableSpinBox - Custom spin box for parameter table.
266    //
267    
268    class qsamplerDeviceParamTableSpinBox : public QTableItem
269    {
270    public:
271    
272      // LSCP client descriptor accessor.          // Constructor.
273      void setClient(lscp_client_t *pClient);          qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType,
274      lscp_client_t * client();                  const QString& sText);
275    
276            // Public accessors.
277            void setMinValue(int iMinValue);
278            void setMaxValue(int iMaxValue);
279            void setValue(int iValue);
280    
281    protected:
282    
283            // Virtual implemetations.
284            QWidget *createEditor() const;
285            void setContentFromEditor(QWidget *pWidget);
286    
287  private:  private:
288    
289      // LSCP client reference.          // Initial value holders.
290      lscp_client_t *m_pClient;          int m_iValue;
291            int m_iMinValue;
292            int m_iMaxValue;
293    };
294    
295    
296    //-------------------------------------------------------------------------
297    // qsamplerDeviceParamTableEditBox - Custom edit box for parameter table.
298    //
299    
300    class qsamplerDeviceParamTableEditBox : public QTableItem
301    {
302    public:
303    
304            // Constructor.
305            qsamplerDeviceParamTableEditBox (QTable *pTable, EditType editType,
306                    const QString& sText);
307    
308    protected:
309    
310            // Virtual implemetations.
311            QWidget *createEditor() const;
312            void setContentFromEditor(QWidget *pWidget);
313  };  };
314    
315    

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

  ViewVC Help
Powered by ViewVC