On Sat, Oct 3, 2020 at 7:15 PM Jakob Laue jakkesprinter@web.de wrote:
Hi Martin, thanks for your quick response!
Gesendet: Samstag, 03. Oktober 2020 um 19:02 Uhr Von: "Martin Peach" chakekatzil@gmail.com An: "Jakob Laue" jakkesprinter@web.de Cc: "Pd-List" pd-list@lists.iem.at Betreff: Re: [PD] mrpeach/midifile: multiple voices On Sat, Oct 3, 2020 at 7:05 AM Jakob Laue jakkesprinter@web.de wrote:
Hi list, i have a patch that a melody and saves it into a midifile with [midifile] from mrpeach. Now i have extended the patch so that there is a second melody generated which accompanies the first one. Now i also send the pitch/noteduration pair of the second melody to the same [midifile] object in order to receive a two-voice-midi-file. But unfortunately both melodies seem to overwrite their noteDurations and hence i have wrong note durations in the midi file.
Are you writing a single track with two MIDI channels or two tracks?
->> to be honest, I can not answer this question. I initialize [midifile] with ...
- filename and fps in one message
- time signature message [255 88 4 4 2 38 8)
- tempo message [255 81 ...(
...before I send it events.
If the events for the two melodies are in two different MIDI channels it should work to record them in the default single track. So if you add the channel number minus one to the MIDI status byte (for example, 144 is note-on status for channel 1, 145 is note-on in channel 2) they should stay separate.
If you use a [track ( message before each event it should keep them separate.
-> Do you mean a track name message like "FF 03 len text Sequence/Track Name" according to http://www.music.mcgill.ca/~ich/classes/mumt306/StandardMIDIfileformat.html at the bottom?
No. See under 2.2 - MIDI File Formats 0,1 and 2. It's possible to make a multitrack midi file by sending, say, [track 2( to [midifile] before sending an event for track 2, then [track 1( before a track 1 event. That way you could have several separate instruments on the same MIDI channel. (This format 1 only writes correctly in the latest midifile v.041, but all versions should be able to read any format). Most of the midi files on the web seem to have one instrument per track, and MIDI channel numbers are not used. To use [midifile] as a sequencer it's easier to have one track and several channels. To export a composition as a MIDI file, it should probably be using several tracks.
Martin