--- qsampler/trunk/src/qsamplerDevice.h 2005/03/10 15:48:38 442 +++ qsampler/trunk/src/qsamplerDevice.h 2006/12/03 18:26:13 961 @@ -1,7 +1,7 @@ // qsamplerDevice.h // /**************************************************************************** - Copyright (C) 2005, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2006, rncbc aka Rui Nuno Capela. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *****************************************************************************/ @@ -34,6 +34,10 @@ // Special QListViewItem::rtti() unique return value. #define QSAMPLER_DEVICE_ITEM 1001 +// Early forward declarations. +class qsamplerMainForm; +class qsamplerDevicePort; + //------------------------------------------------------------------------- // qsamplerDeviceParam - MIDI/Audio Device parameter structure. @@ -67,9 +71,12 @@ QString value; }; -// A typedef'd parameter QMap. +// Typedef'd parameter QMap. typedef QMap qsamplerDeviceParamMap; +// Typedef'd device port/channels QptrList. +typedef QPtrList qsamplerDevicePortList; + //------------------------------------------------------------------------- // qsamplerDevice - MIDI/Audio Device structure. @@ -83,31 +90,52 @@ enum qsamplerDeviceType { None, Midi, Audio }; // Constructor. - qsamplerDevice(lscp_client_t *pClient, - qsamplerDeviceType deviceType, int iDeviceID = -1); + qsamplerDevice(qsamplerDeviceType deviceType, int iDeviceID = -1); + // Copy constructor. + qsamplerDevice(const qsamplerDevice& device); // Default destructor. ~qsamplerDevice(); // Initializer. - void setDevice(lscp_client_t *pClient, - qsamplerDeviceType deviceType, int iDeviceID = -1); + void setDevice(qsamplerDeviceType deviceType, int iDeviceID = -1); // Driver name initializer. - void setDriver(lscp_client_t *pClient, - const QString& sDriverName); + void setDriver(const QString& sDriverName); // Device property accessors. int deviceID() const; qsamplerDeviceType deviceType() const; const QString& deviceTypeName() const; const QString& driverName() const; - const QString& deviceName() const; + // Special device name formatter. + QString deviceName() const; + + // Set the proper device parameter value. + bool setParam (const QString& sParam, const QString& sValue); // Device parameters accessor. - qsamplerDeviceParamMap& params(); + const qsamplerDeviceParamMap& params() const; + + // Device port/channel list accessor. + qsamplerDevicePortList& ports(); - // Update/refresh device/driver data. - void refresh(); + // Device parameter dependency list refreshner. + int refreshParams(); + // Device port/channel list refreshner. + int refreshPorts(); + // Refresh/set dependencies given that some parameter has changed. + int refreshDepends(const QString& sParam); + + // Create/destroy device methods. + bool createDevice(); + bool deleteDevice(); + + // Message logging methods (brainlessly mapped to main form's). + void appendMessages (const QString& s) const; + void appendMessagesColor (const QString& s, const QString & c) const; + void appendMessagesText (const QString& s) const; + void appendMessagesError (const QString& s) const; + void appendMessagesClient (const QString& s) const; // Device ids enumerator. static int *getDevices(lscp_client_t *pClient, @@ -119,6 +147,12 @@ private: + // Refresh/set given parameter based on driver supplied dependencies. + int refreshParam(const QString& sParam); + + // Main application form reference. + qsamplerMainForm *m_pMainForm; + // Instance variables. int m_iDeviceID; qsamplerDeviceType m_deviceType; @@ -128,6 +162,49 @@ // Device parameter list. qsamplerDeviceParamMap m_params; + + // Device port/channel list. + qsamplerDevicePortList m_ports; +}; + + +//------------------------------------------------------------------------- +// qsamplerDevicePort - MIDI/Audio Device port/channel structure. +// + +class qsamplerDevicePort +{ +public: + + // Constructor. + qsamplerDevicePort(qsamplerDevice& device, int iPortID); + // Default destructor. + ~qsamplerDevicePort(); + + // Initializer. + void setDevicePort(int iPortID); + + // Device port property accessors. + int portID() const; + const QString& portName() const; + + // Device port parameters accessor. + const qsamplerDeviceParamMap& params() const; + + // Set the proper device port/channel parameter value. + bool setParam (const QString& sParam, const QString& sValue); + +private: + + // Device reference. + qsamplerDevice& m_device; + + // Instance variables. + int m_iPortID; + QString m_sPortName; + + // Device port parameter list. + qsamplerDeviceParamMap m_params; }; @@ -140,9 +217,9 @@ public: // Constructors. - qsamplerDeviceItem(QListView *pListView, lscp_client_t *pClient, + qsamplerDeviceItem(QListView *pListView, qsamplerDevice::qsamplerDeviceType deviceType); - qsamplerDeviceItem(QListViewItem *pItem, lscp_client_t *pClient, + qsamplerDeviceItem(QListViewItem *pItem, qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID); // Default destructor. ~qsamplerDeviceItem(); @@ -175,8 +252,8 @@ // Default destructor. ~qsamplerDeviceParamTable(); - // Client/device descriptor selector. - void refresh(qsamplerDevice& device); + // Common parameter table renderer. + void refresh(const qsamplerDeviceParamMap& params, bool bEditable); }; @@ -189,7 +266,8 @@ public: // Constructor. - qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType); + qsamplerDeviceParamTableSpinBox (QTable *pTable, EditType editType, + const QString& sText); // Public accessors. void setMinValue(int iMinValue); @@ -205,9 +283,9 @@ private: // Initial value holders. + int m_iValue; int m_iMinValue; int m_iMaxValue; - int m_iValue; };