bgr / mingus

Automatically exported from code.google.com/p/mingus
GNU General Public License v3.0
1 stars 1 forks source link

MIDI loading needs to be better #24

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Loading a MIDI that was generated by mingus works fine, but it sometimes
chokes and throws unnecessary exceptions when parsing files generated by
other programs.

Some refinements:
* Midi events between 0 and 7 of which I have now documentation should be
allowed, but ignored.
* SysEx events should also be parsed but ignored.
* Can we parse type 2 midi files? Need to find some examples...
* We currently have no way to save changing instruments and bpm. We could
save that information on individual Notes but this would complicate all
sequencing algorithms considerably. Maybe it would be best if we had a
separate control track, since I would guess not every MIDI program outputs
tempo change events on every channel.

That's it, I hope.

Original issue reported on code.google.com by Rhijnauwen@gmail.com on 29 Dec 2008 at 1:01

GoogleCodeExporter commented 9 years ago

Original comment by Rhijnauwen@gmail.com on 19 Jan 2009 at 5:17

GoogleCodeExporter commented 9 years ago
The value module needs to be used as well.

Original comment by Rhijnauwen@gmail.com on 24 Feb 2009 at 3:19

GoogleCodeExporter commented 9 years ago
I looked at the mingus MIDI loading support and realized it had absolutely zero
support for running status, which is where midi events are chained together. A
sequencer I'm using uses these for controller change events. I added some 
support and
have uploaded a new MidiFileIn.py.

It's not pretty but it works. I haven't been able to find exact documentation, 
but I
think controller change events that are specified in running status don't have 
time
deltas.

Original comment by iamm...@gmail.com on 8 Jan 2010 at 3:11

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by Rhijnauwen@gmail.com on 18 May 2011 at 7:30

GoogleCodeExporter commented 9 years ago
Any plans on committing running status support?

Original comment by gokcen.eraslan@gmail.com on 6 Feb 2012 at 8:39

GoogleCodeExporter commented 9 years ago
Loading other MIDI files doesn't work for
a variety of reasons. Just bumping this Issue to
get some attention. Tried to load some MIDI files
from: http://www.schristiancollins.com/generaluser.php

Original comment by prolo...@shortcircuit.net.au on 1 Oct 2012 at 11:08

GoogleCodeExporter commented 9 years ago
I too ran into the running status problem.  I wish I had come here first, but 
alas, I coded up my own "fix" based on Will Ware's midi.py 
(http://groups.google.com/groups?hl=en&selm=3C0F67FE.96E7CAE8%40alum.mit.edu)...
see the runningStatus parts.

It is a little smaller than the one posted in comment 3 above.  It addresses 
the following block in a way that prevents the block from being hit.
"       # I don't know what these events are supposed to do, but I keep finding them.
        # The parser ignores them.
        if event_type < 8:
            raise FormatError, "Unknown event type %d. Byte %d." % (event_type, self.bytes_read)
"

While trying to figure out midi in python I ran across this link 
(http://www.daniweb.com/software-development/python/code/216979/embed-and-play-m
idi-music-in-your-code-python) which contains a midi file (FishPolka.mid) that 
mingus can not parse (also attached).

The error is below...
    m, bpm = mf.MIDI_to_Composition("FishPolka.mid")
  File "/usr/local/lib/python2.7/dist-packages/mingus/midi/MidiFileIn.py", line 64, in MIDI_to_Composition
    header, track_data = self.parse_midi_file(file)
  File "/usr/local/lib/python2.7/dist-packages/mingus/midi/MidiFileIn.py", line 367, in parse_midi_file
    events = self.parse_track(f)
  File "/usr/local/lib/python2.7/dist-packages/mingus/midi/MidiFileIn.py", line 257, in parse_track
    event, chunk_delta = self.parse_midi_event(fp)
  File "/usr/local/lib/python2.7/dist-packages/mingus/midi/MidiFileIn.py", line 285, in parse_midi_event
    raise FormatError, "Unknown event type %d. Byte %d." % (event_type, self.bytes_read)
mingus.midi.MidiFileIn.FormatError: Unknown event type 4. Byte 123.

Original comment by shao...@gmail.com on 9 Oct 2012 at 5:19

Attachments:

GoogleCodeExporter commented 9 years ago
There was an indent problem with a last minute edit in the version attached 
above. Sorry!

Original comment by shao...@gmail.com on 9 Oct 2012 at 5:56

Attachments: