Our note velocity go from 0 - 200 but midi note velocity is 0 - 127. In our export code we set anything over 127 to 127 so a track using the full range in lmms will export wrong.
Example issue reported in the forum: https://lmms.io/forum/viewtopic.php?f=7&t=29497
Can we just divide note velocity in two when exporting?
Example, crude but working:
mnote.volume = qMin(qRound(base_volume * 0.635 * LocaleHelper::toDouble(note.attribute("vol", "100"))), 127);
@PhysSong
Change title because I got it wrong. Our velocity seem to go from 0-200. To convert we need to multiply our velocity by 127/200=0.635 to use the full dynamic of the MIDI velocity range. Updated snippet above.
Example, crude but working:
mnote.volume = qMin(qRound(base_volume * 0.635 * LocaleHelper::toDouble(note.attribute("vol", "100"))), 127);
It looks fine to me. I think 0.635 might look unclear at the first look though. We can either add a comment or write this as (127.f / 200.f).
We can either add a comment or write this as
(127.f / 200.f).
Yeah, something is needed or there will be confusion later on. I think a comment with that piece of math and then use const double convertToMIDI = 0.635.
MIDI import may have to be changed too. I'm curious if the internal values were given headroom over original MIDI for a particular reason.
noteEvt->get_loud() / 0.635f );
Equivalent action on import.
_Edit: With this change you can import/export/import... etc. and the values will remain the same. Without the volume will be continuously going down for every import action. Not that people are going to do this more than one way and more than once. Not many anyway._
@zonkmachine Nice catch, thank you!