2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, 2008 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
25 |
|
|
26 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
27 |
|
|
28 |
|
#include "qsamplerChannelFxForm.h" |
29 |
|
|
30 |
|
#include <QMessageBox> |
31 |
#include <QDragEnterEvent> |
#include <QDragEnterEvent> |
32 |
#include <QUrl> |
#include <QUrl> |
33 |
|
|
|
#include <math.h> |
|
|
|
|
34 |
// Channel status/usage usage limit control. |
// Channel status/usage usage limit control. |
35 |
#define QSAMPLER_ERROR_LIMIT 3 |
#define QSAMPLER_ERROR_LIMIT 3 |
36 |
|
|
37 |
|
// Needed for lroundf() |
38 |
|
#include <math.h> |
39 |
|
|
40 |
|
#ifndef CONFIG_ROUND |
41 |
|
static inline long lroundf ( float x ) |
42 |
|
{ |
43 |
|
if (x >= 0.0f) |
44 |
|
return long(x + 0.5f); |
45 |
|
else |
46 |
|
return long(x - 0.5f); |
47 |
|
} |
48 |
|
#endif |
49 |
|
|
50 |
|
|
51 |
namespace QSampler { |
namespace QSampler { |
52 |
|
|
53 |
ChannelStrip::ChannelStrip(QWidget* parent, Qt::WFlags f) : QWidget(parent, f) { |
//------------------------------------------------------------------------- |
54 |
ui.setupUi(this); |
// QSampler::ChannelStrip -- Channel strip form implementation. |
55 |
|
// |
56 |
|
|
57 |
|
// Channel strip activation/selection. |
58 |
|
ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; |
59 |
|
|
60 |
|
ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags ) |
61 |
|
: QWidget(pParent, wflags) |
62 |
|
{ |
63 |
|
m_ui.setupUi(this); |
64 |
|
|
65 |
// Initialize locals. |
// Initialize locals. |
66 |
m_pChannel = NULL; |
m_pChannel = NULL; |
67 |
m_iDirtyChange = 0; |
m_iDirtyChange = 0; |
68 |
m_iErrorCount = 0; |
m_iErrorCount = 0; |
69 |
|
|
70 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
71 |
adjustSize(); |
adjustSize(); |
72 |
|
|
73 |
QObject::connect(ui.ChannelSetupPushButton, |
QObject::connect(m_ui.ChannelSetupPushButton, |
74 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
75 |
SLOT(channelSetup())); |
SLOT(channelSetup())); |
76 |
QObject::connect(ui.ChannelMutePushButton, |
QObject::connect(m_ui.ChannelMutePushButton, |
77 |
SIGNAL(toggled(bool)), |
SIGNAL(toggled(bool)), |
78 |
SLOT(channelMute(bool))); |
SLOT(channelMute(bool))); |
79 |
QObject::connect(ui.ChannelSoloPushButton, |
QObject::connect(m_ui.ChannelSoloPushButton, |
80 |
SIGNAL(toggled(bool)), |
SIGNAL(toggled(bool)), |
81 |
SLOT(channelSolo(bool))); |
SLOT(channelSolo(bool))); |
82 |
QObject::connect(ui.VolumeSlider, |
QObject::connect(m_ui.VolumeSlider, |
83 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
84 |
SLOT(volumeChanged(int))); |
SLOT(volumeChanged(int))); |
85 |
QObject::connect(ui.VolumeSpinBox, |
QObject::connect(m_ui.VolumeSpinBox, |
86 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
87 |
SLOT(volumeChanged(int))); |
SLOT(volumeChanged(int))); |
88 |
QObject::connect(ui.ChannelEditPushButton, |
QObject::connect(m_ui.ChannelEditPushButton, |
89 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
90 |
SLOT(channelEdit())); |
SLOT(channelEdit())); |
91 |
|
QObject::connect(m_ui.FxPushButton, |
92 |
|
SIGNAL(clicked()), |
93 |
|
SLOT(channelFxEdit())); |
94 |
|
|
95 |
|
setSelected(false); |
96 |
} |
} |
97 |
|
|
98 |
ChannelStrip::~ChannelStrip() { |
|
99 |
// Destroy existing channel descriptor. |
ChannelStrip::~ChannelStrip (void) |
100 |
if (m_pChannel) |
{ |
101 |
delete m_pChannel; |
setSelected(false); |
102 |
m_pChannel = NULL; |
|
103 |
|
// Destroy existing channel descriptor. |
104 |
|
if (m_pChannel) |
105 |
|
delete m_pChannel; |
106 |
|
m_pChannel = NULL; |
107 |
} |
} |
108 |
|
|
109 |
|
|
122 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
123 |
const QString& sFilename = iter.next().toLocalFile(); |
const QString& sFilename = iter.next().toLocalFile(); |
124 |
if (!sFilename.isEmpty()) { |
if (!sFilename.isEmpty()) { |
125 |
bAccept = qsamplerChannel::isInstrumentFile(sFilename); |
bAccept = Channel::isInstrumentFile(sFilename); |
126 |
break; |
break; |
127 |
} |
} |
128 |
} |
} |
163 |
|
|
164 |
|
|
165 |
// Channel strip setup formal initializer. |
// Channel strip setup formal initializer. |
166 |
void ChannelStrip::setup ( qsamplerChannel *pChannel ) |
void ChannelStrip::setup ( Channel *pChannel ) |
167 |
{ |
{ |
168 |
// Destroy any previous channel descriptor; |
// Destroy any previous channel descriptor; |
169 |
// (remember that once setup we own it!) |
// (remember that once setup we own it!) |
170 |
if (m_pChannel) |
if (m_pChannel) |
171 |
delete m_pChannel; |
delete m_pChannel; |
172 |
|
|
173 |
// Set the new one... |
// Set the new one... |
174 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
175 |
|
|
176 |
// Stabilize this around. |
// Stabilize this around. |
177 |
updateChannelInfo(); |
updateChannelInfo(); |
178 |
|
|
179 |
// We'll accept drops from now on... |
// We'll accept drops from now on... |
180 |
if (m_pChannel) |
if (m_pChannel) |
181 |
setAcceptDrops(true); |
setAcceptDrops(true); |
182 |
} |
} |
183 |
|
|
184 |
|
|
185 |
// Channel secriptor accessor. |
// Channel secriptor accessor. |
186 |
qsamplerChannel *ChannelStrip::channel (void) |
Channel *ChannelStrip::channel (void) const |
187 |
{ |
{ |
188 |
return m_pChannel; |
return m_pChannel; |
189 |
} |
} |
190 |
|
|
191 |
|
|
192 |
// Messages view font accessors. |
// Messages view font accessors. |
193 |
QFont ChannelStrip::displayFont (void) |
QFont ChannelStrip::displayFont (void) const |
194 |
{ |
{ |
195 |
return ui.EngineNameTextLabel->font(); |
return m_ui.EngineNameTextLabel->font(); |
196 |
} |
} |
197 |
|
|
198 |
void ChannelStrip::setDisplayFont ( const QFont & font ) |
void ChannelStrip::setDisplayFont ( const QFont & font ) |
199 |
{ |
{ |
200 |
ui.EngineNameTextLabel->setFont(font); |
m_ui.EngineNameTextLabel->setFont(font); |
201 |
ui.MidiPortChannelTextLabel->setFont(font); |
m_ui.MidiPortChannelTextLabel->setFont(font); |
202 |
ui.InstrumentNameTextLabel->setFont(font); |
m_ui.InstrumentNameTextLabel->setFont(font); |
203 |
ui.InstrumentStatusTextLabel->setFont(font); |
m_ui.InstrumentStatusTextLabel->setFont(font); |
204 |
} |
} |
205 |
|
|
206 |
|
|
208 |
void ChannelStrip::setDisplayEffect ( bool bDisplayEffect ) |
void ChannelStrip::setDisplayEffect ( bool bDisplayEffect ) |
209 |
{ |
{ |
210 |
QPalette pal; |
QPalette pal; |
211 |
|
pal.setColor(QPalette::Foreground, Qt::yellow); |
212 |
|
m_ui.EngineNameTextLabel->setPalette(pal); |
213 |
|
m_ui.MidiPortChannelTextLabel->setPalette(pal); |
214 |
pal.setColor(QPalette::Foreground, Qt::green); |
pal.setColor(QPalette::Foreground, Qt::green); |
215 |
if (bDisplayEffect) { |
if (bDisplayEffect) { |
216 |
QPixmap pm(":/icons/displaybg1.png"); |
QPixmap pm(":/icons/displaybg1.png"); |
218 |
} else { |
} else { |
219 |
pal.setColor(QPalette::Background, Qt::black); |
pal.setColor(QPalette::Background, Qt::black); |
220 |
} |
} |
221 |
ui.ChannelInfoFrame->setPalette(pal); |
m_ui.ChannelInfoFrame->setPalette(pal); |
222 |
ui.StreamVoiceCountTextLabel->setPalette(pal); |
m_ui.InstrumentNameTextLabel->setPalette(pal); |
223 |
|
m_ui.StreamVoiceCountTextLabel->setPalette(pal); |
224 |
} |
} |
225 |
|
|
226 |
|
|
227 |
// Maximum volume slider accessors. |
// Maximum volume slider accessors. |
228 |
void ChannelStrip::setMaxVolume ( int iMaxVolume ) |
void ChannelStrip::setMaxVolume ( int iMaxVolume ) |
229 |
{ |
{ |
230 |
m_iDirtyChange++; |
m_iDirtyChange++; |
231 |
ui.VolumeSlider->setRange(0, iMaxVolume); |
m_ui.VolumeSlider->setRange(0, iMaxVolume); |
232 |
ui.VolumeSpinBox->setRange(0, iMaxVolume); |
m_ui.VolumeSpinBox->setRange(0, iMaxVolume); |
233 |
m_iDirtyChange--; |
m_iDirtyChange--; |
234 |
} |
} |
235 |
|
|
236 |
|
|
291 |
m_pChannel->editChannel(); |
m_pChannel->editChannel(); |
292 |
} |
} |
293 |
|
|
294 |
|
bool ChannelStrip::channelFxEdit (void) |
295 |
|
{ |
296 |
|
MainForm *pMainForm = MainForm::getInstance(); |
297 |
|
if (!pMainForm || !channel()) |
298 |
|
return false; |
299 |
|
|
300 |
|
pMainForm->appendMessages(QObject::tr("channel fx sends...")); |
301 |
|
|
302 |
|
bool bResult = false; |
303 |
|
|
304 |
|
#if CONFIG_FXSEND |
305 |
|
ChannelFxForm *pChannelFxForm = |
306 |
|
new ChannelFxForm(channel(), parentWidget()); |
307 |
|
if (pChannelFxForm) { |
308 |
|
//pChannelForm->setup(this); |
309 |
|
bResult = pChannelFxForm->exec(); |
310 |
|
delete pChannelFxForm; |
311 |
|
} |
312 |
|
#else // CONFIG_FXSEND |
313 |
|
QMessageBox::critical(this, |
314 |
|
QSAMPLER_TITLE ": " + tr("Unavailable"), |
315 |
|
tr("Sorry, QSampler was built without FX send support!\n\n" |
316 |
|
"(Make sure you have a recent liblscp when recompiling QSampler)")); |
317 |
|
#endif // CONFIG_FXSEND |
318 |
|
|
319 |
|
return bResult; |
320 |
|
} |
321 |
|
|
322 |
// Channel reset slot. |
// Channel reset slot. |
323 |
bool ChannelStrip::channelReset (void) |
bool ChannelStrip::channelReset (void) |
347 |
|
|
348 |
// Instrument name... |
// Instrument name... |
349 |
if (m_pChannel->instrumentName().isEmpty()) { |
if (m_pChannel->instrumentName().isEmpty()) { |
350 |
if (m_pChannel->instrumentStatus() >= 0) |
if (m_pChannel->instrumentStatus() >= 0) { |
351 |
ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::loadingInstrument()); |
m_ui.InstrumentNameTextLabel->setText( |
352 |
else |
' ' + Channel::loadingInstrument()); |
353 |
ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName()); |
} else { |
354 |
} else |
m_ui.InstrumentNameTextLabel->setText( |
355 |
ui.InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName()); |
' ' + Channel::noInstrumentName()); |
356 |
|
} |
357 |
|
} else { |
358 |
|
m_ui.InstrumentNameTextLabel->setText( |
359 |
|
' ' + m_pChannel->instrumentName()); |
360 |
|
} |
361 |
|
|
362 |
return true; |
return true; |
363 |
} |
} |
366 |
// Do the dirty volume change. |
// Do the dirty volume change. |
367 |
bool ChannelStrip::updateChannelVolume (void) |
bool ChannelStrip::updateChannelVolume (void) |
368 |
{ |
{ |
369 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
370 |
return false; |
return false; |
|
|
|
|
// Convert... |
|
|
#ifdef CONFIG_ROUND |
|
|
int iVolume = (int) ::round(100.0 * m_pChannel->volume()); |
|
|
#else |
|
|
double fIPart = 0.0; |
|
|
double fFPart = ::modf(100.0 * m_pChannel->volume(), &fIPart); |
|
|
int iVolume = (int) fIPart; |
|
|
if (fFPart >= +0.5) |
|
|
iVolume++; |
|
|
else |
|
|
if (fFPart <= -0.5) |
|
|
iVolume--; |
|
|
#endif |
|
371 |
|
|
372 |
// And clip... |
// Convert... |
373 |
if (iVolume < 0) |
int iVolume = ::lroundf(100.0f * m_pChannel->volume()); |
374 |
iVolume = 0; |
// And clip... |
375 |
|
if (iVolume < 0) |
376 |
// Flag it here, to avoid infinite recursion. |
iVolume = 0; |
377 |
m_iDirtyChange++; |
|
378 |
ui.VolumeSlider->setValue(iVolume); |
// Flag it here, to avoid infinite recursion. |
379 |
ui.VolumeSpinBox->setValue(iVolume); |
m_iDirtyChange++; |
380 |
m_iDirtyChange--; |
m_ui.VolumeSlider->setValue(iVolume); |
381 |
|
m_ui.VolumeSpinBox->setValue(iVolume); |
382 |
|
m_iDirtyChange--; |
383 |
|
|
384 |
return true; |
return true; |
385 |
} |
} |
386 |
|
|
387 |
|
|
388 |
// Update whole channel info state. |
// Update whole channel info state. |
389 |
bool ChannelStrip::updateChannelInfo (void) |
bool ChannelStrip::updateChannelInfo (void) |
390 |
{ |
{ |
391 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
392 |
return false; |
return false; |
393 |
|
|
394 |
// Check for error limit/recycle... |
// Check for error limit/recycle... |
395 |
if (m_iErrorCount > QSAMPLER_ERROR_LIMIT) |
if (m_iErrorCount > QSAMPLER_ERROR_LIMIT) |
396 |
return true; |
return true; |
397 |
|
|
398 |
// Update strip caption. |
// Update strip caption. |
399 |
QString sText = m_pChannel->channelName(); |
QString sText = m_pChannel->channelName(); |
400 |
setWindowTitle(sText); |
setWindowTitle(sText); |
401 |
ui.ChannelSetupPushButton->setText(sText); |
m_ui.ChannelSetupPushButton->setText('&' + sText); |
402 |
|
|
403 |
// Check if we're up and connected. |
// Check if we're up and connected. |
404 |
MainForm* pMainForm = MainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
405 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
406 |
return false; |
return false; |
407 |
|
|
408 |
// Read actual channel information. |
// Read actual channel information. |
409 |
m_pChannel->updateChannelInfo(); |
m_pChannel->updateChannelInfo(); |
410 |
|
|
411 |
// Engine name... |
// Engine name... |
412 |
if (m_pChannel->engineName().isEmpty()) |
if (m_pChannel->engineName().isEmpty()) { |
413 |
ui.EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName()); |
m_ui.EngineNameTextLabel->setText( |
414 |
else |
' ' + Channel::noEngineName()); |
415 |
ui.EngineNameTextLabel->setText(' ' + m_pChannel->engineName()); |
} else { |
416 |
|
m_ui.EngineNameTextLabel->setText( |
417 |
|
' ' + m_pChannel->engineName()); |
418 |
|
} |
419 |
|
|
420 |
// Instrument name... |
// Instrument name... |
421 |
updateInstrumentName(false); |
updateInstrumentName(false); |
422 |
|
|
423 |
// MIDI Port/Channel... |
// MIDI Port/Channel... |
424 |
QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / "; |
QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / "; |
425 |
if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
426 |
sMidiPortChannel += tr("All"); |
sMidiPortChannel += tr("All"); |
427 |
else |
else |
428 |
sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1); |
sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1); |
429 |
ui.MidiPortChannelTextLabel->setText(sMidiPortChannel); |
m_ui.MidiPortChannelTextLabel->setText(sMidiPortChannel); |
430 |
|
|
431 |
// Common palette... |
// Common palette... |
432 |
QPalette pal; |
QPalette pal; |
433 |
const QColor& rgbFore = pal.color(QPalette::Foreground); |
const QColor& rgbFore = pal.color(QPalette::Foreground); |
434 |
|
|
435 |
// Instrument status... |
// Instrument status... |
436 |
int iInstrumentStatus = m_pChannel->instrumentStatus(); |
int iInstrumentStatus = m_pChannel->instrumentStatus(); |
437 |
if (iInstrumentStatus < 0) { |
if (iInstrumentStatus < 0) { |
438 |
pal.setColor(QPalette::Foreground, Qt::red); |
pal.setColor(QPalette::Foreground, Qt::red); |
439 |
ui.InstrumentStatusTextLabel->setPalette(pal); |
m_ui.InstrumentStatusTextLabel->setPalette(pal); |
440 |
ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus)); |
m_ui.InstrumentStatusTextLabel->setText( |
441 |
m_iErrorCount++; |
tr("ERR%1").arg(iInstrumentStatus)); |
442 |
return false; |
m_iErrorCount++; |
443 |
} |
return false; |
444 |
// All seems normal... |
} |
445 |
|
// All seems normal... |
446 |
pal.setColor(QPalette::Foreground, |
pal.setColor(QPalette::Foreground, |
447 |
iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
448 |
ui.InstrumentStatusTextLabel->setPalette(pal); |
m_ui.InstrumentStatusTextLabel->setPalette(pal); |
449 |
ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%'); |
m_ui.InstrumentStatusTextLabel->setText( |
450 |
m_iErrorCount = 0; |
QString::number(iInstrumentStatus) + '%'); |
451 |
|
m_iErrorCount = 0; |
452 |
|
|
453 |
#ifdef CONFIG_MUTE_SOLO |
#ifdef CONFIG_MUTE_SOLO |
454 |
// Mute/Solo button state coloring... |
// Mute/Solo button state coloring... |
455 |
bool bMute = m_pChannel->channelMute(); |
bool bMute = m_pChannel->channelMute(); |
456 |
const QColor& rgbButton = pal.color(QPalette::Button); |
const QColor& rgbButton = pal.color(QPalette::Button); |
457 |
pal.setColor(QPalette::Foreground, rgbFore); |
pal.setColor(QPalette::Foreground, rgbFore); |
458 |
pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton); |
pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton); |
459 |
ui.ChannelMutePushButton->setPalette(pal); |
m_ui.ChannelMutePushButton->setPalette(pal); |
460 |
ui.ChannelMutePushButton->setDown(bMute); |
m_ui.ChannelMutePushButton->setDown(bMute); |
461 |
bool bSolo = m_pChannel->channelSolo(); |
bool bSolo = m_pChannel->channelSolo(); |
462 |
pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); |
pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); |
463 |
ui.ChannelSoloPushButton->setPalette(pal); |
m_ui.ChannelSoloPushButton->setPalette(pal); |
464 |
ui.ChannelSoloPushButton->setDown(bSolo); |
m_ui.ChannelSoloPushButton->setDown(bSolo); |
465 |
#else |
#else |
466 |
ui.ChannelMutePushButton->setEnabled(false); |
m_ui.ChannelMutePushButton->setEnabled(false); |
467 |
ui.ChannelSoloPushButton->setEnabled(false); |
m_ui.ChannelSoloPushButton->setEnabled(false); |
468 |
#endif |
#endif |
469 |
|
|
470 |
// And update the both GUI volume elements; |
// And update the both GUI volume elements; |
471 |
// return success if, and only if, intrument is fully loaded... |
// return success if, and only if, intrument is fully loaded... |
472 |
return updateChannelVolume() && (iInstrumentStatus == 100); |
return updateChannelVolume() && (iInstrumentStatus == 100); |
473 |
} |
} |
474 |
|
|
475 |
|
|
476 |
// Update whole channel usage state. |
// Update whole channel usage state. |
477 |
bool ChannelStrip::updateChannelUsage (void) |
bool ChannelStrip::updateChannelUsage (void) |
478 |
{ |
{ |
479 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
480 |
return false; |
return false; |
481 |
|
|
482 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
483 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
485 |
|
|
486 |
// This only makes sense on fully loaded channels... |
// This only makes sense on fully loaded channels... |
487 |
if (m_pChannel->instrumentStatus() < 100) |
if (m_pChannel->instrumentStatus() < 100) |
488 |
return false; |
return false; |
489 |
|
|
490 |
// Get current channel voice count. |
// Get current channel voice count. |
491 |
int iVoiceCount = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID()); |
int iVoiceCount = ::lscp_get_channel_voice_count( |
492 |
// Get current stream count. |
pMainForm->client(), m_pChannel->channelID()); |
493 |
int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID()); |
// Get current stream count. |
494 |
// Get current channel buffer fill usage. |
int iStreamCount = ::lscp_get_channel_stream_count( |
495 |
// As benno has suggested this is the percentage usage |
pMainForm->client(), m_pChannel->channelID()); |
496 |
// of the least filled buffer stream... |
// Get current channel buffer fill usage. |
497 |
int iStreamUsage = ::lscp_get_channel_stream_usage(pMainForm->client(), m_pChannel->channelID());; |
// As benno has suggested this is the percentage usage |
498 |
|
// of the least filled buffer stream... |
499 |
// Update the GUI elements... |
int iStreamUsage = ::lscp_get_channel_stream_usage( |
500 |
ui.StreamUsageProgressBar->setValue(iStreamUsage); |
pMainForm->client(), m_pChannel->channelID());; |
501 |
ui.StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount)); |
|
502 |
|
// Update the GUI elements... |
503 |
|
m_ui.StreamUsageProgressBar->setValue(iStreamUsage); |
504 |
|
m_ui.StreamVoiceCountTextLabel->setText( |
505 |
|
QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount)); |
506 |
|
|
507 |
// We're clean. |
// We're clean. |
508 |
return true; |
return true; |
509 |
} |
} |
510 |
|
|
511 |
|
|
512 |
// Volume change slot. |
// Volume change slot. |
513 |
void ChannelStrip::volumeChanged ( int iVolume ) |
void ChannelStrip::volumeChanged ( int iVolume ) |
514 |
{ |
{ |
515 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
516 |
return; |
return; |
517 |
|
|
518 |
|
// Avoid recursion. |
519 |
|
if (m_iDirtyChange > 0) |
520 |
|
return; |
521 |
|
|
522 |
// Avoid recursion. |
// Convert and clip. |
523 |
if (m_iDirtyChange > 0) |
float fVolume = (float) iVolume / 100.0f; |
524 |
return; |
if (fVolume < 0.001f) |
525 |
|
fVolume = 0.0f; |
526 |
// Convert and clip. |
|
527 |
float fVolume = (float) iVolume / 100.0; |
// Update the GUI elements. |
528 |
if (fVolume < 0.001) |
if (m_pChannel->setVolume(fVolume)) { |
529 |
fVolume = 0.0; |
updateChannelVolume(); |
530 |
|
emit channelChanged(this); |
531 |
// Update the GUI elements. |
} |
|
if (m_pChannel->setVolume(fVolume)) { |
|
|
updateChannelVolume(); |
|
|
emit channelChanged(this); |
|
|
} |
|
532 |
} |
} |
533 |
|
|
534 |
|
|
535 |
// Context menu event handler. |
// Context menu event handler. |
536 |
void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent ) |
void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent ) |
537 |
{ |
{ |
538 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
539 |
return; |
return; |
540 |
|
|
541 |
// We'll just show up the main form's edit menu (thru qsamplerChannel). |
// We'll just show up the main form's edit menu (thru qsamplerChannel). |
542 |
m_pChannel->contextMenuEvent(pEvent); |
m_pChannel->contextMenuEvent(pEvent); |
543 |
} |
} |
544 |
|
|
545 |
|
|
549 |
m_iErrorCount = 0; |
m_iErrorCount = 0; |
550 |
} |
} |
551 |
|
|
552 |
|
|
553 |
|
// Channel strip activation/selection. |
554 |
|
void ChannelStrip::setSelected ( bool bSelected ) |
555 |
|
{ |
556 |
|
if (bSelected) { |
557 |
|
if (g_pSelectedStrip == this) |
558 |
|
return; |
559 |
|
if (g_pSelectedStrip) |
560 |
|
g_pSelectedStrip->setSelected(false); |
561 |
|
g_pSelectedStrip = this; |
562 |
|
} else { |
563 |
|
if (g_pSelectedStrip == this) |
564 |
|
g_pSelectedStrip = NULL; |
565 |
|
} |
566 |
|
|
567 |
|
QPalette pal; |
568 |
|
if (bSelected) { |
569 |
|
const QColor& color = pal.midlight().color(); |
570 |
|
pal.setColor(QPalette::Background, color.dark(150)); |
571 |
|
pal.setColor(QPalette::Foreground, color.light(150)); |
572 |
|
} |
573 |
|
QWidget::setPalette(pal); |
574 |
|
} |
575 |
|
|
576 |
|
|
577 |
|
bool ChannelStrip::isSelected (void) const |
578 |
|
{ |
579 |
|
return (this == g_pSelectedStrip); |
580 |
|
} |
581 |
|
|
582 |
|
|
583 |
} // namespace QSampler |
} // namespace QSampler |
584 |
|
|
585 |
|
|