Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Midi import: various small improvements #2006

Merged
merged 7 commits into from
Jun 17, 2015
Merged

Conversation

softrabbit
Copy link
Member

A little mixed bag of short modifications here, longer descriptions are with their respective commits.

@@ -394,8 +401,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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is ticks declared as double instead of int? MidiTime only offers an int() cast operator, so casting to double should not give any benefit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aimed for the least possible change here. noteEvt->get_duration() returns a double, so there was a double going in to the constructor before.

@Wallacoloo
Copy link
Member

Just built your branch, and attempting to import "Sylver - Love is an Angel" from http://www.eurokdj.com/ringtones/index_midis.php reliably results in a crash, whereas it works with only warnings in master from a few days ago (edit: it works in current master as well):

FlpImport::tryImport(): not a valid FL project

Error reading song: song node not found
MidiImport::tryImport(): found MThd
MISSING GLOBAL THINGY
lmms: /home/colin/proj/lmms/plugins/MidiImport/portsmf/allegro.cpp:555: char *Alg_event::get_atom_value(): Assertion `get_update_type() == 'a'' failed.
Aborted (core dumped)

v.s. expected output:

FlpImport::tryImport(): not a valid FL project

Error reading song: song node not found
MidiImport::tryImport(): found MThd
MISSING GLOBAL HANDLER
     Chn: -1, Type Code: 9, Time: 0.000000, Update Type: sysexs
fluidsynth: error: There is no preset with bank number 0 and preset number 38 in SoundFont 0
fluidsynth: error: There is no preset with bank number 0 and preset number 80 in SoundFont 0
fluidsynth: error: There is no preset with bank number 0 and preset number 64 in SoundFont 0
fluidsynth: error: There is no preset with bank number 0 and preset number 81 in SoundFont 0
fluidsynth: error: There is no preset with bank number 0 and preset number 119 in SoundFont 0
fluidsynth: error: There is no preset with bank number 128 and preset number 0 in SoundFont 0

Note that I don't have any soundfonts installed (I've never used midi in lmms before).

@Wallacoloo
Copy link
Member

Also, I'd recommend that you add some inline documentation explaining why the code calls qApp->processEvents() if it's not too much trouble. Might be useful if imports are ever refactored to be threaded separately.

@softrabbit
Copy link
Member Author

@Wallacoloo, #1984 is the fix for that crash. Left my variant of that code out of this as that part was taken care of elsewhere. Guess I could rebase this now.

Should be enough to add the object to the automation pattern only once,
as the objModel variable that is added will always be the same for the
same value of ccid, which indexes the ccs array.

This will speed up creation of automation tracks for MIDI CCs and pitch
bend.
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.
Name the automation tracks like "[MIDI trackname] CC ##". And don't
call the automation track creation function for every CC event, as
it now will involve constructing a QString.
This should keep LMMS responsive from the window managers POV, unless
the user selects a huge enough default sound font that loading it
takes too long.
AFAIK, this is how the General MIDI standard says it should be.
@softrabbit
Copy link
Member Author

Added a few tweaks suggested by @midi-pascal and @tresf on the lmms-dev mailing list.

@midi-pascal
Copy link
Contributor

This would be very nice to have this PR integrated to the master branch.
I use it a lot and it works like a charm.
@tresf Do you think it is feasible since this PR has no side effect?

@tresf
Copy link
Member

tresf commented Jun 17, 2015

@tresf Do you think it is feasible since this PR has no side effect?

Absolutely, merged. Added to changelog.

FYI, @softrabbit has the ability to merge his own, so this is more a matter of waiting on peer review.

tresf added a commit that referenced this pull request Jun 17, 2015
Midi import: various small improvements
@tresf tresf merged commit 05d4b13 into LMMS:master Jun 17, 2015
@softrabbit
Copy link
Member Author

FYI, @softrabbit has the ability to merge his own, so this is more a matter of waiting on peer review.

Are you sure? I always get the text "Only those with write access to this repository can merge pull requests." and no obvious way to merge, so I've assumed that's the way it's meant to be.

@tresf
Copy link
Member

tresf commented Jun 17, 2015

Are you sure? I always get the text "Only those with write access to this repository can merge pull requests." and no obvious way to merge, so I've assumed that's the way it's meant to be.

Sorry. Fixed. :)

FYI, @softrabbit NOW has the ability to merge his own~~, so this is more a matter of waiting on peer review.~~

@midi-pascal
Copy link
Contributor

Wonderfull 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants