本文整理汇总了C++中MidiDevice::getVariationType方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiDevice::getVariationType方法的具体用法?C++ MidiDevice::getVariationType怎么用?C++ MidiDevice::getVariationType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidiDevice
的用法示例。
在下文中一共展示了MidiDevice::getVariationType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSelectedInstrument
void
MIDIInstrumentParameterPanel::slotSelectProgram(int index)
{
RG_DEBUG << "slotSelectProgram()";
if (!getSelectedInstrument())
return;
MidiDevice *md =
dynamic_cast<MidiDevice *>(getSelectedInstrument()->getDevice());
if (!md)
return;
const MidiProgram *prg = &m_programs[index];
// If there has been no change, bail.
if (getSelectedInstrument()->getProgramChange() == prg->getProgram())
return;
getSelectedInstrument()->setProgramChange(prg->getProgram());
// In Variations mode, select the 0th variation.
// In Variations mode, it's very easy to select an "invalid"
// program change. I.e. one for which the bank is not valid. Go
// from one program/variation to a program that doesn't have that
// variation. We need to handle that here by selecting the 0th
// variation. That's what the user expects.
if (md->getVariationType() == MidiDevice::VariationFromMSB) {
MidiBank bank = getSelectedInstrument()->getProgram().getBank();
// Get the list of MSB variations.
BankList bankList = md->getBanksByLSB(
getSelectedInstrument()->isPercussion(), bank.getLSB());
if (!bankList.empty()) {
// Pick the first MSB variation
getSelectedInstrument()->setMSB(bankList.front().getMSB());
}
}
if (md->getVariationType() == MidiDevice::VariationFromLSB) {
MidiBank bank = getSelectedInstrument()->getProgram().getBank();
// Get the list of LSB variations.
BankList bankList = md->getBanksByMSB(
getSelectedInstrument()->isPercussion(), bank.getMSB());
if (!bankList.empty()) {
// Pick the first LSB variation
getSelectedInstrument()->setLSB(bankList.front().getLSB());
}
}
getSelectedInstrument()->sendChannelSetup();
// Just one change notification for the two potential changes.
// See comments in slotSelectBank() for further discussion.
getSelectedInstrument()->changed();
}
示例2: Device
MidiDevice::MidiDevice(DeviceId id,
InstrumentId ibase,
const MidiDevice &dev) :
Device(id, dev.getName(), Device::Midi),
m_programList(dev.m_programList),
m_bankList(dev.m_bankList),
m_controlList(0),
m_keyMappingList(dev.m_keyMappingList),
m_metronome(0),
m_direction(dev.getDirection()),
m_variationType(dev.getVariationType()),
m_librarian(dev.getLibrarian()),
m_allocator(new AllocateChannels(ChannelSetup::MIDI))
{
createInstruments(ibase);
// Populate device and Instrument with Controllers.
ControlList::const_iterator cIt = dev.m_controlList.begin();
for(; cIt != dev.m_controlList.end(); ++cIt) {
addControlParameter(*cIt, true);
}
// Create and assign a metronome if required
//
if (dev.getMetronome()) {
m_metronome = new MidiMetronome(*dev.getMetronome());
}
generatePresentationList();
}
示例3:
void
ModifyDeviceCommand::execute()
{
Device *device = m_studio->getDevice(m_device);
if (!device) {
std::cerr << "ERROR: ModifyDeviceCommand::execute(): no such device as " << m_device << std::endl;
return;
}
MidiDevice *midiDevice = dynamic_cast<MidiDevice *>(device);
if (!midiDevice) {
std::cerr << "ERROR: ModifyDeviceCommand::execute(): device " << m_device << " is not a MIDI device" << std::endl;
return;
}
// Save Original Values for Undo
// ??? Really wish we could just m_oldDevice = *(midiDevice). See below.
m_oldName = midiDevice->getName();
m_oldBankList = midiDevice->getBanks();
m_oldProgramList = midiDevice->getPrograms();
m_oldControlList = midiDevice->getControlParameters();
m_oldKeyMappingList = midiDevice->getKeyMappings();
m_oldLibrarianName = midiDevice->getLibrarianName();
m_oldLibrarianEmail = midiDevice->getLibrarianEmail();
m_oldVariationType = midiDevice->getVariationType();
InstrumentList instruments = midiDevice->getAllInstruments();
for (size_t i = 0; i < instruments.size(); ++i) {
// ??? Preserving just the programs isn't enough. We need
// to preserve the rest of the Instrument as well. However,
// the auto/fixed channel feature has made it impossible
// to safely make copies of Instrument objects. Also, Instrument
// has an ID. How should that be handled for undo? ISTM
// that we either need to introduce some sort of copyForUndo()
// hack to each object, or develop a set of standards for coding
// objects that are undo-safe. Sounds like a pretty big project.
m_oldInstrumentPrograms.push_back(instruments[i]->getProgram());
}
// Make the Changes
if (m_changeVariation)
midiDevice->setVariationType(m_variationType);
if (m_overwrite) {
if (m_clearBankAndProgramList) {
midiDevice->clearBankList();
midiDevice->clearProgramList();
midiDevice->clearKeyMappingList();
} else {
if (m_changeBanks)
midiDevice->replaceBankList(m_bankList);
if (m_changePrograms)
midiDevice->replaceProgramList(m_programList);
if (m_changeBanks || m_changePrograms) {
// Make sure the instruments make sense.
for (size_t i = 0; i < instruments.size(); ++i) {
instruments[i]->pickFirstProgram(
midiDevice->isPercussionNumber(i));
}
}
}
if (m_changeKeyMappings) {
midiDevice->replaceKeyMappingList(m_keyMappingList);
}
if (m_rename)
midiDevice->setName(m_name);
midiDevice->setLibrarian(m_librarianName, m_librarianEmail);
} else {
if (m_clearBankAndProgramList) {
midiDevice->clearBankList();
midiDevice->clearProgramList();
} else {
if (m_changeBanks)
midiDevice->mergeBankList(m_bankList);
if (m_changePrograms)
midiDevice->mergeProgramList(m_programList);
}
if (m_changeKeyMappings) {
midiDevice->mergeKeyMappingList(m_keyMappingList);
}
if (m_rename) {
std::string mergeName = midiDevice->getName() +
std::string("/") + m_name;
midiDevice->setName(mergeName);
}
}
//!!! merge option?
if (m_changeControls) {
midiDevice->replaceControlParameters(m_controlList);
}
// ??? Instead of this kludge, we should be calling a Studio::hasChanged()
// which would then notify all observers (e.g. MIPP) who, in turn,
// would update themselves.
//.........这里部分代码省略.........
示例4: program
void
MIDIInstrumentParameterPanel::updateVariationComboBox()
{
RG_DEBUG << "updateVariationComboBox() begin...";
if (!getSelectedInstrument())
return;
MidiDevice *md =
dynamic_cast<MidiDevice *>(getSelectedInstrument()->getDevice());
if (!md) {
std::cerr << "WARNING: MIDIInstrumentParameterPanel::updateVariationComboBox(): No MidiDevice for Instrument " << getSelectedInstrument()->getId() << '\n';
return;
}
RG_DEBUG << "updateVariationComboBox(): Variation type is " << md->getVariationType();
if (md->getVariationType() == MidiDevice::NoVariations) {
showVariation(false);
return;
}
// Get the variations.
bool useMSB = (md->getVariationType() == MidiDevice::VariationFromMSB);
MidiByteList variationBanks;
if (useMSB) {
MidiByte lsb = getSelectedInstrument()->getLSB();
variationBanks = md->getDistinctMSBs(getSelectedInstrument()->isPercussion(),
lsb);
RG_DEBUG << "updateVariationComboBox(): Have " << variationBanks.size() << " variations for LSB " << lsb;
} else {
MidiByte msb = getSelectedInstrument()->getMSB();
variationBanks = md->getDistinctLSBs(getSelectedInstrument()->isPercussion(),
msb);
RG_DEBUG << "updateVariationComboBox(): Have " << variationBanks.size() << " variations for MSB " << msb;
}
// Convert variationBanks to a ProgramList.
ProgramList variations;
// For each variation
for (size_t i = 0; i < variationBanks.size(); ++i) {
// Assemble the program for the variation.
MidiBank bank;
if (useMSB) {
bank = MidiBank(getSelectedInstrument()->isPercussion(),
variationBanks[i],
getSelectedInstrument()->getLSB());
} else {
bank = MidiBank(getSelectedInstrument()->isPercussion(),
getSelectedInstrument()->getMSB(),
variationBanks[i]);
}
MidiProgram program(bank, getSelectedInstrument()->getProgramChange());
// Skip any programs without names.
if (md->getProgramName(program) == "")
continue;
variations.push_back(program);
}
// Compute the current variation.
// ??? This might be combined into the previous for loop.
int currentVariation = -1;
// For each variation
for (size_t i = 0; i < variations.size(); ++i) {
if (getSelectedInstrument()->getProgram().partialCompare(variations[i])) {
currentVariation = i;
break;
}
}
// If the variations have changed, repopulate the combobox.
if (!partialCompareWithName(variations, m_variations)) {
RG_DEBUG << "updateVariationComboBox(): Repopulating the combobox";
// Update the cache.
m_variations = variations;
// Copy from m_variations to m_variationComboBox.
m_variationComboBox->clear();
for (size_t i = 0; i < m_variations.size(); ++i) {
std::string programName = md->getProgramName(m_variations[i]);
// Pick the correct bank number.
MidiBank bank = m_variations[i].getBank();
MidiByte variationBank = useMSB ? bank.getMSB() : bank.getLSB();
m_variationComboBox->addItem(QObject::tr("%1. %2")
.arg(variationBank)
.arg(QObject::tr(programName.c_str())));
}
//.........这里部分代码省略.........