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:
committed by
Oskar Wallgren
parent
6df6f12a3d
commit
c1ae1ed5f4
@@ -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);
|
||||
|
||||
@@ -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 );
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user