20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
23 |
|
#include "qsamplerAbout.h" |
24 |
#include "qsamplerChannelStrip.h" |
#include "qsamplerChannelStrip.h" |
25 |
|
|
26 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
27 |
|
|
28 |
#include <q3dragobject.h> |
#include <QDragEnterEvent> |
|
|
|
29 |
#include <QUrl> |
#include <QUrl> |
30 |
|
|
|
#include <math.h> |
|
|
|
|
31 |
// Channel status/usage usage limit control. |
// Channel status/usage usage limit control. |
32 |
#define QSAMPLER_ERROR_LIMIT 3 |
#define QSAMPLER_ERROR_LIMIT 3 |
33 |
|
|
34 |
|
// Needed for lroundf() |
35 |
|
#include <math.h> |
36 |
|
|
37 |
|
#ifndef CONFIG_ROUND |
38 |
|
static inline long lroundf ( float x ) |
39 |
|
{ |
40 |
|
if (x >= 0.0f) |
41 |
|
return long(x + 0.5f); |
42 |
|
else |
43 |
|
return long(x - 0.5f); |
44 |
|
} |
45 |
|
#endif |
46 |
|
|
47 |
|
|
48 |
namespace QSampler { |
namespace QSampler { |
49 |
|
|
50 |
ChannelStrip::ChannelStrip(QWidget* parent, Qt::WFlags f) : QWidget(parent, f) { |
// Channel strip activation/selection. |
51 |
ui.setupUi(this); |
ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; |
52 |
|
|
|
// Initialize locals. |
|
|
m_pChannel = NULL; |
|
|
m_iDirtyChange = 0; |
|
|
m_iErrorCount = 0; |
|
53 |
|
|
54 |
// Try to restore normal window positioning. |
ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags ) |
55 |
adjustSize(); |
: QWidget(pParent, wflags) |
56 |
|
{ |
57 |
|
m_ui.setupUi(this); |
58 |
|
|
59 |
|
// Initialize locals. |
60 |
|
m_pChannel = NULL; |
61 |
|
m_iDirtyChange = 0; |
62 |
|
m_iErrorCount = 0; |
63 |
|
|
64 |
|
// Try to restore normal window positioning. |
65 |
|
adjustSize(); |
66 |
|
setSelected(false); |
67 |
|
|
68 |
QObject::connect(ui.ChannelSetupPushButton, |
QObject::connect(m_ui.ChannelSetupPushButton, |
69 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
70 |
SLOT(channelSetup())); |
SLOT(channelSetup())); |
71 |
QObject::connect(ui.ChannelMutePushButton, |
QObject::connect(m_ui.ChannelMutePushButton, |
72 |
SIGNAL(toggled(bool)), |
SIGNAL(toggled(bool)), |
73 |
SLOT(channelMute(bool))); |
SLOT(channelMute(bool))); |
74 |
QObject::connect(ui.ChannelSoloPushButton, |
QObject::connect(m_ui.ChannelSoloPushButton, |
75 |
SIGNAL(toggled(bool)), |
SIGNAL(toggled(bool)), |
76 |
SLOT(channelSolo(bool))); |
SLOT(channelSolo(bool))); |
77 |
QObject::connect(ui.VolumeSlider, |
QObject::connect(m_ui.VolumeSlider, |
78 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
79 |
SLOT(volumeChanged(int))); |
SLOT(volumeChanged(int))); |
80 |
QObject::connect(ui.VolumeSpinBox, |
QObject::connect(m_ui.VolumeSpinBox, |
81 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
82 |
SLOT(volumeChanged(int))); |
SLOT(volumeChanged(int))); |
83 |
QObject::connect(ui.ChannelEditPushButton, |
QObject::connect(m_ui.ChannelEditPushButton, |
84 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
85 |
SLOT(channelEdit())); |
SLOT(channelEdit())); |
86 |
} |
} |
87 |
|
|
88 |
ChannelStrip::~ChannelStrip() { |
|
89 |
// Destroy existing channel descriptor. |
ChannelStrip::~ChannelStrip (void) |
90 |
if (m_pChannel) |
{ |
91 |
delete m_pChannel; |
// Destroy existing channel descriptor. |
92 |
m_pChannel = NULL; |
if (m_pChannel) |
93 |
|
delete m_pChannel; |
94 |
|
m_pChannel = NULL; |
95 |
} |
} |
96 |
|
|
97 |
|
|
98 |
// Drag'n'drop file handler. |
// Window drag-n-drop event handlers. |
99 |
bool ChannelStrip::decodeDragFile ( const QMimeSource *pEvent, QString& sInstrumentFile ) |
void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
100 |
{ |
{ |
101 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
102 |
return false; |
return; |
103 |
if (Q3TextDrag::canDecode(pEvent)) { |
|
104 |
QString sText; |
bool bAccept = false; |
105 |
if (Q3TextDrag::decode(pEvent, sText)) { |
|
106 |
QStringList files = QStringList::split('\n', sText); |
if (pDragEnterEvent->source() == NULL) { |
107 |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
const QMimeData *pMimeData = pDragEnterEvent->mimeData(); |
108 |
*iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path(); |
if (pMimeData && pMimeData->hasUrls()) { |
109 |
if (qsamplerChannel::isInstrumentFile(*iter)) { |
QListIterator<QUrl> iter(pMimeData->urls()); |
110 |
sInstrumentFile = *iter; |
while (iter.hasNext()) { |
111 |
return true; |
const QString& sFilename = iter.next().toLocalFile(); |
112 |
|
if (!sFilename.isEmpty()) { |
113 |
|
bAccept = qsamplerChannel::isInstrumentFile(sFilename); |
114 |
|
break; |
115 |
} |
} |
116 |
} |
} |
117 |
} |
} |
118 |
} |
} |
|
// Fail. |
|
|
return false; |
|
|
} |
|
119 |
|
|
120 |
|
if (bAccept) |
121 |
// Window drag-n-drop event handlers. |
pDragEnterEvent->accept(); |
122 |
void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
else |
123 |
{ |
pDragEnterEvent->ignore(); |
|
QString sInstrumentFile; |
|
|
pDragEnterEvent->accept(decodeDragFile(pDragEnterEvent, sInstrumentFile)); |
|
124 |
} |
} |
125 |
|
|
126 |
|
|
127 |
void ChannelStrip::dropEvent ( QDropEvent* pDropEvent ) |
void ChannelStrip::dropEvent ( QDropEvent* pDropEvent ) |
128 |
{ |
{ |
129 |
QString sInstrumentFile; |
if (m_pChannel == NULL) |
130 |
|
return; |
131 |
|
|
132 |
if (decodeDragFile(pDropEvent, sInstrumentFile)) { |
if (pDropEvent->source()) |
133 |
// Go and set the dropped instrument filename... |
return; |
134 |
m_pChannel->setInstrument(sInstrumentFile, 0); |
|
135 |
// Open up the channel dialog. |
const QMimeData *pMimeData = pDropEvent->mimeData(); |
136 |
channelSetup(); |
if (pMimeData && pMimeData->hasUrls()) { |
137 |
|
QStringList files; |
138 |
|
QListIterator<QUrl> iter(pMimeData->urls()); |
139 |
|
while (iter.hasNext()) { |
140 |
|
const QString& sFilename = iter.next().toLocalFile(); |
141 |
|
if (!sFilename.isEmpty()) { |
142 |
|
// Go and set the dropped instrument filename... |
143 |
|
m_pChannel->setInstrument(sFilename, 0); |
144 |
|
// Open up the channel dialog. |
145 |
|
channelSetup(); |
146 |
|
break; |
147 |
|
} |
148 |
|
} |
149 |
} |
} |
150 |
} |
} |
151 |
|
|
153 |
// Channel strip setup formal initializer. |
// Channel strip setup formal initializer. |
154 |
void ChannelStrip::setup ( qsamplerChannel *pChannel ) |
void ChannelStrip::setup ( qsamplerChannel *pChannel ) |
155 |
{ |
{ |
156 |
// Destroy any previous channel descriptor; |
// Destroy any previous channel descriptor; |
157 |
// (remember that once setup we own it!) |
// (remember that once setup we own it!) |
158 |
if (m_pChannel) |
if (m_pChannel) |
159 |
delete m_pChannel; |
delete m_pChannel; |
160 |
|
|
161 |
// Set the new one... |
// Set the new one... |
162 |
m_pChannel = pChannel; |
m_pChannel = pChannel; |
163 |
|
|
164 |
// Stabilize this around. |
// Stabilize this around. |
165 |
updateChannelInfo(); |
updateChannelInfo(); |
166 |
|
|
167 |
// We'll accept drops from now on... |
// We'll accept drops from now on... |
168 |
if (m_pChannel) |
if (m_pChannel) |
169 |
setAcceptDrops(true); |
setAcceptDrops(true); |
170 |
} |
} |
171 |
|
|
172 |
|
|
173 |
// Channel secriptor accessor. |
// Channel secriptor accessor. |
174 |
qsamplerChannel *ChannelStrip::channel (void) |
qsamplerChannel *ChannelStrip::channel (void) const |
175 |
{ |
{ |
176 |
return m_pChannel; |
return m_pChannel; |
177 |
} |
} |
178 |
|
|
179 |
|
|
180 |
// Messages view font accessors. |
// Messages view font accessors. |
181 |
QFont ChannelStrip::displayFont (void) |
QFont ChannelStrip::displayFont (void) const |
182 |
{ |
{ |
183 |
return ui.EngineNameTextLabel->font(); |
return m_ui.EngineNameTextLabel->font(); |
184 |
} |
} |
185 |
|
|
186 |
void ChannelStrip::setDisplayFont ( const QFont & font ) |
void ChannelStrip::setDisplayFont ( const QFont & font ) |
187 |
{ |
{ |
188 |
ui.EngineNameTextLabel->setFont(font); |
m_ui.EngineNameTextLabel->setFont(font); |
189 |
ui.MidiPortChannelTextLabel->setFont(font); |
m_ui.MidiPortChannelTextLabel->setFont(font); |
190 |
ui.InstrumentNameTextLabel->setFont(font); |
m_ui.InstrumentNameTextLabel->setFont(font); |
191 |
ui.InstrumentStatusTextLabel->setFont(font); |
m_ui.InstrumentStatusTextLabel->setFont(font); |
192 |
} |
} |
193 |
|
|
194 |
|
|
195 |
// Channel display background effect. |
// Channel display background effect. |
196 |
void ChannelStrip::setDisplayEffect ( bool bDisplayEffect ) |
void ChannelStrip::setDisplayEffect ( bool bDisplayEffect ) |
197 |
{ |
{ |
198 |
QPixmap pm = |
QPalette pal; |
199 |
(bDisplayEffect) ? |
pal.setColor(QPalette::Foreground, Qt::yellow); |
200 |
QPixmap(":/icons/displaybg1.png") : QPixmap(); |
m_ui.EngineNameTextLabel->setPalette(pal); |
201 |
setDisplayBackground(pm); |
m_ui.MidiPortChannelTextLabel->setPalette(pal); |
202 |
} |
pal.setColor(QPalette::Foreground, Qt::green); |
203 |
|
if (bDisplayEffect) { |
204 |
|
QPixmap pm(":/icons/displaybg1.png"); |
205 |
// Update main display background pixmap. |
pal.setBrush(QPalette::Background, QBrush(pm)); |
206 |
void ChannelStrip::setDisplayBackground ( const QPixmap& pm ) |
} else { |
207 |
{ |
pal.setColor(QPalette::Background, Qt::black); |
208 |
// Set the main origin... |
} |
209 |
ui.ChannelInfoFrame->setPaletteBackgroundPixmap(pm); |
m_ui.ChannelInfoFrame->setPalette(pal); |
210 |
|
m_ui.StreamVoiceCountTextLabel->setPalette(pal); |
|
// Iterate for every child text label... |
|
|
QList<QObject*> list = ui.ChannelInfoFrame->queryList("QLabel"); |
|
|
for (QList<QObject*>::iterator iter = list.begin(); iter != list.end(); iter++) { |
|
|
static_cast<QLabel*>(*iter)->setPaletteBackgroundPixmap(pm); |
|
|
} |
|
|
|
|
|
// And this standalone too. |
|
|
ui.StreamVoiceCountTextLabel->setPaletteBackgroundPixmap(pm); |
|
211 |
} |
} |
212 |
|
|
213 |
|
|
214 |
// Maximum volume slider accessors. |
// Maximum volume slider accessors. |
215 |
void ChannelStrip::setMaxVolume ( int iMaxVolume ) |
void ChannelStrip::setMaxVolume ( int iMaxVolume ) |
216 |
{ |
{ |
217 |
m_iDirtyChange++; |
m_iDirtyChange++; |
218 |
ui.VolumeSlider->setRange(0, iMaxVolume); |
m_ui.VolumeSlider->setRange(0, iMaxVolume); |
219 |
ui.VolumeSpinBox->setRange(0, iMaxVolume); |
m_ui.VolumeSpinBox->setRange(0, iMaxVolume); |
220 |
m_iDirtyChange--; |
m_iDirtyChange--; |
221 |
} |
} |
222 |
|
|
223 |
|
|
307 |
|
|
308 |
// Instrument name... |
// Instrument name... |
309 |
if (m_pChannel->instrumentName().isEmpty()) { |
if (m_pChannel->instrumentName().isEmpty()) { |
310 |
if (m_pChannel->instrumentStatus() >= 0) |
if (m_pChannel->instrumentStatus() >= 0) { |
311 |
ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::loadingInstrument()); |
m_ui.InstrumentNameTextLabel->setText( |
312 |
else |
' ' + qsamplerChannel::loadingInstrument()); |
313 |
ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName()); |
} else { |
314 |
} else |
m_ui.InstrumentNameTextLabel->setText( |
315 |
ui.InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName()); |
' ' + qsamplerChannel::noInstrumentName()); |
316 |
|
} |
317 |
|
} else { |
318 |
|
m_ui.InstrumentNameTextLabel->setText( |
319 |
|
' ' + m_pChannel->instrumentName()); |
320 |
|
} |
321 |
|
|
322 |
return true; |
return true; |
323 |
} |
} |
326 |
// Do the dirty volume change. |
// Do the dirty volume change. |
327 |
bool ChannelStrip::updateChannelVolume (void) |
bool ChannelStrip::updateChannelVolume (void) |
328 |
{ |
{ |
329 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
330 |
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 |
|
331 |
|
|
332 |
// And clip... |
// Convert... |
333 |
if (iVolume < 0) |
int iVolume = ::lroundf(100.0f * m_pChannel->volume()); |
334 |
iVolume = 0; |
// And clip... |
335 |
|
if (iVolume < 0) |
336 |
// Flag it here, to avoid infinite recursion. |
iVolume = 0; |
337 |
m_iDirtyChange++; |
|
338 |
ui.VolumeSlider->setValue(iVolume); |
// Flag it here, to avoid infinite recursion. |
339 |
ui.VolumeSpinBox->setValue(iVolume); |
m_iDirtyChange++; |
340 |
m_iDirtyChange--; |
m_ui.VolumeSlider->setValue(iVolume); |
341 |
|
m_ui.VolumeSpinBox->setValue(iVolume); |
342 |
|
m_iDirtyChange--; |
343 |
|
|
344 |
return true; |
return true; |
345 |
} |
} |
346 |
|
|
347 |
|
|
348 |
// Update whole channel info state. |
// Update whole channel info state. |
349 |
bool ChannelStrip::updateChannelInfo (void) |
bool ChannelStrip::updateChannelInfo (void) |
350 |
{ |
{ |
351 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
352 |
return false; |
return false; |
353 |
|
|
354 |
// Check for error limit/recycle... |
// Check for error limit/recycle... |
355 |
if (m_iErrorCount > QSAMPLER_ERROR_LIMIT) |
if (m_iErrorCount > QSAMPLER_ERROR_LIMIT) |
356 |
return true; |
return true; |
357 |
|
|
358 |
// Update strip caption. |
// Update strip caption. |
359 |
QString sText = m_pChannel->channelName(); |
QString sText = m_pChannel->channelName(); |
360 |
setCaption(sText); |
setWindowTitle(sText); |
361 |
ui.ChannelSetupPushButton->setText(sText); |
m_ui.ChannelSetupPushButton->setText('&' + sText); |
362 |
|
|
363 |
// Check if we're up and connected. |
// Check if we're up and connected. |
364 |
MainForm* pMainForm = MainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
365 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
366 |
return false; |
return false; |
367 |
|
|
368 |
// Read actual channel information. |
// Read actual channel information. |
369 |
m_pChannel->updateChannelInfo(); |
m_pChannel->updateChannelInfo(); |
370 |
|
|
371 |
// Engine name... |
// Engine name... |
372 |
if (m_pChannel->engineName().isEmpty()) |
if (m_pChannel->engineName().isEmpty()) { |
373 |
ui.EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName()); |
m_ui.EngineNameTextLabel->setText( |
374 |
else |
' ' + qsamplerChannel::noEngineName()); |
375 |
ui.EngineNameTextLabel->setText(' ' + m_pChannel->engineName()); |
} else { |
376 |
|
m_ui.EngineNameTextLabel->setText( |
377 |
|
' ' + m_pChannel->engineName()); |
378 |
|
} |
379 |
|
|
380 |
// Instrument name... |
// Instrument name... |
381 |
updateInstrumentName(false); |
updateInstrumentName(false); |
382 |
|
|
383 |
// MIDI Port/Channel... |
// MIDI Port/Channel... |
384 |
QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / "; |
QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / "; |
385 |
if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
386 |
sMidiPortChannel += tr("All"); |
sMidiPortChannel += tr("All"); |
387 |
else |
else |
388 |
sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1); |
sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1); |
389 |
ui.MidiPortChannelTextLabel->setText(sMidiPortChannel); |
m_ui.MidiPortChannelTextLabel->setText(sMidiPortChannel); |
390 |
|
|
391 |
// Instrument status... |
// Common palette... |
392 |
int iInstrumentStatus = m_pChannel->instrumentStatus(); |
QPalette pal; |
393 |
if (iInstrumentStatus < 0) { |
const QColor& rgbFore = pal.color(QPalette::Foreground); |
394 |
ui.InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red); |
|
395 |
ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus)); |
// Instrument status... |
396 |
m_iErrorCount++; |
int iInstrumentStatus = m_pChannel->instrumentStatus(); |
397 |
return false; |
if (iInstrumentStatus < 0) { |
398 |
} |
pal.setColor(QPalette::Foreground, Qt::red); |
399 |
// All seems normal... |
m_ui.InstrumentStatusTextLabel->setPalette(pal); |
400 |
ui.InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
m_ui.InstrumentStatusTextLabel->setText( |
401 |
ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%'); |
tr("ERR%1").arg(iInstrumentStatus)); |
402 |
m_iErrorCount = 0; |
m_iErrorCount++; |
403 |
|
return false; |
404 |
|
} |
405 |
|
// All seems normal... |
406 |
|
pal.setColor(QPalette::Foreground, |
407 |
|
iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
408 |
|
m_ui.InstrumentStatusTextLabel->setPalette(pal); |
409 |
|
m_ui.InstrumentStatusTextLabel->setText( |
410 |
|
QString::number(iInstrumentStatus) + '%'); |
411 |
|
m_iErrorCount = 0; |
412 |
|
|
413 |
#ifdef CONFIG_MUTE_SOLO |
#ifdef CONFIG_MUTE_SOLO |
414 |
// Mute/Solo button state coloring... |
// Mute/Solo button state coloring... |
415 |
const QColor& rgbNormal = ChannelSetupPushButton->paletteBackgroundColor(); |
bool bMute = m_pChannel->channelMute(); |
416 |
bool bMute = m_pChannel->channelMute(); |
const QColor& rgbButton = pal.color(QPalette::Button); |
417 |
ChannelMutePushButton->setPaletteBackgroundColor(bMute ? Qt::yellow : rgbNormal); |
pal.setColor(QPalette::Foreground, rgbFore); |
418 |
ChannelMutePushButton->setDown(bMute); |
pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton); |
419 |
bool bSolo = m_pChannel->channelSolo(); |
m_ui.ChannelMutePushButton->setPalette(pal); |
420 |
ChannelSoloPushButton->setPaletteBackgroundColor(bSolo ? Qt::cyan : rgbNormal); |
m_ui.ChannelMutePushButton->setDown(bMute); |
421 |
ChannelSoloPushButton->setDown(bSolo); |
bool bSolo = m_pChannel->channelSolo(); |
422 |
|
pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); |
423 |
|
m_ui.ChannelSoloPushButton->setPalette(pal); |
424 |
|
m_ui.ChannelSoloPushButton->setDown(bSolo); |
425 |
#else |
#else |
426 |
ui.ChannelMutePushButton->setEnabled(false); |
m_ui.ChannelMutePushButton->setEnabled(false); |
427 |
ui.ChannelSoloPushButton->setEnabled(false); |
m_ui.ChannelSoloPushButton->setEnabled(false); |
428 |
#endif |
#endif |
429 |
|
|
430 |
// And update the both GUI volume elements; |
// And update the both GUI volume elements; |
431 |
// return success if, and only if, intrument is fully loaded... |
// return success if, and only if, intrument is fully loaded... |
432 |
return updateChannelVolume() && (iInstrumentStatus == 100); |
return updateChannelVolume() && (iInstrumentStatus == 100); |
433 |
} |
} |
434 |
|
|
435 |
|
|
436 |
// Update whole channel usage state. |
// Update whole channel usage state. |
437 |
bool ChannelStrip::updateChannelUsage (void) |
bool ChannelStrip::updateChannelUsage (void) |
438 |
{ |
{ |
439 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
440 |
return false; |
return false; |
441 |
|
|
442 |
MainForm *pMainForm = MainForm::getInstance(); |
MainForm *pMainForm = MainForm::getInstance(); |
443 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
445 |
|
|
446 |
// This only makes sense on fully loaded channels... |
// This only makes sense on fully loaded channels... |
447 |
if (m_pChannel->instrumentStatus() < 100) |
if (m_pChannel->instrumentStatus() < 100) |
448 |
return false; |
return false; |
449 |
|
|
450 |
// Get current channel voice count. |
// Get current channel voice count. |
451 |
int iVoiceCount = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID()); |
int iVoiceCount = ::lscp_get_channel_voice_count( |
452 |
// Get current stream count. |
pMainForm->client(), m_pChannel->channelID()); |
453 |
int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID()); |
// Get current stream count. |
454 |
// Get current channel buffer fill usage. |
int iStreamCount = ::lscp_get_channel_stream_count( |
455 |
// As benno has suggested this is the percentage usage |
pMainForm->client(), m_pChannel->channelID()); |
456 |
// of the least filled buffer stream... |
// Get current channel buffer fill usage. |
457 |
int iStreamUsage = ::lscp_get_channel_stream_usage(pMainForm->client(), m_pChannel->channelID());; |
// As benno has suggested this is the percentage usage |
458 |
|
// of the least filled buffer stream... |
459 |
// Update the GUI elements... |
int iStreamUsage = ::lscp_get_channel_stream_usage( |
460 |
ui.StreamUsageProgressBar->setValue(iStreamUsage); |
pMainForm->client(), m_pChannel->channelID());; |
461 |
ui.StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount)); |
|
462 |
|
// Update the GUI elements... |
463 |
|
m_ui.StreamUsageProgressBar->setValue(iStreamUsage); |
464 |
|
m_ui.StreamVoiceCountTextLabel->setText( |
465 |
|
QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount)); |
466 |
|
|
467 |
// We're clean. |
// We're clean. |
468 |
return true; |
return true; |
469 |
} |
} |
470 |
|
|
471 |
|
|
472 |
// Volume change slot. |
// Volume change slot. |
473 |
void ChannelStrip::volumeChanged ( int iVolume ) |
void ChannelStrip::volumeChanged ( int iVolume ) |
474 |
{ |
{ |
475 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
476 |
return; |
return; |
477 |
|
|
478 |
// Avoid recursion. |
// Avoid recursion. |
479 |
if (m_iDirtyChange > 0) |
if (m_iDirtyChange > 0) |
480 |
return; |
return; |
481 |
|
|
482 |
// Convert and clip. |
// Convert and clip. |
483 |
float fVolume = (float) iVolume / 100.0; |
float fVolume = (float) iVolume / 100.0f; |
484 |
if (fVolume < 0.001) |
if (fVolume < 0.001f) |
485 |
fVolume = 0.0; |
fVolume = 0.0f; |
486 |
|
|
487 |
// Update the GUI elements. |
// Update the GUI elements. |
488 |
if (m_pChannel->setVolume(fVolume)) { |
if (m_pChannel->setVolume(fVolume)) { |
489 |
updateChannelVolume(); |
updateChannelVolume(); |
490 |
emit channelChanged(this); |
emit channelChanged(this); |
491 |
} |
} |
492 |
} |
} |
493 |
|
|
494 |
|
|
495 |
// Context menu event handler. |
// Context menu event handler. |
496 |
void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent ) |
void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent ) |
497 |
{ |
{ |
498 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
499 |
return; |
return; |
500 |
|
|
501 |
// 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). |
502 |
m_pChannel->contextMenuEvent(pEvent); |
m_pChannel->contextMenuEvent(pEvent); |
503 |
} |
} |
504 |
|
|
505 |
|
|
509 |
m_iErrorCount = 0; |
m_iErrorCount = 0; |
510 |
} |
} |
511 |
|
|
512 |
|
|
513 |
|
// Channel strip activation/selection. |
514 |
|
void ChannelStrip::setSelected ( bool bSelected ) |
515 |
|
{ |
516 |
|
if (bSelected) { |
517 |
|
if (g_pSelectedStrip == this) |
518 |
|
return; |
519 |
|
if (g_pSelectedStrip) |
520 |
|
g_pSelectedStrip->setSelected(false); |
521 |
|
g_pSelectedStrip = this; |
522 |
|
} else { |
523 |
|
if (g_pSelectedStrip == this) |
524 |
|
g_pSelectedStrip = NULL; |
525 |
|
} |
526 |
|
|
527 |
|
QPalette pal; |
528 |
|
if (bSelected) { |
529 |
|
const QColor& color = pal.midlight().color(); |
530 |
|
pal.setColor(QPalette::Background, color.dark(150)); |
531 |
|
pal.setColor(QPalette::Foreground, color.light(150)); |
532 |
|
} |
533 |
|
QWidget::setPalette(pal); |
534 |
|
} |
535 |
|
|
536 |
|
|
537 |
|
bool ChannelStrip::isSelected (void) const |
538 |
|
{ |
539 |
|
return (this == g_pSelectedStrip); |
540 |
|
} |
541 |
|
|
542 |
|
|
543 |
} // namespace QSampler |
} // namespace QSampler |
544 |
|
|
545 |
|
|