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

Legend:
Removed from v.430  
changed lines
  Added in v.961

  ViewVC Help
Powered by ViewVC