void Bank::createFromXml( istringstream& is, ProgramList& list ) { Document doc; try { doc.Parse( is.str(), true ); Node* moduleNode = doc.FirstChild( "Module", false ); if( moduleNode != NULL ) { Program* program = new Program(); createFromXml( is, *program ); list.push_back( program ); } else { Iterator< Element > it( "Program" ); for( it = it.begin( &doc ); it != it.end(); it++ ) { Program* program = new Program(); Element* programElement = it.Get(); readProgram( programElement, program ); list.push_back( program ); } } } catch( const exception& e ) { TRACE( e.what() ); } }
OnsetDetector::ProgramList OnsetDetector::getPrograms() const { ProgramList programs; programs.push_back(""); programs.push_back("General purpose"); programs.push_back("Soft onsets"); programs.push_back("Percussive onsets"); return programs; }
TemplateDetector::ProgramList TemplateDetector::getPrograms() const { ProgramList list; list.push_back("blow1"); list.push_back("blow2"); // If you have no programs, return an empty list (or simply don't // implement this function or getCurrentProgram/selectProgram) return list; }
PluginHostAdapter::ProgramList PluginHostAdapter::getPrograms() const { ProgramList list; for (unsigned int i = 0; i < m_descriptor->programCount; ++i) { list.push_back(m_descriptor->programs[i]); } return list; }
ProgramList MidiDevice::getPrograms(const MidiBank &bank) const { ProgramList programs; for (ProgramList::const_iterator it = m_programList.begin(); it != m_programList.end(); ++it) { if (it->getBank() == bank) programs.push_back(*it); } return programs; }
ProgramList MidiProgramsEditor::getBankSubset(const MidiBank &bank) { ProgramList program; ProgramList::iterator it; for (it = m_programList.begin(); it != m_programList.end(); ++it) { if (it->getBank() == bank) program.push_back(*it); } return 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()))); } } // Display the current variation. m_variationComboBox->setCurrentIndex(currentVariation); // Show the variation widgets in either of two cases: // 1. More than one variation is available for this program. // 2. The variation was not in the Device and there is a variation // to choose from. showVariation(m_variations.size() > 1 || (currentVariation == -1 && !m_variations.empty())); m_variationComboBox->setEnabled(getSelectedInstrument()->sendsBankSelect()); }