MIDI import/export: map note volume and MIDI velocity with their full range (#4785)

* MIDI export: map volume to MIDI velocity correctly

* MIDI import: map MIDI velocity to note volume with full range
This commit is contained in:
Hyunjin Song
2019-01-22 02:49:25 +09:00
committed by Oskar Wallgren
parent 6df6f12a3d
commit c1ae1ed5f4
2 changed files with 3 additions and 2 deletions

View File

@@ -274,7 +274,8 @@ void MidiExport::writePattern(MidiNoteVector &pat, QDomNode n,
// TODO interpret pan="0" fxch="0" pitchrange="1"
MidiNote mnote;
mnote.pitch = qMax(0, qMin(127, note.attribute("key", "0").toInt() + base_pitch));
mnote.volume = qMin(qRound(base_volume * LocaleHelper::toDouble(note.attribute("vol", "100"))), 127);
// Map from LMMS volume to MIDI velocity
mnote.volume = qMin(qRound(base_volume * LocaleHelper::toDouble(note.attribute("vol", "100")) * (127.0 / 200.0)), 127);
mnote.time = base_time + note.attribute("pos", "0").toInt();
mnote.duration = note.attribute("len", "0").toInt();
pat.push_back(mnote);

View File

@@ -426,7 +426,7 @@ bool MidiImport::readSMF( TrackContainer* tc )
Note n( (ticks < 1 ? 1 : ticks ),
noteEvt->get_start_time() * ticksPerBeat,
noteEvt->get_identifier() - 12,
noteEvt->get_loud());
noteEvt->get_loud() * (200.f / 127.f)); // Map from MIDI velocity to LMMS volume
ch->addNote( n );
}