More on this topic:
I was wrong regarding "division": in this MIDI file, division = 1000 is
the correct value, provided that we keep the information contained in
the first track, namely "TimeSig" and "Tempo".
The content of the MIDI file is attached in MF2T text format to make
things clear.
The original content was incorrect and MIDIjs refused to play it. It
became correct after adding these metadata:
0 Meta TrkName "imported_1"
...
0 Meta TrkName "imported_2"
...
171250 Meta TrkEnd
Therefore, tracks require (arbitrary) names and a "Meta TrkEnd" should
be placed just before each "TrkEnd" instruction. At least, these are
requirements for MIDIclass.php to produce a MIDI file accepted by MIDIjs.
The corrected MIDI file is attached, namely "imported_codes.mid". Both
MIDIjs and PianoTeq accept it. (It sounds way better on PianoTeq!)
Bernard
----------
I checked MIDI files types 0 and 1 produced by BP2.9.8.
For instance I produced the enclosed "Visser.Waves1.mid" using
"-gr.Visser.Waves".
When trying to import it to a sound-object prototype I got an error in
MIDIclass.php indicating that the last event (a NoteOff) had been lost.
The file was imported anyway but the last event was missing. We do get
the last NoteOn timed 171250 ms but we miss its NoteOff around 180000 ms.
I modified "MIDIclass.php" so that it does not attempt to pick up the
missing event, but the result is unchanged. Only the error message
disappears.
In addition, the "division" found by MIDIclass is "1000" yielding a
faster playback. It should be set to "480" for a reason I still don't
understand…
Problems are identical when exporting type 0 and type 1 files. We should
avoid type 0 anyway, even though BP always produces single-track files.
This trace might be helpful for the design of MIDIfile export on the
console…
Bernard
|