[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] SimpleMIDIFile, get the duration and onset-time of the events



On Wed, Mar 6, 2019 at 10:57 PM <mr.lucedan@xxxxxxxxxx> wrote:
> I am using the SimpleMIDIFile UGen.

It's a language-side class, not a server-side UGen.

> The file does provide information for each event like this: [ 0, 1320, noteOn, 0, 50, 127 ]
> I don't understand how to get the duration of the event.

MIDI represents one note as two events:

- noteOn with note number x at time t0
- noteOff with note number x at time t1

The duration, then, is t1 - t0.

If you are looking at the noteOn event (array format in
SimpleMIDIFile), then you know t0 (= 1320 in your example), but you
don't know t1 yet.

You have to scan forward in the list of notes until you find the next
noteOff with the same note number. Then you have t1.

It's not convenient. MIDI is designed for performance data, not
musical-analytical data.

> I believed that array[1] was the time in ms in which the event happens, but it is not (I have compared it against the actual midi playing).

See `timeMode_()` -- 1320 looks like it's measured in "ticks"
(internal MIDI representation). These are probably not meaningful to
you. But you can set `myMIDIFile.timeMode = \seconds`.

hjh

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/