From 2a72d5f119de59b02e0a56cd2622729eaa60ad2c Mon Sep 17 00:00:00 2001 From: "Raine M. Ekman" Date: Fri, 24 Apr 2015 22:26:31 +0300 Subject: [PATCH] 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. --- plugins/MidiImport/MidiImport.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index 0ec05af49..afc49e7bb 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -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( 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());