MIDI import: ensure minimum note length 1 tick

Too short notes had their duration rounded down to 0 on import,
as MIDI precision allows way shorter notes than LMMS, and
portsmf reports the duration as a double, where a beat == 1.0.

Was going to use ceil() first, but that might round some notes
up to a slightly longer duration.
This commit is contained in:
Raine M. Ekman
2015-04-24 22:26:31 +03:00
parent ff44854cde
commit 2a72d5f119

View File

@@ -357,7 +357,7 @@ bool MidiImport::readSMF( TrackContainer* tc )
// Tracks
for( int t = 0; t < seq->tracks(); ++t )
{
QString trackName = "";
QString trackName = QString("Track %1").arg(t);
Alg_track_ptr trk = seq->track( t );
pd.setValue( t + preTrackSteps );
@@ -402,8 +402,8 @@ bool MidiImport::readSMF( TrackContainer* tc )
{
smfMidiChannel * ch = chs[evt->chan].create( tc, trackName );
Alg_note_ptr noteEvt = dynamic_cast<Alg_note_ptr>( evt );
Note n( noteEvt->get_duration() * ticksPerBeat,
double ticks = MidiTime( noteEvt->get_duration() * ticksPerBeat );
Note n( (ticks < 1 ? 1 : ticks ),
noteEvt->get_start_time() * ticksPerBeat,
noteEvt->get_identifier() - 12,
noteEvt->get_loud());