本文整理汇总了C++中MidiDevice::getPresentationInstruments方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiDevice::getPresentationInstruments方法的具体用法?C++ MidiDevice::getPresentationInstruments怎么用?C++ MidiDevice::getPresentationInstruments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidiDevice
的用法示例。
在下文中一共展示了MidiDevice::getPresentationInstruments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Rotary
void
MidiMixerWindow::setupTabs()
{
DeviceListConstIterator it;
MidiDevice *dev = 0;
InstrumentList instruments;
InstrumentList::const_iterator iIt;
int faderCount = 0, deviceCount = 1;
if (m_tabFrame)
delete m_tabFrame;
// Setup m_tabFrame
//
QWidget *blackWidget = new QWidget(this);
setCentralWidget(blackWidget);
QVBoxLayout *centralLayout = new QVBoxLayout;
blackWidget->setLayout(centralLayout);
m_tabWidget = new QTabWidget;
centralLayout->addWidget(m_tabWidget);
connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)),
this, SLOT(slotCurrentTabChanged(QWidget *)));
m_tabWidget->setTabPosition(QTabWidget::South);
setWindowTitle(tr("MIDI Mixer"));
setWindowIcon(IconLoader().loadPixmap("window-midimixer"));
for (it = m_studio->begin(); it != m_studio->end(); ++it) {
dev = dynamic_cast<MidiDevice*>(*it);
if (dev) {
// Get the control parameters that are on the IPB (and hence can
// be shown here too).
//
ControlList controls = getIPBForMidiMixer(dev);
instruments = dev->getPresentationInstruments();
// Don't add a frame for empty devices
//
if (!instruments.size())
continue;
m_tabFrame = new QFrame(m_tabWidget);
m_tabFrame->setContentsMargins(10, 10, 10, 10);
// m_tabFrame->setContentsMargins(5, 5, 5, 5); ???
QGridLayout *mainLayout = new QGridLayout(m_tabFrame);
// MIDI Mixer label
QLabel *label = new QLabel("", m_tabFrame);
mainLayout->addWidget(label, 0, 0, 0, 16, Qt::AlignCenter);
// control labels
for (size_t i = 0; i < controls.size(); ++i) {
label = new QLabel(QObject::tr(controls[i].getName().c_str()), m_tabFrame);
mainLayout->addWidget(label, i + 1, 0, Qt::AlignCenter);
}
// meter label
// (obsolete abandoned code deleted here)
// volume label
label = new QLabel(tr("Volume"), m_tabFrame);
mainLayout->addWidget(label, controls.size() + 2, 0,
Qt::AlignCenter);
// instrument label
label = new QLabel(tr("Instrument"), m_tabFrame);
label->setFixedWidth(80); //!!! this should come from metrics
mainLayout->addWidget(label, controls.size() + 3, 0,
Qt::AlignLeft);
int posCount = 1;
int firstInstrument = -1;
for (iIt = instruments.begin(); iIt != instruments.end(); ++iIt) {
// Add new fader struct
//
m_faders.push_back(new FaderStruct());
// Store the first ID
//
if (firstInstrument == -1)
firstInstrument = (*iIt)->getId();
// Add the controls
//
for (size_t i = 0; i < controls.size(); ++i) {
QColor knobColour = QColor(Qt::white);
if (controls[i].getColourIndex() > 0) {
Colour c =
m_document->getComposition().getGeneralColourMap().
getColourByIndex(controls[i].getColourIndex());
//.........这里部分代码省略.........
示例2: instrumentParametersChanged
void
MidiMixerWindow::slotControllerDeviceEventReceived(MappedEvent *e,
const void *preferredCustomer)
{
if (preferredCustomer != this)
return ;
RG_DEBUG << "MidiMixerWindow::slotControllerDeviceEventReceived: this one's for me" << endl;
raise();
// get channel number n from event
// get nth instrument on current tab
if (e->getType() != MappedEvent::MidiController)
return ;
unsigned int channel = e->getRecordedChannel();
MidiByte controller = e->getData1();
MidiByte value = e->getData2();
int tabIndex = m_tabWidget->currentIndex();
int i = 0;
for (DeviceList::const_iterator it = m_studio->begin();
it != m_studio->end(); ++it) {
MidiDevice *dev =
dynamic_cast<MidiDevice*>(*it);
if (!dev)
continue;
if (i != tabIndex) {
++i;
continue;
}
InstrumentList instruments = dev->getPresentationInstruments();
for (InstrumentList::const_iterator iIt =
instruments.begin(); iIt != instruments.end(); ++iIt) {
Instrument *instrument = *iIt;
if (instrument->getNaturalChannel() != channel)
continue;
ControlList cl = dev->getIPBControlParameters();
for (ControlList::const_iterator i = cl.begin();
i != cl.end(); ++i) {
if ((*i).getControllerValue() == controller) {
RG_DEBUG << "Setting controller " << controller << " for instrument " << instrument->getId() << " to " << value << endl;
instrument->setControllerValue(controller, value);
break;
}
}
slotUpdateInstrument(instrument->getId());
emit instrumentParametersChanged(instrument->getId());
}
break;
}
}
示例3: mE
void
MidiMixerWindow::sendControllerRefresh()
{
//!!! need to know if we have a current external controller device,
// as this is expensive
int tabIndex = m_tabWidget->currentIndex();
RG_DEBUG << "MidiMixerWindow::slotCurrentTabChanged: current is " << tabIndex << endl;
if (tabIndex < 0)
return ;
int i = 0;
for (DeviceList::const_iterator dit = m_studio->begin();
dit != m_studio->end(); ++dit) {
MidiDevice *dev = dynamic_cast<MidiDevice*>(*dit);
RG_DEBUG << "device is " << (*dit)->getId() << ", dev " << dev << endl;
if (!dev)
continue;
if (i != tabIndex) {
++i;
continue;
}
InstrumentList instruments = dev->getPresentationInstruments();
ControlList controls = getIPBForMidiMixer(dev);
RG_DEBUG << "device has " << instruments.size() << " presentation instruments, " << dev->getAllInstruments().size() << " instruments " << endl;
for (InstrumentList::const_iterator iIt =
instruments.begin(); iIt != instruments.end(); ++iIt) {
Instrument *instrument = *iIt;
if (!instrument->hasFixedChannel()) { continue; }
int channel = instrument->getNaturalChannel();
RG_DEBUG << "instrument is " << instrument->getId() << endl;
for (ControlList::const_iterator cIt =
controls.begin(); cIt != controls.end(); ++cIt) {
int controller = (*cIt).getControllerValue();
int value;
try {
value = instrument->getControllerValue(controller);
} catch (std::string s) {
std::cerr << "Exception in MidiMixerWindow::currentChanged: " << s << " (controller " << controller << ", instrument " << instrument->getId() << ")" << std::endl;
value = 0;
}
MappedEvent mE(instrument->getId(),
MappedEvent::MidiController,
controller, value);
mE.setRecordedChannel(channel);
mE.setRecordedDevice(Device::CONTROL_DEVICE);
StudioControl::sendMappedEvent(mE);
}
MappedEvent mE(instrument->getId(),
MappedEvent::MidiController,
MIDI_CONTROLLER_VOLUME,
instrument->getVolume());
mE.setRecordedChannel(channel);
mE.setRecordedDevice(Device::CONTROL_DEVICE);
RG_DEBUG << "sending controller mapped event for channel " << channel << ", volume " << instrument->getVolume() << endl;
StudioControl::sendMappedEvent(mE);
}
break;
}
}
示例4: blockSignals
void
MidiMixerWindow::slotUpdateInstrument(InstrumentId id)
{
//RG_DEBUG << "MidiMixerWindow::slotUpdateInstrument - id = " << id << endl;
DeviceListConstIterator it;
MidiDevice *dev = 0;
InstrumentList instruments;
InstrumentList::const_iterator iIt;
int count = 0;
blockSignals(true);
for (it = m_studio->begin(); it != m_studio->end(); ++it) {
dev = dynamic_cast<MidiDevice*>(*it);
if (dev) {
instruments = dev->getPresentationInstruments();
ControlList controls = getIPBForMidiMixer(dev);
for (iIt = instruments.begin(); iIt != instruments.end(); ++iIt) {
// Match and set
//
if ((*iIt)->getId() == id) {
// Set Volume fader
//
m_faders[count]->m_volumeFader->blockSignals(true);
MidiByte volumeValue;
try {
volumeValue = (*iIt)->
getControllerValue(MIDI_CONTROLLER_VOLUME);
} catch (std::string s) {
// This should never get called.
volumeValue = (*iIt)->getVolume();
}
m_faders[count]->m_volumeFader->setFader(float(volumeValue));
m_faders[count]->m_volumeFader->blockSignals(false);
/*
StaticControllers &staticControls =
(*iIt)->getStaticControllers();
RG_DEBUG << "STATIC CONTROLS SIZE = "
<< staticControls.size() << endl;
*/
// Set all controllers for this Instrument
//
for (size_t i = 0; i < controls.size(); ++i) {
float value = 0.0;
m_faders[count]->m_controllerRotaries[i].second->blockSignals(true);
// The ControllerValues might not yet be set on
// the actual Instrument so don't always expect
// to find one. There might be a hole here for
// deleted Controllers to hang around on
// Instruments..
//
try {
value = float((*iIt)->getControllerValue
(controls[i].getControllerValue()));
} catch (std::string s) {
/*
RG_DEBUG <<
"MidiMixerWindow::slotUpdateInstrument - "
<< "can't match controller "
<< int(controls[i].
getControllerValue()) << " - \""
<< s << "\"" << endl;
*/
continue;
}
/*
RG_DEBUG << "MidiMixerWindow::slotUpdateInstrument"
<< " - MATCHED "
<< int(controls[i].getControllerValue())
<< endl;
*/
m_faders[count]->m_controllerRotaries[i].
second->setPosition(value);
m_faders[count]->m_controllerRotaries[i].second->blockSignals(false);
}
}
count++;
}
}
}
blockSignals(false);
}