void InstrumentTrackWindow::modelChanged() { m_track = castModel<InstrumentTrack>(); m_nameLineEdit->setText( m_track->name() ); m_track->disconnect( SIGNAL( nameChanged() ), this ); m_track->disconnect( SIGNAL( instrumentChanged() ), this ); connect( m_track, SIGNAL( nameChanged() ), this, SLOT( updateName() ) ); connect( m_track, SIGNAL( instrumentChanged() ), this, SLOT( updateInstrumentView() ) ); m_volumeKnob->setModel( &m_track->m_volumeModel ); m_panningKnob->setModel( &m_track->m_panningModel ); m_effectChannelNumber->setModel( &m_track->m_effectChannelModel ); m_pianoView->setModel( &m_track->m_piano ); if( m_track->instrument() && m_track->instrument()->flags().testFlag( Instrument::IsNotBendable ) == false ) { m_pitchKnob->setModel( &m_track->m_pitchModel ); m_pitchRangeSpinBox->setModel( &m_track->m_pitchRangeModel ); m_pitchKnob->show(); m_pitchLabel->show(); m_pitchRangeSpinBox->show(); m_pitchRangeLabel->show(); } else { m_pitchKnob->hide(); m_pitchLabel->hide(); m_pitchKnob->setModel( NULL ); m_pitchRangeSpinBox->hide(); m_pitchRangeLabel->hide(); } m_ssView->setModel( &m_track->m_soundShaping ); m_noteStackingView->setModel( &m_track->m_noteStacking ); m_arpeggioView->setModel( &m_track->m_arpeggio ); m_midiView->setModel( &m_track->m_midiPort ); m_effectView->setModel( m_track->m_audioPort.effects() ); updateName(); }
void EditStaff::apply() { Score* score = staff->score(); Part* part = staff->part(); int intervalIdx = iList->currentIndex(); bool upFlag = up->isChecked(); Interval interval = intervalList[intervalIdx]; interval.diatonic += octave->value() * 7; interval.chromatic += octave->value() * 12; if (!upFlag) interval.flip(); instrument.setTranspose(interval); instrument.setMinPitchA(_minPitchA); instrument.setMaxPitchA(_maxPitchA); instrument.setMinPitchP(_minPitchP); instrument.setMaxPitchP(_maxPitchP); instrument.setShortName(QTextDocumentFragment(shortName->document())); instrument.setLongName(QTextDocumentFragment(longName->document())); bool s = small->isChecked(); bool inv = invisible->isChecked(); qreal userDist = spinExtraDistance->value(); QColor col = color->color(); int staffIdx = staffType->itemData(staffType->currentIndex()).toInt(); StaffType* st = score->staffType(staffIdx); // before changing instrument, check if notes need to be updated // true if changing into or away from TAB or from one TAB type to another StaffGroup ng = st->group(); // new staff group StaffGroup og = staff->staffType()->group(); // old staff group bool updateNeeded = (ng == TAB_STAFF_GROUP && og != TAB_STAFF_GROUP) || (ng != TAB_STAFF_GROUP && og == TAB_STAFF_GROUP) || (ng == TAB_STAFF_GROUP && og == TAB_STAFF_GROUP && instrument.stringData() != part->instr()->stringData()); if (!(instrument == *part->instr()) || part->partName() != partName->text()) { score->undo(new ChangePart(part, instrument, partName->text())); emit instrumentChanged(); } if (s != staff->small() || inv != staff->invisible() || userDist != staff->userDist() || st != staff->staffType() || col != staff->color()) score->undo(new ChangeStaff(staff, s, inv, userDist * score->spatium(), col, st)); if (updateNeeded) score->cmdUpdateNotes(); score->setLayoutAll(true); score->update(); }
Instrument * InstrumentTrack::loadInstrument( const QString & _plugin_name ) { silenceAllNotes(); engine::getMixer()->lock(); delete m_instrument; m_instrument = Instrument::instantiate( _plugin_name, this ); engine::getMixer()->unlock(); emit instrumentChanged(); return m_instrument; }
void InstrumentTrackWindow::modelChanged() { m_track = castModel<InstrumentTrack>(); m_nameLineEdit->setText( m_track->name() ); m_track->disconnect( SIGNAL( nameChanged() ), this ); m_track->disconnect( SIGNAL( instrumentChanged() ), this ); connect( m_track, SIGNAL( nameChanged() ), this, SLOT( updateName() ) ); connect( m_track, SIGNAL( instrumentChanged() ), this, SLOT( updateInstrumentView() ) ); m_volumeKnob->setModel( &m_track->m_volumeModel ); m_panningKnob->setModel( &m_track->m_panningModel ); m_effectChannelNumber->setModel( &m_track->m_effectChannelModel ); m_pianoView->setModel( &m_track->m_piano ); if( m_track->instrument() && m_track->instrument()->isBendable() ) { m_pitchKnob->setModel( &m_track->m_pitchModel ); m_pitchRange->setModel( &m_track->m_pitchRangeModel ); m_pitchKnob->show(); } else { m_pitchKnob->hide(); m_pitchKnob->setModel( NULL ); } m_ssView->setModel( &m_track->m_soundShaping ); m_chordView->setModel( &m_track->m_chordCreator ); m_arpView->setModel( &m_track->m_arpeggiator ); m_midiView->setModel( &m_track->m_midiPort ); m_effectView->setModel( m_track->m_audioPort.effects() ); updateName(); }
Instrument * InstrumentTrack::loadInstrument( const QString & _plugin_name ) { silenceAllNotes( true ); lock(); delete m_instrument; m_instrument = Instrument::instantiate( _plugin_name, this ); unlock(); setName( m_instrument->displayName() ); emit instrumentChanged(); return m_instrument; }
void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & _this ) { silenceAllNotes(); engine::getMixer()->lock(); m_volumeModel.loadSettings( _this, "vol" ); // compat-hacks - move to mmp::upgrade if( _this.hasAttribute( "surpos" ) || _this.hasAttribute( "surpos-x" ) || !_this.firstChildElement( "automationpattern" ). firstChildElement( "surpos-x" ).isNull() ) { surroundAreaModel m( this, this ); m.loadSettings( _this, "surpos" ); m_panningModel.setValue( m.x() * 100 / SURROUND_AREA_SIZE ); } else { m_panningModel.loadSettings( _this, "pan" ); } m_pitchRangeModel.loadSettings( _this, "pitchrange" ); m_pitchModel.loadSettings( _this, "pitch" ); m_effectChannelModel.loadSettings( _this, "fxch" ); if( _this.hasAttribute( "baseoct" ) ) { // TODO: move this compat code to mmp.cpp -> upgrade() baseNoteModel()->setInitValue( _this. attribute( "baseoct" ).toInt() * KeysPerOctave + _this.attribute( "basetone" ).toInt() ); } else { baseNoteModel()->loadSettings( _this, "basenote" ); } // clear effect-chain just in case we load an old preset without FX-data m_audioPort.effects()->clear(); QDomNode node = _this.firstChild(); while( !node.isNull() ) { if( node.isElement() ) { if( m_soundShaping.nodeName() == node.nodeName() ) { m_soundShaping.restoreState( node.toElement() ); } else if( m_chordCreator.nodeName() == node.nodeName() ) { m_chordCreator.restoreState( node.toElement() ); } else if( m_arpeggiator.nodeName() == node.nodeName() ) { m_arpeggiator.restoreState( node.toElement() ); } else if( m_midiPort.nodeName() == node.nodeName() ) { m_midiPort.restoreState( node.toElement() ); } else if( m_audioPort.effects()->nodeName() == node.nodeName() ) { m_audioPort.effects()->restoreState( node.toElement() ); } else if( node.nodeName() == "instrument" ) { delete m_instrument; m_instrument = NULL; m_instrument = Instrument::instantiate( node.toElement().attribute( "name" ), this ); m_instrument->restoreState( node.firstChildElement() ); emit instrumentChanged(); } // compat code - if node-name doesn't match any known // one, we assume that it is an instrument-plugin // which we'll try to load else if( AutomationPattern::classNodeName() != node.nodeName() && ControllerConnection::classNodeName() != node.nodeName() && !node.toElement().hasAttribute( "id" ) ) { delete m_instrument; m_instrument = NULL; m_instrument = Instrument::instantiate( node.nodeName(), this ); if( m_instrument->nodeName() == node.nodeName() ) { m_instrument->restoreState( node.toElement() ); } emit instrumentChanged(); } } node = node.nextSibling(); } engine::getMixer()->unlock(); }
void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement ) { silenceAllNotes( true ); lock(); m_volumeModel.loadSettings( thisElement, "vol" ); m_panningModel.loadSettings( thisElement, "pan" ); m_pitchRangeModel.loadSettings( thisElement, "pitchrange" ); m_pitchModel.loadSettings( thisElement, "pitch" ); m_effectChannelModel.setRange( 0, Engine::fxMixer()->numChannels()-1 ); m_effectChannelModel.loadSettings( thisElement, "fxch" ); m_baseNoteModel.loadSettings( thisElement, "basenote" ); m_useMasterPitchModel.loadSettings( thisElement, "usemasterpitch"); // clear effect-chain just in case we load an old preset without FX-data m_audioPort.effects()->clear(); QDomNode node = thisElement.firstChild(); while( !node.isNull() ) { if( node.isElement() ) { if( m_soundShaping.nodeName() == node.nodeName() ) { m_soundShaping.restoreState( node.toElement() ); } else if( m_noteStacking.nodeName() == node.nodeName() ) { m_noteStacking.restoreState( node.toElement() ); } else if( m_arpeggio.nodeName() == node.nodeName() ) { m_arpeggio.restoreState( node.toElement() ); } else if( m_midiPort.nodeName() == node.nodeName() ) { m_midiPort.restoreState( node.toElement() ); } else if( m_audioPort.effects()->nodeName() == node.nodeName() ) { m_audioPort.effects()->restoreState( node.toElement() ); } else if( node.nodeName() == "instrument" ) { delete m_instrument; m_instrument = NULL; m_instrument = Instrument::instantiate( node.toElement().attribute( "name" ), this ); m_instrument->restoreState( node.firstChildElement() ); emit instrumentChanged(); } // compat code - if node-name doesn't match any known // one, we assume that it is an instrument-plugin // which we'll try to load else if( AutomationPattern::classNodeName() != node.nodeName() && ControllerConnection::classNodeName() != node.nodeName() && !node.toElement().hasAttribute( "id" ) ) { delete m_instrument; m_instrument = NULL; m_instrument = Instrument::instantiate( node.nodeName(), this ); if( m_instrument->nodeName() == node.nodeName() ) { m_instrument->restoreState( node.toElement() ); } emit instrumentChanged(); } } node = node.nextSibling(); } updatePitchRange(); unlock(); }
void EditStaff::apply() { Score* score = orgStaff->score(); Part* part = orgStaff->part(); QString sn = shortName->toPlainText(); QString ln = longName->toPlainText(); if (!Text::validateText(sn) || !Text::validateText(ln)) { QMessageBox msgBox; msgBox.setText(tr("The instrument name is invalid.")); msgBox.exec(); return; } shortName->setPlainText(sn); // show the fixed text longName->setPlainText(ln); int intervalIdx = iList->currentIndex(); bool upFlag = up->isChecked(); Interval interval = intervalList[intervalIdx]; interval.diatonic += octave->value() * 7; interval.chromatic += octave->value() * 12; if (!upFlag) interval.flip(); instrument.setTranspose(interval); instrument.setMinPitchA(_minPitchA); instrument.setMaxPitchA(_maxPitchA); instrument.setMinPitchP(_minPitchP); instrument.setMaxPitchP(_maxPitchP); instrument.setShortName(sn); instrument.setLongName(ln); instrument.setSingleNoteDynamics(singleNoteDynamics->isChecked()); bool inv = invisible->isChecked(); ClefTypeList clefType = orgStaff->defaultClefType(); qreal userDist = spinExtraDistance->value(); bool ifEmpty = showIfEmpty->isChecked(); bool hideSystemBL = hideSystemBarLine->isChecked(); bool cutAway = cutaway->isChecked(); Staff::HideMode hideEmpty = Staff::HideMode(hideMode->currentIndex()); QString newPartName = partName->text().simplified(); bool instrumentFieldChanged = !(instrument == *part->instrument()); if (instrumentFieldChanged) clefType = instrument.clefType(orgStaff->rstaff()); if (instrumentFieldChanged || part->partName() != newPartName) { // instrument has changed Interval v1 = instrument.transpose(); Interval v2 = part->instrument()->transpose(); score->undo(new ChangePart(part, new Instrument(instrument), newPartName)); emit instrumentChanged(); if (v1 != v2) score->transpositionChanged(part, v2, _tickStart, _tickEnd); } orgStaff->undoChangeProperty(Pid::MAG, mag->value() / 100.0); orgStaff->undoChangeProperty(Pid::COLOR, color->color()); orgStaff->undoChangeProperty(Pid::SMALL, small->isChecked()); if (inv != orgStaff->invisible() || clefType != orgStaff->defaultClefType() || userDist != orgStaff->userDist() || cutAway != orgStaff->cutaway() || hideEmpty != orgStaff->hideWhenEmpty() || ifEmpty != orgStaff->showIfEmpty() || hideSystemBL != orgStaff->hideSystemBarLine() ) { score->undo(new ChangeStaff(orgStaff, inv, clefType, userDist * score->spatium(), hideEmpty, ifEmpty, cutAway, hideSystemBL)); } if ( !(*orgStaff->staffType(Fraction(0,1)) == *staff->staffType(Fraction(0,1))) ) { // updateNeeded |= (orgStaff->staffGroup() == StaffGroup::TAB || staff->staffGroup() == StaffGroup::TAB); score->undo(new ChangeStaffType(orgStaff, *staff->staffType(Fraction(0,1)))); } score->update(); score->masterScore()->updateChannel(); }