-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 export doesn't handle B&B tracks correctly #2384
Comments
Hi @grejppi , thanks for reporting the bug. Could you attach a sample affected lmms project? |
@mohamed--abdel-maksoud: The project used in the screenshots is |
OK, I will look into the bug some time next week (unless someone else is working on it already) |
More information: The bug does not seem to affect only the MIDI exporter. Problems can be seen even when saving an uncompressed (*.mmp) project file. Even if the project has more than one BB track, all notes are saved in the first BB track. |
What? I get notes in all BB tracks, like this:
(and it sounds reasonably like music, too 😃 ) Using master, up to date: de7d83d |
Everything looks fine when the file is opened on LMMS. Nevertheless, by opening the uncompressed file on a plain text editor, one can see all notes saved in the first BB track. |
Oh, now I see what you mean... I tried an It does explain why the MIDI export fails, though. Looks like the export reads the XML and creates the MIDI from that, instead of reading straight from the song. And it assumes any |
Good find! 👍 In fact ..
|
@mohamed--abdel-maksoud can you please address the issues noted above so that we can make this feature available in the next release? If not, we be forced to keep this feature disabled. |
Marking this as critical, since this needs to be addressed for 1.2, or we'll need to disable the MIDI Export function. Also, when a midi file is exported, there is no visual confirmation that the job has been done (a notification bubble would be sufficient for that). Also there seems to be some debugging info left, since I get my terminal spammed with
or similar when I export midi. |
Hi, |
We'd like to get a beta release out next month (Feb), since we're wrapping up most critical issues now. |
OK, I'll look at the issues from tomorrow. Hopefully they'll be fixed in time. |
I am not sure if i have a updated midi-export binary, (zonkmaschines distro) I know it is not merged! But if i try to re-import an lmms-exported midi, it fails completely. Everything is inserted in one track, and timing also seems to be off |
In the beta, we may just alert the user that midi exporting won't work well with BB tracks... |
No. That's not fixing the problem, its sweeping it under a rug. |
Yes 👍 Imo midi export could / should be postponed to 1,2,1. Even though it has been mentioned now and then, no one has promised midi-export. 1.2 will still be a bundle of goodies! |
But if we make it accessible we can test it even more and discover a lot more bugs that may lead us to the real problem... I'm not saying to put it in 1.2 (or RC), I was talking about the beta. |
Quite frankly the real problem is that MIDI data is not rendered in the same way as with audio export... The current method blindly looks for instrument patterns in the project file and converts them into MIDI notes at appropriate positions. Instrument patterns inside the B&B editor also have a position property, but it is used only to determine which B&B pattern it belongs to. It's impossible to tell a B&B instrument pattern from a pattern in the song editor just by looking at the individual element without context. |
A most interesting issue... Some observations:
Changing the way the track-to-XML-conversion is handled right now could fix the B&B exporting bug (the data needed to process B&B tracks correctly is there, it's just not used yet). However, I wonder if it would be a better idea to get rid of the XML conversion entirely and just work with LMMS's objects themselves. How stable is that structure expected to be compared to the XML representation? Fixing the export/re-import bug seems complicated enough to warrant its own issue, so I propose to redirect further discussion on that elsewhere. |
insightful remarks in the last two posts.
|
After giving more thought to how this would be implemented, I realize that there is another issue we need to address first: how are B&B tracks expected to be exported? MIDI has no support for defining patterns and repeating them AFAIK. All we can render are notes and events at certain times, possibly split out in tracks. Because a B&B track can play notes to multiple instruments, putting all notes in a single MIDI track means a loss of information. For drum patterns, this could be solved by putting the notes for each instrument on a different tone, but B&B patterns can contain melodies as well, which wouldn't work well with that approach. A different approach would be to export the notes of the song as a whole. That would mean processing B&B tracks into the resulting notes to their instruments, and then exporting those instruments as MIDI tracks. Importing such a MIDI file, assigning the right instruments to the tracks and playing would result in a faithful reproduction of the whole song. However, the individual B&B patterns would be lost and require manual copying and pasting of notes to be restored. FL Studio "fixes" this problem by not allowing to export the whole song to MIDI at all. It only exports the individual patterns and leaves you to redo the arrangement in the program in which you import it. LMMS, however, allows notes that exist only in the song editor, meaning that FL studio's approach won't work. Perhaps the best solution for LMMS would be to export the notes of the song as a whole by default, and allow exporting individual B&B patterns for those who want to use those in a different program. Thoughts? |
Let's try to understand the users' needs. Exporting a single instrument track is already a good thing, as most of the times midi is used to copy notes between programs. Most likely, it would be used to create a midi song intended for listening or to pass the project to another program. In both cases, keeping the bb patterns is not needed (or trying to leave clues for LMMS to recreate them). So the only problem I see here is passing from bb editor tracks to instruments and drumkit midi tracks, as fastigium said. Since automatically detecting the kind of instrument isn't an option, we will need the user to do the job of joining all the drum samples into a single track using a general midi soundfont. In the end, if the the midi file is made for listening, the user should edit it as he intends it to be heard, full of sf2 tracks, just as an imported midi. If it is not, then keeping the instruments is probably not important. Note that general midi doesn't have single samples patches, it only has drumkits. |
@DeRobyJ Imo it would even be acceptable to mint the user to exchange all instruments in the project manually for SF2generalUser presets, and manually select the patch for each instrument, Then LMMS should then export a midi-file with the content. So ok, a midi export is not a one-click-wonder.. So what? One issue that still could be a plague is the inserts on the presets FX-page. If the original LMMS projects uses VST-effects there, then what? schedule imo 1.2.1 or later |
@zonkmachine, how does that MIDI file behave when importing in something else? That would probably be the most common case. And it could be that the import code is less than perfect... |
Indeed, if I open the same file in MusE it looks correct. |
Did you look into this any further? I tried the online converter just briefly and it made a correct export of the demo project |
I'm working on it because I need MIDI export feature now. @DeRobyJ's approach seems good for me. I found notes with length -192 inside B&B patterns. Handling these notes is important because it might cause underflow or other bugs. |
It is in Event::writeToBuffer(), file MidiFile.hpp. When fixing is finished, marking that as a comment seems fine. |
A bit off topic... MidiFile.hpp lacks a license. It references one but the actual license text isn't there.
I did a search and found:
I just assume that if it's got 'Debian' stuck to it, the license has been reviewed thoroughly. |
printf() here. I think so too but I would add the excplicit braces //for( int i=0; i<3; i++ ) { printf("%02x ", fourbytes[i+1]); }
//printf("\n"); Or remove it completely... |
@zonkmachine Sure, I can do the modifications (immediately?) |
Right now is fine! ;-)
👍 |
The rewrite can and should be relicensed GPL2. The MIT license is compatible and leaving the original copyright should fulfill the needs of the original MIT. Please edit the file to use the standard GPL2 heading and change the python reference to mention the original license by name only so that others wishing to use the code under MIT specifically can go back to it as they wish. Gaining mohammed's permission to use GPL2 is a nice gesture, but it's irrelevant. We can legally use this file MIT, therefore we can use it GPL2. |
I found another bug of MIDI export: If two notes have the same pitch and one note starts at the position where another note ends, sometimes some exported notes have wrong lengths. |
Sorry,missed this part. @mohamed--abdel-maksoud was the original intent to keep MIT, GPL2+ or use another license. We must operate under the assumption that any code not specified is GPL2+. |
@tresf I ported the code for MIDI output from this MIT-licensed project (https://code.google.com/archive/p/midiutil/). As I'm not an expert in OS licenses, I played safe and kept the license of the original code: MIT. |
It's proper because it's less confusing to those who download our code. They're compatible, yes. GPL2+ would be advantageous since this code was written solely for LMMS and |
If it is a port from an existing project I would find it fair to the original author to keep the license they chose 🤔 It wouldn't make LMMS any less GPL'd anyway. |
There's no "fairness" argument when relicensing, just what's allowed. That's sort of the point of a permissive license to begin with. |
Exactly, so we should call a spade a spade. |
Is the 1.2.0 milestone for this issue appropriate? I think I can fix it in about a week, so the time doesn't matter. |
Yes, it was already a feature in 1.2-RC1 |
Yes I think so too. Apart from being a milestone it's a feature that is frequently requested in the forum. |
Yes please, I'm waiting for it. |
If the points are explored, the 'need' is not so obvious:
|
Thanks to everyone who made this happen! |
Every B&B pattern in the project is placed in the resulting MIDI file in sequence, with a new pattern starting on each bar.
This may be better explained in pictures. A song like this:
gets exported as if it was like this:
(cc @mohamed--abdel-maksoud)
The text was updated successfully, but these errors were encountered: