34 |
// Needed for lroundf() |
// Needed for lroundf() |
35 |
#include <math.h> |
#include <math.h> |
36 |
|
|
|
namespace QSampler { |
|
|
|
|
37 |
#ifndef CONFIG_ROUND |
#ifndef CONFIG_ROUND |
38 |
static inline long lroundf ( float x ) |
static inline long lroundf ( float x ) |
39 |
{ |
{ |
44 |
} |
} |
45 |
#endif |
#endif |
46 |
|
|
47 |
|
|
48 |
|
namespace QSampler { |
49 |
|
|
50 |
|
//------------------------------------------------------------------------- |
51 |
|
// QSampler::ChannelStrip -- Channel strip form implementation. |
52 |
|
// |
53 |
|
|
54 |
|
// Channel strip activation/selection. |
55 |
|
ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; |
56 |
|
|
57 |
ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags ) |
ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags ) |
58 |
: QWidget(pParent, wflags) |
: QWidget(pParent, wflags) |
59 |
{ |
{ |
85 |
QObject::connect(m_ui.ChannelEditPushButton, |
QObject::connect(m_ui.ChannelEditPushButton, |
86 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
87 |
SLOT(channelEdit())); |
SLOT(channelEdit())); |
88 |
|
|
89 |
|
setSelected(false); |
90 |
} |
} |
91 |
|
|
92 |
ChannelStrip::~ChannelStrip() { |
|
93 |
|
ChannelStrip::~ChannelStrip (void) |
94 |
|
{ |
95 |
|
setSelected(false); |
96 |
|
|
97 |
// Destroy existing channel descriptor. |
// Destroy existing channel descriptor. |
98 |
if (m_pChannel) |
if (m_pChannel) |
99 |
delete m_pChannel; |
delete m_pChannel; |
116 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
117 |
const QString& sFilename = iter.next().toLocalFile(); |
const QString& sFilename = iter.next().toLocalFile(); |
118 |
if (!sFilename.isEmpty()) { |
if (!sFilename.isEmpty()) { |
119 |
bAccept = qsamplerChannel::isInstrumentFile(sFilename); |
bAccept = Channel::isInstrumentFile(sFilename); |
120 |
break; |
break; |
121 |
} |
} |
122 |
} |
} |
157 |
|
|
158 |
|
|
159 |
// Channel strip setup formal initializer. |
// Channel strip setup formal initializer. |
160 |
void ChannelStrip::setup ( qsamplerChannel *pChannel ) |
void ChannelStrip::setup ( Channel *pChannel ) |
161 |
{ |
{ |
162 |
// Destroy any previous channel descriptor; |
// Destroy any previous channel descriptor; |
163 |
// (remember that once setup we own it!) |
// (remember that once setup we own it!) |
175 |
setAcceptDrops(true); |
setAcceptDrops(true); |
176 |
} |
} |
177 |
|
|
178 |
|
|
179 |
// Channel secriptor accessor. |
// Channel secriptor accessor. |
180 |
qsamplerChannel *ChannelStrip::channel (void) const |
Channel *ChannelStrip::channel (void) const |
181 |
{ |
{ |
182 |
return m_pChannel; |
return m_pChannel; |
183 |
} |
} |
313 |
|
|
314 |
// Instrument name... |
// Instrument name... |
315 |
if (m_pChannel->instrumentName().isEmpty()) { |
if (m_pChannel->instrumentName().isEmpty()) { |
316 |
if (m_pChannel->instrumentStatus() >= 0) |
if (m_pChannel->instrumentStatus() >= 0) { |
317 |
m_ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::loadingInstrument()); |
m_ui.InstrumentNameTextLabel->setText( |
318 |
else |
' ' + Channel::loadingInstrument()); |
319 |
m_ui.InstrumentNameTextLabel->setText(' ' + qsamplerChannel::noInstrumentName()); |
} else { |
320 |
} else |
m_ui.InstrumentNameTextLabel->setText( |
321 |
m_ui.InstrumentNameTextLabel->setText(' ' + m_pChannel->instrumentName()); |
' ' + Channel::noInstrumentName()); |
322 |
|
} |
323 |
|
} else { |
324 |
|
m_ui.InstrumentNameTextLabel->setText( |
325 |
|
' ' + m_pChannel->instrumentName()); |
326 |
|
} |
327 |
|
|
328 |
return true; |
return true; |
329 |
} |
} |
364 |
// Update strip caption. |
// Update strip caption. |
365 |
QString sText = m_pChannel->channelName(); |
QString sText = m_pChannel->channelName(); |
366 |
setWindowTitle(sText); |
setWindowTitle(sText); |
367 |
m_ui.ChannelSetupPushButton->setText(sText); |
m_ui.ChannelSetupPushButton->setText('&' + sText); |
368 |
|
|
369 |
// Check if we're up and connected. |
// Check if we're up and connected. |
370 |
MainForm* pMainForm = MainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
375 |
m_pChannel->updateChannelInfo(); |
m_pChannel->updateChannelInfo(); |
376 |
|
|
377 |
// Engine name... |
// Engine name... |
378 |
if (m_pChannel->engineName().isEmpty()) |
if (m_pChannel->engineName().isEmpty()) { |
379 |
m_ui.EngineNameTextLabel->setText(' ' + qsamplerChannel::noEngineName()); |
m_ui.EngineNameTextLabel->setText( |
380 |
else |
' ' + Channel::noEngineName()); |
381 |
m_ui.EngineNameTextLabel->setText(' ' + m_pChannel->engineName()); |
} else { |
382 |
|
m_ui.EngineNameTextLabel->setText( |
383 |
|
' ' + m_pChannel->engineName()); |
384 |
|
} |
385 |
|
|
386 |
// Instrument name... |
// Instrument name... |
387 |
updateInstrumentName(false); |
updateInstrumentName(false); |
403 |
if (iInstrumentStatus < 0) { |
if (iInstrumentStatus < 0) { |
404 |
pal.setColor(QPalette::Foreground, Qt::red); |
pal.setColor(QPalette::Foreground, Qt::red); |
405 |
m_ui.InstrumentStatusTextLabel->setPalette(pal); |
m_ui.InstrumentStatusTextLabel->setPalette(pal); |
406 |
m_ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus)); |
m_ui.InstrumentStatusTextLabel->setText( |
407 |
|
tr("ERR%1").arg(iInstrumentStatus)); |
408 |
m_iErrorCount++; |
m_iErrorCount++; |
409 |
return false; |
return false; |
410 |
} |
} |
412 |
pal.setColor(QPalette::Foreground, |
pal.setColor(QPalette::Foreground, |
413 |
iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
414 |
m_ui.InstrumentStatusTextLabel->setPalette(pal); |
m_ui.InstrumentStatusTextLabel->setPalette(pal); |
415 |
m_ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%'); |
m_ui.InstrumentStatusTextLabel->setText( |
416 |
|
QString::number(iInstrumentStatus) + '%'); |
417 |
m_iErrorCount = 0; |
m_iErrorCount = 0; |
418 |
|
|
419 |
#ifdef CONFIG_MUTE_SOLO |
#ifdef CONFIG_MUTE_SOLO |
454 |
return false; |
return false; |
455 |
|
|
456 |
// Get current channel voice count. |
// Get current channel voice count. |
457 |
int iVoiceCount = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID()); |
int iVoiceCount = ::lscp_get_channel_voice_count( |
458 |
|
pMainForm->client(), m_pChannel->channelID()); |
459 |
// Get current stream count. |
// Get current stream count. |
460 |
int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID()); |
int iStreamCount = ::lscp_get_channel_stream_count( |
461 |
|
pMainForm->client(), m_pChannel->channelID()); |
462 |
// Get current channel buffer fill usage. |
// Get current channel buffer fill usage. |
463 |
// As benno has suggested this is the percentage usage |
// As benno has suggested this is the percentage usage |
464 |
// of the least filled buffer stream... |
// of the least filled buffer stream... |
465 |
int iStreamUsage = ::lscp_get_channel_stream_usage(pMainForm->client(), m_pChannel->channelID());; |
int iStreamUsage = ::lscp_get_channel_stream_usage( |
466 |
|
pMainForm->client(), m_pChannel->channelID());; |
467 |
|
|
468 |
// Update the GUI elements... |
// Update the GUI elements... |
469 |
m_ui.StreamUsageProgressBar->setValue(iStreamUsage); |
m_ui.StreamUsageProgressBar->setValue(iStreamUsage); |
470 |
m_ui.StreamVoiceCountTextLabel->setText(QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount)); |
m_ui.StreamVoiceCountTextLabel->setText( |
471 |
|
QString("%1 / %2").arg(iStreamCount).arg(iVoiceCount)); |
472 |
|
|
473 |
// We're clean. |
// We're clean. |
474 |
return true; |
return true; |
515 |
m_iErrorCount = 0; |
m_iErrorCount = 0; |
516 |
} |
} |
517 |
|
|
518 |
|
|
519 |
|
// Channel strip activation/selection. |
520 |
|
void ChannelStrip::setSelected ( bool bSelected ) |
521 |
|
{ |
522 |
|
if (bSelected) { |
523 |
|
if (g_pSelectedStrip == this) |
524 |
|
return; |
525 |
|
if (g_pSelectedStrip) |
526 |
|
g_pSelectedStrip->setSelected(false); |
527 |
|
g_pSelectedStrip = this; |
528 |
|
} else { |
529 |
|
if (g_pSelectedStrip == this) |
530 |
|
g_pSelectedStrip = NULL; |
531 |
|
} |
532 |
|
|
533 |
|
QPalette pal; |
534 |
|
if (bSelected) { |
535 |
|
const QColor& color = pal.midlight().color(); |
536 |
|
pal.setColor(QPalette::Background, color.dark(150)); |
537 |
|
pal.setColor(QPalette::Foreground, color.light(150)); |
538 |
|
} |
539 |
|
QWidget::setPalette(pal); |
540 |
|
} |
541 |
|
|
542 |
|
|
543 |
|
bool ChannelStrip::isSelected (void) const |
544 |
|
{ |
545 |
|
return (this == g_pSelectedStrip); |
546 |
|
} |
547 |
|
|
548 |
|
|
549 |
} // namespace QSampler |
} // namespace QSampler |
550 |
|
|
551 |
|
|