50 |
const char *pszValue ) |
const char *pszValue ) |
51 |
{ |
{ |
52 |
if (pParamInfo == NULL) |
if (pParamInfo == NULL) |
53 |
return; |
return; |
54 |
|
|
55 |
// Info structure field members. |
// Info structure field members. |
56 |
|
|
57 |
type = pParamInfo->type; |
type = pParamInfo->type; |
58 |
|
|
59 |
if (pParamInfo->description) |
if (pParamInfo->description) |
60 |
description = pParamInfo->description; |
description = pParamInfo->description; |
61 |
else |
else |
62 |
description = QString::null; |
description = QString::null; |
63 |
|
|
64 |
mandatory = (bool) pParamInfo->multiplicity; |
mandatory = (bool) pParamInfo->multiplicity; |
65 |
fix = (bool) pParamInfo->fix; |
fix = (bool) pParamInfo->fix; |
66 |
multiplicity = (bool) pParamInfo->multiplicity; |
multiplicity = (bool) pParamInfo->multiplicity; |
67 |
|
|
68 |
depends.clear(); |
depends.clear(); |
69 |
for (int i = 0; pParamInfo->depends && pParamInfo->depends[i]; i++) |
for (int i = 0; pParamInfo->depends && pParamInfo->depends[i]; i++) |
70 |
depends.append(pParamInfo->depends[i]); |
depends.append(pParamInfo->depends[i]); |
71 |
|
|
72 |
if (pParamInfo->defaultv) |
if (pParamInfo->defaultv) |
73 |
defaultv = pParamInfo->defaultv; |
defaultv = pParamInfo->defaultv; |
74 |
else |
else |
75 |
defaultv = QString::null; |
defaultv = QString::null; |
76 |
|
|
77 |
if (pParamInfo->range_min) |
if (pParamInfo->range_min) |
78 |
range_min = pParamInfo->range_min; |
range_min = pParamInfo->range_min; |
79 |
else |
else |
80 |
range_min = QString::null; |
range_min = QString::null; |
81 |
|
|
82 |
if (pParamInfo->range_max) |
if (pParamInfo->range_max) |
83 |
range_max = pParamInfo->range_max; |
range_max = pParamInfo->range_max; |
84 |
else |
else |
85 |
range_max = QString::null; |
range_max = QString::null; |
86 |
|
|
87 |
possibilities.clear(); |
possibilities.clear(); |
88 |
for (int i = 0; pParamInfo->possibilities && pParamInfo->possibilities[i]; i++) |
for (int i = 0; pParamInfo->possibilities && pParamInfo->possibilities[i]; i++) |
89 |
possibilities.append(pParamInfo->possibilities[i]); |
possibilities.append(pParamInfo->possibilities[i]); |
90 |
|
|
91 |
// The current parameter value. |
// The current parameter value. |
92 |
if (pszValue) |
if (pszValue) |
93 |
value = pszValue; |
value = pszValue; |
94 |
else |
else |
95 |
value = QString::null; |
value = QString::null; |
96 |
} |
} |
125 |
QString sDeviceType; |
QString sDeviceType; |
126 |
lscp_device_info_t *pDeviceInfo = NULL; |
lscp_device_info_t *pDeviceInfo = NULL; |
127 |
switch (deviceType) { |
switch (deviceType) { |
128 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
129 |
sDeviceType = QObject::tr("Audio"); |
sDeviceType = QObject::tr("Audio"); |
130 |
pDeviceInfo = ::lscp_get_audio_device_info(pClient, iDeviceID); |
pDeviceInfo = ::lscp_get_audio_device_info(pClient, iDeviceID); |
131 |
break; |
break; |
132 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
133 |
sDeviceType = QObject::tr("MIDI"); |
sDeviceType = QObject::tr("MIDI"); |
134 |
pDeviceInfo = ::lscp_get_midi_device_info(pClient, iDeviceID); |
pDeviceInfo = ::lscp_get_midi_device_info(pClient, iDeviceID); |
135 |
break; |
break; |
136 |
} |
} |
137 |
|
|
138 |
// If we're bogus, bail out... |
// If we're bogus, bail out... |
139 |
if (pDeviceInfo == NULL) { |
if (pDeviceInfo == NULL) { |
140 |
m_sDriverName = QString::null; |
m_sDriverName = QString::null; |
141 |
m_sDeviceName = QObject::tr("New %1 device").arg(sDeviceType); |
m_sDeviceName = QObject::tr("New %1 device").arg(sDeviceType); |
142 |
return; |
return; |
143 |
} |
} |
144 |
|
|
145 |
// Other device properties... |
// Other device properties... |
146 |
m_sDriverName = pDeviceInfo->driver; |
m_sDriverName = pDeviceInfo->driver; |
147 |
m_sDeviceName = m_sDriverName + ' ' |
m_sDeviceName = m_sDriverName + ' ' |
148 |
+ QObject::tr("Device %1").arg(m_iDeviceID); |
+ QObject::tr("Device %1").arg(m_iDeviceID); |
149 |
|
|
150 |
// Grab device/driver parameters... |
// Grab device parameters... |
151 |
m_params.clear(); |
m_params.clear(); |
152 |
for (int i = 0; pDeviceInfo->params && pDeviceInfo->params[i].key; i++) { |
for (int i = 0; pDeviceInfo->params && pDeviceInfo->params[i].key; i++) { |
153 |
const char *pszParam = pDeviceInfo->params[i].key; |
const char *pszParam = pDeviceInfo->params[i].key; |
154 |
lscp_param_info_t *pParamInfo = NULL; |
lscp_param_info_t *pParamInfo = NULL; |
155 |
switch (deviceType) { |
switch (deviceType) { |
156 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
157 |
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
158 |
m_sDriverName.latin1(), pszParam, NULL); |
m_sDriverName.latin1(), pszParam, NULL); |
159 |
break; |
break; |
160 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
161 |
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
162 |
m_sDriverName.latin1(), pszParam, NULL); |
m_sDriverName.latin1(), pszParam, NULL); |
163 |
break; |
break; |
164 |
} |
} |
167 |
} |
} |
168 |
|
|
169 |
|
|
170 |
|
// Driver name initializer. |
171 |
|
void qsamplerDevice::setDriver ( lscp_client_t *pClient, |
172 |
|
const QString& sDriverName ) |
173 |
|
{ |
174 |
|
// Valid only for scratch devices. |
175 |
|
if (m_sDriverName == sDriverName) |
176 |
|
return; |
177 |
|
|
178 |
|
// Retrieve driver info, if any. |
179 |
|
lscp_driver_info_t *pDriverInfo = NULL; |
180 |
|
switch (m_deviceType) { |
181 |
|
case qsamplerDevice::Audio: |
182 |
|
pDriverInfo = ::lscp_get_audio_driver_info(pClient, |
183 |
|
sDriverName.latin1()); |
184 |
|
break; |
185 |
|
case qsamplerDevice::Midi: |
186 |
|
pDriverInfo = ::lscp_get_midi_driver_info(pClient, |
187 |
|
sDriverName.latin1()); |
188 |
|
break; |
189 |
|
} |
190 |
|
|
191 |
|
// If we're bogus, bail out... |
192 |
|
if (pDriverInfo == NULL) |
193 |
|
return; |
194 |
|
|
195 |
|
// Remember device parameters... |
196 |
|
m_sDriverName = sDriverName; |
197 |
|
|
198 |
|
// Grab driver parameters... |
199 |
|
m_params.clear(); |
200 |
|
for (int i = 0; pDriverInfo->parameters && pDriverInfo->parameters[i]; i++) { |
201 |
|
const char *pszParam = pDriverInfo->parameters[i]; |
202 |
|
lscp_param_info_t *pParamInfo = NULL; |
203 |
|
switch (m_deviceType) { |
204 |
|
case qsamplerDevice::Audio: |
205 |
|
pParamInfo = ::lscp_get_audio_driver_param_info(pClient, |
206 |
|
sDriverName.latin1(), pszParam, NULL); |
207 |
|
break; |
208 |
|
case qsamplerDevice::Midi: |
209 |
|
pParamInfo = ::lscp_get_midi_driver_param_info(pClient, |
210 |
|
sDriverName.latin1(), pszParam, NULL); |
211 |
|
break; |
212 |
|
} |
213 |
|
m_params[pszParam] = qsamplerDeviceParam(pParamInfo, pParamInfo->defaultv); |
214 |
|
} |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
// Device property accessors. |
// Device property accessors. |
219 |
int qsamplerDevice::deviceID (void) const |
int qsamplerDevice::deviceID (void) const |
220 |
{ |
{ |
254 |
{ |
{ |
255 |
int *piDeviceIDs = NULL; |
int *piDeviceIDs = NULL; |
256 |
switch (deviceType) { |
switch (deviceType) { |
257 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
258 |
piDeviceIDs = ::lscp_list_audio_devices(pClient); |
piDeviceIDs = ::lscp_list_audio_devices(pClient); |
259 |
break; |
break; |
260 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
261 |
piDeviceIDs = ::lscp_list_midi_devices(pClient); |
piDeviceIDs = ::lscp_list_midi_devices(pClient); |
262 |
break; |
break; |
263 |
} |
} |
264 |
return piDeviceIDs; |
return piDeviceIDs; |
273 |
|
|
274 |
const char **ppszDrivers = NULL; |
const char **ppszDrivers = NULL; |
275 |
switch (deviceType) { |
switch (deviceType) { |
276 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
277 |
ppszDrivers = ::lscp_get_available_audio_drivers(pClient); |
ppszDrivers = ::lscp_get_available_audio_drivers(pClient); |
278 |
break; |
break; |
279 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
280 |
ppszDrivers = ::lscp_get_available_midi_drivers(pClient); |
ppszDrivers = ::lscp_get_available_midi_drivers(pClient); |
281 |
break; |
break; |
282 |
} |
} |
283 |
|
|
284 |
for (int iDriver = 0; ppszDrivers[iDriver]; iDriver++) |
for (int iDriver = 0; ppszDrivers[iDriver]; iDriver++) |
285 |
drivers.append(ppszDrivers[iDriver]); |
drivers.append(ppszDrivers[iDriver]); |
286 |
|
|
287 |
return drivers; |
return drivers; |
288 |
} |
} |
298 |
: QListViewItem(pListView), m_device(pClient, deviceType) |
: QListViewItem(pListView), m_device(pClient, deviceType) |
299 |
{ |
{ |
300 |
switch(m_device.deviceType()) { |
switch(m_device.deviceType()) { |
301 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
302 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio1.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio1.png")); |
303 |
QListViewItem::setText(0, QObject::tr("Audio devices")); |
QListViewItem::setText(0, QObject::tr("Audio devices")); |
304 |
break; |
break; |
305 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
306 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi1.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi1.png")); |
307 |
QListViewItem::setText(0, QObject::tr("MIDI devices")); |
QListViewItem::setText(0, QObject::tr("MIDI devices")); |
308 |
break; |
break; |
314 |
: QListViewItem(pItem), m_device(pClient, deviceType, iDeviceID) |
: QListViewItem(pItem), m_device(pClient, deviceType, iDeviceID) |
315 |
{ |
{ |
316 |
switch(m_device.deviceType()) { |
switch(m_device.deviceType()) { |
317 |
case qsamplerDevice::Audio: |
case qsamplerDevice::Audio: |
318 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio2.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("audio2.png")); |
319 |
break; |
break; |
320 |
case qsamplerDevice::Midi: |
case qsamplerDevice::Midi: |
321 |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi2.png")); |
QListViewItem::setPixmap(0, QPixmap::fromMimeSource("midi2.png")); |
322 |
break; |
break; |
323 |
} |
} |
331 |
} |
} |
332 |
|
|
333 |
// Instance accessors. |
// Instance accessors. |
334 |
const qsamplerDevice& qsamplerDeviceItem::device (void) |
qsamplerDevice& qsamplerDeviceItem::device (void) |
335 |
{ |
{ |
336 |
return m_device; |
return m_device; |
337 |
} |
} |
352 |
qsamplerDeviceParamTable::qsamplerDeviceParamTable ( QWidget *pParent, const char *pszName ) |
qsamplerDeviceParamTable::qsamplerDeviceParamTable ( QWidget *pParent, const char *pszName ) |
353 |
: QTable(pParent, pszName) |
: QTable(pParent, pszName) |
354 |
{ |
{ |
|
m_pClient = NULL; |
|
|
m_iDeviceID = -1; |
|
|
|
|
355 |
// Set fixed number of columns. |
// Set fixed number of columns. |
356 |
QTable::setNumCols(3); |
QTable::setNumCols(3); |
357 |
QTable::setShowGrid(false); |
QTable::setShowGrid(false); |
364 |
// Initialize the fixed table column headings. |
// Initialize the fixed table column headings. |
365 |
QHeader *pHeader = QTable::horizontalHeader(); |
QHeader *pHeader = QTable::horizontalHeader(); |
366 |
pHeader->setLabel(0, tr("Parameter")); |
pHeader->setLabel(0, tr("Parameter")); |
367 |
pHeader->setLabel(1, tr("Description")); |
pHeader->setLabel(1, tr("Value")); |
368 |
pHeader->setLabel(2, tr("Value")); |
pHeader->setLabel(2, tr("Description")); |
369 |
// Set read-onlyness of each column |
// Set read-onlyness of each column |
370 |
QTable::setColumnReadOnly(0, true); |
QTable::setColumnReadOnly(0, true); |
371 |
QTable::setColumnReadOnly(1, true); |
// QTable::setColumnReadOnly(1, true); -- of course not. |
372 |
// QTable::setColumnReadOnly(2, true); -- of course not. |
QTable::setColumnReadOnly(2, true); |
373 |
} |
} |
374 |
|
|
375 |
// Default destructor. |
// Default destructor. |
378 |
} |
} |
379 |
|
|
380 |
|
|
|
// Client/device descriptor selector. |
|
|
void qsamplerDeviceParamTable::setDevice ( lscp_client_t *pClient, |
|
|
qsamplerDevice::qsamplerDeviceType deviceType, int iDeviceID ) |
|
|
{ |
|
|
if (m_pClient |
|
|
&& m_pClient == pClient |
|
|
&& m_deviceType == deviceType |
|
|
&& m_iDeviceID == iDeviceID) |
|
|
return; |
|
|
|
|
|
m_pClient = pClient; |
|
|
m_deviceType = deviceType; |
|
|
m_iDeviceID = iDeviceID; |
|
|
|
|
|
refresh(); |
|
|
} |
|
|
|
|
|
|
|
|
// Client/device descriptor accessors. |
|
|
lscp_client_t *qsamplerDeviceParamTable::client (void) |
|
|
{ |
|
|
return m_pClient; |
|
|
} |
|
|
|
|
|
int qsamplerDeviceParamTable::deviceID (void) |
|
|
{ |
|
|
return m_iDeviceID; |
|
|
} |
|
|
|
|
|
|
|
381 |
// The main table refresher. |
// The main table refresher. |
382 |
void qsamplerDeviceParamTable::refresh (void) |
void qsamplerDeviceParamTable::refresh ( qsamplerDevice& device ) |
383 |
{ |
{ |
384 |
// Always (re)start it empty. |
// Always (re)start it empty. |
385 |
QTable::setNumRows(0); |
QTable::setNumRows(0); |
386 |
|
|
|
if (m_pClient == NULL) |
|
|
return; |
|
|
|
|
|
// Construct the local device object here. |
|
|
qsamplerDevice device(m_pClient, m_deviceType, m_iDeviceID); |
|
|
|
|
|
|
|
387 |
// Now fill the parameter table... |
// Now fill the parameter table... |
388 |
QHeader *pHeader = QTable::verticalHeader(); |
qsamplerDeviceParamMap& params = device.params(); |
|
qsamplerDeviceParamMap& params = device.params(); |
|
389 |
QTable::insertRows(0, params.count()); |
QTable::insertRows(0, params.count()); |
390 |
int iRow = 0; |
int iRow = 0; |
391 |
qsamplerDeviceParamMap::Iterator iter; |
qsamplerDeviceParamMap::ConstIterator iter; |
392 |
for (iter = params.begin(); iter != params.end(); ++iter) { |
for (iter = params.begin(); iter != params.end(); ++iter) { |
393 |
QTable::setText(iRow, 0, iter.key()); |
QTable::setText(iRow, 0, iter.key()); |
394 |
QTable::setText(iRow, 1, iter.data().description); |
QTable::setText(iRow, 1, iter.data().value); |
395 |
QTable::setText(iRow, 2, iter.data().value); |
QTable::setText(iRow, 2, iter.data().description); |
396 |
++iRow; |
++iRow; |
397 |
} |
} |
398 |
|
|
399 |
// Adjust optimal column width. |
// Adjust optimal column width. |