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