📄 midiinstrumentparameterpanel.cpp
字号:
bigStep, it->getDefault(), 20, Rotary::NoTicks, false, it->getDefault() == 64); //!!! hacky rotary->setKnobColour(knobColour); // Add a label QLabel *label = new KSqueezedTextLabel(strtoqstr(it->getName()), hbox); RG_DEBUG << "Adding new widget at " << (count / 2) << "," << (count % 2) << endl; // Add the compound widget // m_rotaryGrid->addWidget(hbox, count / 2, (count % 2) * 2, AlignLeft); hbox->show(); // Add to list // m_rotaries.push_back(std::pair<int, RotaryPair> (it->getControllerValue(), RotaryPair(rotary, label))); // Connect // connect(rotary, SIGNAL(valueChanged(float)), m_rotaryMapper, SLOT(map())); rmi = m_rotaries.end(); } // Add signal mapping // m_rotaryMapper->setMapping(rotary, int(it->getControllerValue())); count++; } if (rmi != m_rotaries.end()) { for (RotaryMap::iterator rmj = rmi; rmj != m_rotaries.end(); ++rmj) { delete rmj->second.first; delete rmj->second.second; } m_rotaries = std::vector<std::pair<int, RotaryPair> > (m_rotaries.begin(), rmi); } m_rotaryFrame->show();}voidMIDIInstrumentParameterPanel::setRotaryToValue(int controller, int value){ /* RG_DEBUG << "MIDIInstrumentParameterPanel::setRotaryToValue - " << "controller = " << controller << ", value = " << value << std::endl; */ for (RotaryMap::iterator it = m_rotaries.begin() ; it != m_rotaries.end(); ++it) { if (it->first == controller) { it->second.first->setPosition(float(value)); return ; } }}voidMIDIInstrumentParameterPanel::slotSelectChannel(int index){ if (m_selectedInstrument == 0) return ; m_selectedInstrument->setMidiChannel(index); // don't use the emit - use this method instead StudioControl::sendMappedInstrument( MappedInstrument(m_selectedInstrument)); emit updateAllBoxes();}voidMIDIInstrumentParameterPanel::populateBankList(){ if (m_selectedInstrument == 0) return ; m_bankValue->clear(); m_banks.clear(); MidiDevice *md = dynamic_cast<MidiDevice*> (m_selectedInstrument->getDevice()); if (!md) { RG_DEBUG << "WARNING: MIDIInstrumentParameterPanel::populateBankList:" << " No MidiDevice for Instrument " << m_selectedInstrument->getId() << endl; return ; } int currentBank = -1; BankList banks; /* RG_DEBUG << "MIDIInstrumentParameterPanel::populateBankList: " << "variation type is " << md->getVariationType() << endl; */ if (md->getVariationType() == MidiDevice::NoVariations) { banks = md->getBanks(m_selectedInstrument->isPercussion()); if (!banks.empty()) { if (m_bankLabel->isHidden()) { m_bankLabel->show(); m_bankCheckBox->show(); m_bankValue->show(); } } else { m_bankLabel->hide(); m_bankCheckBox->hide(); m_bankValue->hide(); } for (unsigned int i = 0; i < banks.size(); ++i) { if (m_selectedInstrument->getProgram().getBank() == banks[i]) { currentBank = i; } } } else { MidiByteList bytes; bool useMSB = (md->getVariationType() == MidiDevice::VariationFromLSB); if (useMSB) { bytes = md->getDistinctMSBs(m_selectedInstrument->isPercussion()); } else { bytes = md->getDistinctLSBs(m_selectedInstrument->isPercussion()); } if (bytes.size() < 2) { if (!m_bankLabel->isHidden()) { m_bankLabel->hide(); m_bankCheckBox->hide(); m_bankValue->hide(); } } else { if (m_bankLabel->isHidden()) { m_bankLabel->show(); m_bankCheckBox->show(); m_bankValue->show(); } } if (useMSB) { for (unsigned int i = 0; i < bytes.size(); ++i) { BankList bl = md->getBanksByMSB (m_selectedInstrument->isPercussion(), bytes[i]); RG_DEBUG << "MIDIInstrumentParameterPanel::populateBankList: have " << bl.size() << " variations for msb " << bytes[i] << endl; if (bl.size() == 0) continue; if (m_selectedInstrument->getMSB() == bytes[i]) { currentBank = banks.size(); } banks.push_back(bl[0]); } } else { for (unsigned int i = 0; i < bytes.size(); ++i) { BankList bl = md->getBanksByLSB (m_selectedInstrument->isPercussion(), bytes[i]); RG_DEBUG << "MIDIInstrumentParameterPanel::populateBankList: have " << bl.size() << " variations for lsb " << bytes[i] << endl; if (bl.size() == 0) continue; if (m_selectedInstrument->getLSB() == bytes[i]) { currentBank = banks.size(); } banks.push_back(bl[0]); } } } for (BankList::const_iterator i = banks.begin(); i != banks.end(); ++i) { m_banks.push_back(*i); m_bankValue->insertItem(strtoqstr(i->getName())); } m_bankValue->setEnabled(m_selectedInstrument->sendsBankSelect()); if (currentBank < 0 && !banks.empty()) { m_bankValue->setCurrentItem(0); slotSelectBank(0); } else { m_bankValue->setCurrentItem(currentBank); }}voidMIDIInstrumentParameterPanel::populateProgramList(){ if (m_selectedInstrument == 0) return ; m_programValue->clear(); m_programs.clear(); MidiDevice *md = dynamic_cast<MidiDevice*> (m_selectedInstrument->getDevice()); if (!md) { RG_DEBUG << "WARNING: MIDIInstrumentParameterPanel::populateProgramList: No MidiDevice for Instrument " << m_selectedInstrument->getId() << endl; return ; } /* RG_DEBUG << "MIDIInstrumentParameterPanel::populateProgramList:" << " variation type is " << md->getVariationType() << endl; */ MidiBank bank( m_selectedInstrument->isPercussion(), m_selectedInstrument->getMSB(), m_selectedInstrument->getLSB()); if (m_selectedInstrument->sendsBankSelect()) { bank = m_selectedInstrument->getProgram().getBank(); } int currentProgram = -1; ProgramList programs = md->getPrograms(bank); if (!programs.empty()) { if (m_programLabel->isHidden()) { m_programLabel->show(); m_programCheckBox->show(); m_programValue->show(); } } else { m_programLabel->hide(); m_programCheckBox->hide(); m_programValue->hide(); } for (unsigned int i = 0; i < programs.size(); ++i) { std::string programName = programs[i].getName(); if (programName != "") { m_programValue->insertItem(QString("%1. %2") .arg(programs[i].getProgram() + 1) .arg(strtoqstr(programName))); if (m_selectedInstrument->getProgram() == programs[i]) { currentProgram = m_programs.size(); } m_programs.push_back(programs[i]); } } m_programValue->setEnabled(m_selectedInstrument->sendsProgramChange()); if (currentProgram < 0 && !m_programs.empty()) { m_programValue->setCurrentItem(0); slotSelectProgram(0); } else { m_programValue->setCurrentItem(currentProgram); // Ensure that stored program change value is same as the one // we're now showing (BUG 937371) // if (!m_programs.empty()) { m_selectedInstrument->setProgramChange ((m_programs[m_programValue->currentItem()]).getProgram()); } }}voidMIDIInstrumentParameterPanel::populateVariationList(){ if (m_selectedInstrument == 0) return ; m_variationValue->clear(); m_variations.clear(); MidiDevice *md = dynamic_cast<MidiDevice*> (m_selectedInstrument->getDevice()); if (!md) { RG_DEBUG << "WARNING: MIDIInstrumentParameterPanel::populateVariationList: No MidiDevice for Instrument " << m_selectedInstrument->getId() << endl; return ; } /* RG_DEBUG << "MIDIInstrumentParameterPanel::populateVariationList:" << " variation type is " << md->getVariationType() << endl; */ if (md->getVariationType() == MidiDevice::NoVariations) { if (!m_variationLabel->isHidden()) { m_variationLabel->hide(); m_variationCheckBox->hide(); m_variationValue->hide(); } return ; } bool useMSB = (md->getVariationType() == MidiDevice::VariationFromMSB); MidiByteList variations; if (useMSB) { MidiByte lsb = m_selectedInstrument->getLSB(); variations = md->getDistinctMSBs(m_selectedInstrument->isPercussion(), lsb); RG_DEBUG << "MIDIInstrumentParameterPanel::populateVariationList: have " << variations.size() << " variations for lsb " << lsb << endl; } else { MidiByte msb = m_selectedInstrument->getMSB(); variations = md->getDistinctLSBs(m_selectedInstrument->isPercussion(), msb); RG_DEBUG << "MIDIInstrumentParameterPanel::populateVariationList: have " << variations.size() << " variations for msb " << msb << endl; } m_variationValue->setCurrentItem( -1); MidiProgram defaultProgram; if (useMSB) { defaultProgram = MidiProgram (MidiBank(m_selectedInstrument->isPercussion(), 0, m_selectedInstrument->getLSB()), m_selectedInstrument->getProgramChange()); } else { defaultProgram = MidiProgram (MidiBank(m_selectedInstrument->isPercussion(), m_selectedInstrument->getMSB(), 0), m_selectedInstrument->getProgramChange()); } std::string defaultProgramName = md->getProgramName(defaultProgram); int currentVariation = -1; for (unsigned int i = 0; i < variations.size(); ++i) { MidiProgram program; if (useMSB) { program = MidiProgram (MidiBank(m_selectedInstrument->isPercussion(), variations[i], m_selectedInstrument->getLSB()), m_selectedInstrument->getProgramChange()); } else { program = MidiProgram (MidiBank(m_selectedInstrument->isPercussion(), m_selectedInstrument->getMSB(), variations[i]), m_selectedInstrument->getProgramChange()); } std::string programName = md->getProgramName(program); if (programName != "") { // yes, that is how you know whether it exists /* m_variationValue->insertItem(programName == defaultProgramName ? i18n("(default)") : strtoqstr(programName)); */ m_variationValue->insertItem(QString("%1. %2") .arg(variations[i] + 1) .arg(strtoqstr(programName))); if (m_selectedInstrument->getProgram() == program) { currentVariation = m_variations.size(); } m_variations.push_back(variations[i]); } } if (currentVariation < 0 && !m_variations.empty()) { m_variationValue->setCurrentItem(0); slotSelectVariation(0); } else { m_variationValue->setCurrentItem(currentVariation); } if (m_variations.size() < 2) { if (!m_variationLabel->isHidden()) { m_variationLabel->hide();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -