[PD] including bpm info to midi-recording

Martin Peach chakekatzil at gmail.com
Tue Apr 7 17:25:33 CEST 2020


On Mon, Apr 6, 2020 at 3:27 AM Jakob Laue <jakkesprinter at web.de> wrote:
>
> Hey Martin,
> thanks for your hints!
>
> I created a midi file in ableton, exported it and then read it with the midifile-read-help-patch.
> This is what I get after reading:
>
> midifile: opened /Users/wbjc/Desktop/ableton.mid
> midifile: Header chunk type: MThd
> midifile: Header chunk length: 6
> midifile: Header chunk format: 0 (Single multichannel track)
> midifile: Header chunk ntrks: 1
> midifile: Header chunk division: 0x60: 96 ticks per quarter note
> midifile: Track chunk 0 type: MTrk, length 81
>
>
>
> And this is what I get after the |dump 0( message:
>
>
>
>
> midifile: Parsing track[0]...
> midifile: tick 0 delta 0 status FF Meta 0x03 length 1
> Sequence/Track Name
> midifile: tick 0 delta 0 status FF Meta 0x58 length 4
> Time Signature 4/4 36 clocks per tick, 8 32nd notes per quarter note
> midifile: tick 0 delta 0 status FF Meta 0x58 length 4
> Time Signature 4/4 36 clocks per tick, 8 32nd notes per quarter note
> midifile: tick 0 delta 0 status 90 MIDI 0x90 42 64 : channel 1 Note 66 On velocity 100
> midifile: tick 24 delta 24 status 80 MIDI 0x80 42 40 : channel 1 Note 66 Off velocity 64
> midifile: tick 72 delta 48 status 90 MIDI 0x90 41 64 : channel 1 Note 65 On velocity 100
> midifile: tick 96 delta 24 status 80 MIDI 0x80 41 40 : channel 1 Note 65 Off velocity 64
> midifile: tick 120 delta 24 status 90 MIDI 0x90 46 64 : channel 1 Note 70 On velocity 100
> midifile: tick 144 delta 24 status 80 MIDI 0x80 46 40 : channel 1 Note 70 Off velocity 64
> midifile: tick 168 delta 24 status 90 MIDI 0x90 41 64 : channel 1 Note 65 On velocity 100
> midifile: tick 192 delta 24 status 80 MIDI 0x80 41 40 : channel 1 Note 65 Off velocity 64
> midifile: tick 216 delta 24 status 90 MIDI 0x90 40 64 : channel 1 Note 64 On velocity 100
> midifile: tick 240 delta 24 status 80 MIDI 0x80 40 40 : channel 1 Note 64 Off velocity 64
> midifile: tick 264 delta 24 status 90 MIDI 0x90 45 64 : channel 1 Note 69 On velocity 100
> midifile: tick 288 delta 24 status 80 MIDI 0x80 45 40 : channel 1 Note 69 Off velocity 64
> midifile: tick 312 delta 24 status 90 MIDI 0x90 41 64 : channel 1 Note 65 On velocity 100
> midifile: tick 336 delta 24 status 80 MIDI 0x80 41 40 : channel 1 Note 65 Off velocity 64
> midifile: tick 336 delta 0 status FF Meta 0x2F length 0
> ========End of Track 0==========
>
>
>
> The differences that I noticed:
>
> In the ableton-file the "header chunk division" is given as "ticks per quarter note", whereas in the midifile-file it is given in "frames per second and ticks per frame".
>
>
>
> midifile: Header chunk division: "0x60: 96 ticks per quarter note"
> midifile: Header chunk division: "0xE714: 25 frames per second, 20 ticks per frame"
>
>
> In the ableton-file there is an info given about the time signature: "Time Signature 4/4 36 clocks per tick, 8 32nd notes per quarter note"
>
> This info is not present after loading the file that i recorded with [midifile].

You have to add it yourself, since [midifile] has no idea what time
signature or tempo you are using (when writing, the ticks don't have
to be in real time).
With the latest version of [midifile] there is a [meta( message for
this. With earlier versions you can write the meta tags directly, for
example to get the time signature,
Time Signature 4/4 36 clocks per tick, 8 32nd notes per quarter note
you can send
[255 88 4 4 36 8{
and the tempo
[255 81 500000(
sets 500000 microseconds per quarter note.

You can find more info here:
http://www.music.mcgill.ca/~ich/classes/mumt306/StandardMIDIfileformat.html

Martin
> ____
>
>
> Furthermore, looking at the first lines of the dump-info of the ableton-exported-file, we can see that there is also one note being played at tick 0, but I did not actually put a note there. The same applies for the [midifile]-recorded file. I did not play notes directly after hitting the record-[bang]. I don't know how these notes on the first tick (0) have gotten there.
>
> As a side-note the help-patches that I am using are from 2010 (write-help-patch) and 2011 (read-help-patch). These were included in the mrpeach_v0-0-extended package that I downloaded via deken.
>
> Best, Jakob





More information about the Pd-list mailing list