From 65762d089811c6f0a197bc9cc635e645eae9ee81 Mon Sep 17 00:00:00 2001 From: Hyunjin Song Date: Mon, 21 Jan 2019 16:00:54 +0900 Subject: [PATCH 1/2] MIDI export: map volume to MIDI velocity correctly --- plugins/MidiExport/MidiExport.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/MidiExport/MidiExport.cpp b/plugins/MidiExport/MidiExport.cpp index 65eaf46132b..20bda52b385 100644 --- a/plugins/MidiExport/MidiExport.cpp +++ b/plugins/MidiExport/MidiExport.cpp @@ -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); From ee70aa562a70cb6318b68758d9d7c3738f626e88 Mon Sep 17 00:00:00 2001 From: Hyunjin Song Date: Mon, 21 Jan 2019 16:01:35 +0900 Subject: [PATCH 2/2] MIDI import: map MIDI velocity to note volume with full range --- plugins/MidiImport/MidiImport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index 5fde7acc792..e83ef8c2736 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -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 ); }