void MidiProgramsEditor::slotNewLSB(int value) { RG_DEBUG << "MidiProgramsEditor::slotNewLSB(" << value << ")\n"; m_lsb->blockSignals(true); int lsb; try { lsb = ensureUniqueLSB(value, value > getCurrentBank()->getLSB()); } catch (bool) { lsb = getCurrentBank()->getLSB(); } MidiBank newBank(m_percussion->isChecked(), m_msb->value(), lsb, getCurrentBank()->getName()); modifyCurrentPrograms(*getCurrentBank(), newBank); m_lsb->setValue(lsb); *getCurrentBank() = newBank; m_lsb->blockSignals(false); m_bankEditor->slotApply(); }
void Bank::load( const string& path, bool append ) { if( path.empty() ) return; if( append == false ) { clear(); path_ = path; } try { Document doc = Document( path ); doc.LoadFile(); Element* bankElement = doc.FirstChildElement( "Bank", true ); if( append == false ) { bankElement->GetAttribute( "name", &name_ ); bankElement->GetAttribute( "program", &programNum_ ); } Iterator< Element > it( "Program" ); for( it = it.begin( bankElement ); it != it.end(); it++ ) { Element* programElement = it.Get(); Program* program = new Program(); try { readProgram( programElement, program ); push_back( program ); } catch( const exception& e ) { // parse error, skip program TRACE( e.what() ); } } if( programNum_ >= (INT32)size() ) programNum_ = 0; if( append == false && programNum_ < (INT32)size() ) // create current program currentProgram_ = *at( programNum_ ); } catch( const exception& e ) // file error, use default program { TRACE( e.what() ); newBank( "New Bank.nexus", "New Bank", false ); } }