Skip to content

Commit

Permalink
fix repeat playback of dynamics, other various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jthistle committed Jan 27, 2019
1 parent 48e80cd commit c57a39d
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 80 deletions.
5 changes: 5 additions & 0 deletions libmscore/dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ QString Dynamic::speedToName(Speed speed)
qFatal("Unrecognised change speed!");
}


//---------------------------------------------------------
// nameToSpeed
//---------------------------------------------------------

Dynamic::Speed Dynamic::nameToSpeed(QString name)
{
for (auto i : Dynamic::changeSpeedTable) {
Expand Down
4 changes: 4 additions & 0 deletions libmscore/hairpin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ QString Hairpin::veloChangeMethodToName(VeloChangeMethod method)
qFatal("Unrecognised velo change method!");
}

//---------------------------------------------------------
// nameToVeloChangeMethod
//---------------------------------------------------------

VeloChangeMethod Hairpin::nameToVeloChangeMethod(QString name)
{
for (auto i : Hairpin::veloChangeMethodTable) {
Expand Down
33 changes: 19 additions & 14 deletions libmscore/instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ void Instrument::write(XmlWriter& xml, Part* part) const
}
}

xml.tag("singleNoteDynamics", _singleNoteDynamics);
if (_singleNoteDynamics != getSingleNoteDynamicsFromTemplate())
xml.tag("singleNoteDynamics", _singleNoteDynamics);

if (!(_stringData == StringData()))
_stringData.write(xml);
Expand Down Expand Up @@ -785,31 +786,29 @@ void Channel::switchExpressive(MasterSynthesizer* m, bool expressive)
// normal counterparts, except on bank 0, where they are placed on bank 17
// and on bank 8, which uses bank 18 instead.
int searchBankNum;
int newBankNum;
if (expressive) {
int relativeBank = bank() % 129;
int newBankNum;
if (relativeBank == 0)
newBankNum = 17;
else if (relativeBank == 8)
newBankNum = 18;
else
newBankNum = relativeBank + 1;

searchBankNum = (bank()/129)*129 + newBankNum;
}
else {
int relativeBank = bank() % 129;
int newBankNum;
if (relativeBank == 17)
newBankNum = 0;
else if (relativeBank == 18)
newBankNum = 8;
else
newBankNum = relativeBank - 1;

searchBankNum = (bank()/129)*129 + newBankNum;
}

// Floor bank num to multiple of 129 and add new num to get bank num of new patch
searchBankNum = (bank() / 129) * 129 + newBankNum;

const auto& pl = m->getPatchInfo();
QString containString;
if (expressive)
Expand All @@ -831,8 +830,6 @@ void Channel::switchExpressive(MasterSynthesizer* m, bool expressive)
}
}
}

// qDebug() << "No expressive matches for patch " << channelPatchName;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1289,17 +1286,25 @@ Instrument Instrument::fromTemplate(const InstrumentTemplate* t)
}

//---------------------------------------------------------
// setSingleNoteDynamicsFromTemplate
// getSingleNoteDynamicsFromTemplate
//---------------------------------------------------------

void Instrument::setSingleNoteDynamicsFromTemplate()
bool Instrument::getSingleNoteDynamicsFromTemplate() const
{
QString templateName = trackName().toLower().replace(" ", "-");
InstrumentTemplate* tp = searchTemplate(templateName);
if (tp)
setSingleNoteDynamics(tp->singleNoteDynamics);
else if (templateName == "")
setSingleNoteDynamics(false);
return tp->singleNoteDynamics;
return false;
}

//---------------------------------------------------------
// setSingleNoteDynamicsFromTemplate
//---------------------------------------------------------

void Instrument::setSingleNoteDynamicsFromTemplate()
{
setSingleNoteDynamics(getSingleNoteDynamicsFromTemplate());
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/instrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class Instrument {
bool singleNoteDynamics() const { return _singleNoteDynamics; }
void setSingleNoteDynamics(bool val) { _singleNoteDynamics = val; }
void setSingleNoteDynamicsFromTemplate();
bool getSingleNoteDynamicsFromTemplate() const;
};

//---------------------------------------------------------
Expand Down
118 changes: 67 additions & 51 deletions libmscore/rendermidi.cpp

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4477,10 +4477,7 @@ void MasterScore::updateExpressive(MasterSynthesizer* m)
}
}

if (method == 0)
updateExpressive(m, false);
else
updateExpressive(m, true);
updateExpressive(m, (method != 0));
}


Expand Down
7 changes: 2 additions & 5 deletions mscore/inspector/inspectorDynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ void InspectorDynamic::valueChanged(int idx, bool b)

// Update min and max for velocity change input
int velocity = d.velocity->value();
d.changeInVelocity->setMinimum(1-velocity);
d.changeInVelocity->setMaximum(127-velocity);
d.changeInVelocity->setMinimum(1 - velocity);
d.changeInVelocity->setMaximum(127 - velocity);
}


} // namespace Ms

5 changes: 1 addition & 4 deletions mscore/synthcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,7 @@ void SynthControl::effectBChanged(int idx)

void SynthControl::dynamicsMethodChanged(int val)
{
if (val == 0)
ccToUseList->setEnabled(false);
else
ccToUseList->setEnabled(true);
ccToUseList->setEnabled(val != 0);
synti->setDynamicsMethod(val);
setDirty();
}
Expand Down
1 change: 0 additions & 1 deletion synthesizer/msynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ void MasterSynthesizer::setMasterTuning(double val)
for (Synthesizer* s : _synthesizer)
s->setMasterTuning(_masterTuning);
}

} // namespace Ms


5 changes: 4 additions & 1 deletion zerberus/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ void Channel::controller(int c, int val)
_panRightGain = sinf(M_PI_2 * float(val)/126.0);
}
else if (c == Ms::CTRL_VOLUME) {
_midiVolume = float(val)/127.0; // (float(val) * float(ctrl[Ms::CTRL_EXPRESSION])) / (127.0 * 127.0);
// This was previously:
// (float(val) * float(ctrl[Ms::CTRL_EXPRESSION])) / (127.0 * 127.0);
// which was a hack to include CC11 support for SFZ. If necessary, revert to this.
_midiVolume = float(val) / 127.0;
}
else if (c == Ms::CTRL_ALL_NOTES_OFF) {
for (Voice* v = _msynth->getActiveVoices(); v; v = v->next()) {
Expand Down

0 comments on commit c57a39d

Please sign in to comment.