1 |
// qsamplerChannelStrip.cpp |
// qsamplerChannelStrip.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2012, 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 <QFileInfo> |
33 |
|
#include <QTimer> |
34 |
#include <QUrl> |
#include <QUrl> |
35 |
|
|
36 |
|
#if QT_VERSION >= 0x050000 |
37 |
|
#include <QMimeData> |
38 |
|
#endif |
39 |
|
|
40 |
// Channel status/usage usage limit control. |
// Channel status/usage usage limit control. |
41 |
#define QSAMPLER_ERROR_LIMIT 3 |
#define QSAMPLER_ERROR_LIMIT 3 |
42 |
|
|
56 |
|
|
57 |
namespace QSampler { |
namespace QSampler { |
58 |
|
|
59 |
|
//------------------------------------------------------------------------- |
60 |
|
// QSampler::ChannelStrip -- Channel strip form implementation. |
61 |
|
// |
62 |
|
|
63 |
|
// MIDI activity pixmap common resources. |
64 |
|
int ChannelStrip::g_iMidiActivityRefCount = 0; |
65 |
|
QPixmap *ChannelStrip::g_pMidiActivityLedOn = NULL; |
66 |
|
QPixmap *ChannelStrip::g_pMidiActivityLedOff = NULL; |
67 |
|
|
68 |
// Channel strip activation/selection. |
// Channel strip activation/selection. |
69 |
ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; |
ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; |
70 |
|
|
|
|
|
71 |
ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags ) |
ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags ) |
72 |
: QWidget(pParent, wflags) |
: QWidget(pParent, wflags) |
73 |
{ |
{ |
78 |
m_iDirtyChange = 0; |
m_iDirtyChange = 0; |
79 |
m_iErrorCount = 0; |
m_iErrorCount = 0; |
80 |
|
|
81 |
|
if (++g_iMidiActivityRefCount == 1) { |
82 |
|
g_pMidiActivityLedOn = new QPixmap(":/images/ledon1.png"); |
83 |
|
g_pMidiActivityLedOff = new QPixmap(":/images/ledoff1.png"); |
84 |
|
} |
85 |
|
|
86 |
|
m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff); |
87 |
|
|
88 |
|
#ifndef CONFIG_EVENT_CHANNEL_MIDI |
89 |
|
m_ui.MidiActivityLabel->setToolTip("MIDI activity (disabled)"); |
90 |
|
#endif |
91 |
|
|
92 |
|
m_pMidiActivityTimer = new QTimer(this); |
93 |
|
m_pMidiActivityTimer->setSingleShot(true); |
94 |
|
|
95 |
|
QObject::connect(m_pMidiActivityTimer, |
96 |
|
SIGNAL(timeout()), |
97 |
|
SLOT(midiActivityLedOff()) |
98 |
|
); |
99 |
|
|
100 |
// Try to restore normal window positioning. |
// Try to restore normal window positioning. |
101 |
adjustSize(); |
adjustSize(); |
|
setSelected(false); |
|
102 |
|
|
103 |
QObject::connect(m_ui.ChannelSetupPushButton, |
QObject::connect(m_ui.ChannelSetupPushButton, |
104 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
118 |
QObject::connect(m_ui.ChannelEditPushButton, |
QObject::connect(m_ui.ChannelEditPushButton, |
119 |
SIGNAL(clicked()), |
SIGNAL(clicked()), |
120 |
SLOT(channelEdit())); |
SLOT(channelEdit())); |
121 |
|
QObject::connect(m_ui.FxPushButton, |
122 |
|
SIGNAL(clicked()), |
123 |
|
SLOT(channelFxEdit())); |
124 |
|
|
125 |
|
setSelected(false); |
126 |
} |
} |
127 |
|
|
128 |
|
|
129 |
ChannelStrip::~ChannelStrip (void) |
ChannelStrip::~ChannelStrip (void) |
130 |
{ |
{ |
131 |
|
setSelected(false); |
132 |
|
|
133 |
// Destroy existing channel descriptor. |
// Destroy existing channel descriptor. |
134 |
if (m_pChannel) |
if (m_pChannel) |
135 |
delete m_pChannel; |
delete m_pChannel; |
136 |
m_pChannel = NULL; |
m_pChannel = NULL; |
137 |
|
|
138 |
|
if (--g_iMidiActivityRefCount == 0) { |
139 |
|
if (g_pMidiActivityLedOn) |
140 |
|
delete g_pMidiActivityLedOn; |
141 |
|
g_pMidiActivityLedOn = NULL; |
142 |
|
if (g_pMidiActivityLedOff) |
143 |
|
delete g_pMidiActivityLedOff; |
144 |
|
g_pMidiActivityLedOff = NULL; |
145 |
|
} |
146 |
} |
} |
147 |
|
|
148 |
|
|
161 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
162 |
const QString& sFilename = iter.next().toLocalFile(); |
const QString& sFilename = iter.next().toLocalFile(); |
163 |
if (!sFilename.isEmpty()) { |
if (!sFilename.isEmpty()) { |
164 |
bAccept = qsamplerChannel::isInstrumentFile(sFilename); |
// bAccept = Channel::isDlsInstrumentFile(sFilename); |
165 |
|
bAccept = QFileInfo(sFilename).exists(); |
166 |
break; |
break; |
167 |
} |
} |
168 |
} |
} |
203 |
|
|
204 |
|
|
205 |
// Channel strip setup formal initializer. |
// Channel strip setup formal initializer. |
206 |
void ChannelStrip::setup ( qsamplerChannel *pChannel ) |
void ChannelStrip::setup ( Channel *pChannel ) |
207 |
{ |
{ |
208 |
// Destroy any previous channel descriptor; |
// Destroy any previous channel descriptor; |
209 |
// (remember that once setup we own it!) |
// (remember that once setup we own it!) |
223 |
|
|
224 |
|
|
225 |
// Channel secriptor accessor. |
// Channel secriptor accessor. |
226 |
qsamplerChannel *ChannelStrip::channel (void) const |
Channel *ChannelStrip::channel (void) const |
227 |
{ |
{ |
228 |
return m_pChannel; |
return m_pChannel; |
229 |
} |
} |
253 |
m_ui.MidiPortChannelTextLabel->setPalette(pal); |
m_ui.MidiPortChannelTextLabel->setPalette(pal); |
254 |
pal.setColor(QPalette::Foreground, Qt::green); |
pal.setColor(QPalette::Foreground, Qt::green); |
255 |
if (bDisplayEffect) { |
if (bDisplayEffect) { |
256 |
QPixmap pm(":/icons/displaybg1.png"); |
QPixmap pm(":/images/displaybg1.png"); |
257 |
pal.setBrush(QPalette::Background, QBrush(pm)); |
pal.setBrush(QPalette::Background, QBrush(pm)); |
258 |
} else { |
} else { |
259 |
pal.setColor(QPalette::Background, Qt::black); |
pal.setColor(QPalette::Background, Qt::black); |
260 |
} |
} |
261 |
m_ui.ChannelInfoFrame->setPalette(pal); |
m_ui.ChannelInfoFrame->setPalette(pal); |
262 |
|
m_ui.InstrumentNameTextLabel->setPalette(pal); |
263 |
m_ui.StreamVoiceCountTextLabel->setPalette(pal); |
m_ui.StreamVoiceCountTextLabel->setPalette(pal); |
264 |
} |
} |
265 |
|
|
331 |
m_pChannel->editChannel(); |
m_pChannel->editChannel(); |
332 |
} |
} |
333 |
|
|
334 |
|
bool ChannelStrip::channelFxEdit (void) |
335 |
|
{ |
336 |
|
MainForm *pMainForm = MainForm::getInstance(); |
337 |
|
if (!pMainForm || !channel()) |
338 |
|
return false; |
339 |
|
|
340 |
|
pMainForm->appendMessages(QObject::tr("channel fx sends...")); |
341 |
|
|
342 |
|
bool bResult = false; |
343 |
|
|
344 |
|
#if CONFIG_FXSEND |
345 |
|
ChannelFxForm *pChannelFxForm = |
346 |
|
new ChannelFxForm(channel(), parentWidget()); |
347 |
|
if (pChannelFxForm) { |
348 |
|
//pChannelForm->setup(this); |
349 |
|
bResult = pChannelFxForm->exec(); |
350 |
|
delete pChannelFxForm; |
351 |
|
} |
352 |
|
#else // CONFIG_FXSEND |
353 |
|
QMessageBox::critical(this, |
354 |
|
QSAMPLER_TITLE ": " + tr("Unavailable"), |
355 |
|
tr("Sorry, QSampler was built without FX send support!\n\n" |
356 |
|
"(Make sure you have a recent liblscp when recompiling QSampler)")); |
357 |
|
#endif // CONFIG_FXSEND |
358 |
|
|
359 |
|
return bResult; |
360 |
|
} |
361 |
|
|
362 |
// Channel reset slot. |
// Channel reset slot. |
363 |
bool ChannelStrip::channelReset (void) |
bool ChannelStrip::channelReset (void) |
389 |
if (m_pChannel->instrumentName().isEmpty()) { |
if (m_pChannel->instrumentName().isEmpty()) { |
390 |
if (m_pChannel->instrumentStatus() >= 0) { |
if (m_pChannel->instrumentStatus() >= 0) { |
391 |
m_ui.InstrumentNameTextLabel->setText( |
m_ui.InstrumentNameTextLabel->setText( |
392 |
' ' + qsamplerChannel::loadingInstrument()); |
' ' + Channel::loadingInstrument()); |
393 |
} else { |
} else { |
394 |
m_ui.InstrumentNameTextLabel->setText( |
m_ui.InstrumentNameTextLabel->setText( |
395 |
' ' + qsamplerChannel::noInstrumentName()); |
' ' + Channel::noInstrumentName()); |
396 |
} |
} |
397 |
} else { |
} else { |
398 |
m_ui.InstrumentNameTextLabel->setText( |
m_ui.InstrumentNameTextLabel->setText( |
451 |
// Engine name... |
// Engine name... |
452 |
if (m_pChannel->engineName().isEmpty()) { |
if (m_pChannel->engineName().isEmpty()) { |
453 |
m_ui.EngineNameTextLabel->setText( |
m_ui.EngineNameTextLabel->setText( |
454 |
' ' + qsamplerChannel::noEngineName()); |
' ' + Channel::noEngineName()); |
455 |
} else { |
} else { |
456 |
m_ui.EngineNameTextLabel->setText( |
m_ui.EngineNameTextLabel->setText( |
457 |
' ' + m_pChannel->engineName()); |
' ' + m_pChannel->engineName()); |
494 |
// Mute/Solo button state coloring... |
// Mute/Solo button state coloring... |
495 |
bool bMute = m_pChannel->channelMute(); |
bool bMute = m_pChannel->channelMute(); |
496 |
const QColor& rgbButton = pal.color(QPalette::Button); |
const QColor& rgbButton = pal.color(QPalette::Button); |
497 |
|
const QColor& rgbButtonText = pal.color(QPalette::ButtonText); |
498 |
pal.setColor(QPalette::Foreground, rgbFore); |
pal.setColor(QPalette::Foreground, rgbFore); |
499 |
pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton); |
pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton); |
500 |
|
pal.setColor(QPalette::ButtonText, bMute ? Qt::darkYellow : rgbButtonText); |
501 |
m_ui.ChannelMutePushButton->setPalette(pal); |
m_ui.ChannelMutePushButton->setPalette(pal); |
502 |
m_ui.ChannelMutePushButton->setDown(bMute); |
m_ui.ChannelMutePushButton->setDown(bMute); |
503 |
bool bSolo = m_pChannel->channelSolo(); |
bool bSolo = m_pChannel->channelSolo(); |
504 |
pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); |
pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); |
505 |
|
pal.setColor(QPalette::ButtonText, bSolo ? Qt::darkCyan : rgbButtonText); |
506 |
m_ui.ChannelSoloPushButton->setPalette(pal); |
m_ui.ChannelSoloPushButton->setPalette(pal); |
507 |
m_ui.ChannelSoloPushButton->setDown(bSolo); |
m_ui.ChannelSoloPushButton->setDown(bSolo); |
508 |
#else |
#else |
586 |
} |
} |
587 |
|
|
588 |
|
|
589 |
|
void ChannelStrip::midiActivityLedOn (void) |
590 |
|
{ |
591 |
|
m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOn); |
592 |
|
m_pMidiActivityTimer->start(100); |
593 |
|
} |
594 |
|
|
595 |
|
|
596 |
|
void ChannelStrip::midiActivityLedOff (void) |
597 |
|
{ |
598 |
|
m_ui.MidiActivityLabel->setPixmap(*g_pMidiActivityLedOff); |
599 |
|
} |
600 |
|
|
601 |
|
|
602 |
// Error count hackish accessors. |
// Error count hackish accessors. |
603 |
void ChannelStrip::resetErrorCount (void) |
void ChannelStrip::resetErrorCount (void) |
604 |
{ |
{ |