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 loading needs to be better #24

Open
GoogleCodeExporter opened this issue Mar 24, 2015 · 8 comments
Open

MIDI loading needs to be better #24

GoogleCodeExporter opened this issue Mar 24, 2015 · 8 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

  • Added labels: Milestone-Release0.5
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

The value module needs to be used as well.

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

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

Attachments:

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: Milestone-Release0.6
  • Removed labels: Milestone-Release0.5

@GoogleCodeExporter
Copy link
Author

Any plans on committing running status support?

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

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

Attachments:

@GoogleCodeExporter
Copy link
Author

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

  • Added labels: ****
  • Removed labels: ****

Attachments:

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

No branches or pull requests

1 participant