Skip to content

midifilevents

Returns the number of events in a MIDI file.

Requires the -F flag to operate. If a filename is passed to -F, it is open with id 0.

Syntax

 num:i =  midifilevents([id:i])
inum midifilevents [id]

Initialization

id (optional, default=0) -- MIDI file id, defaults to 0, the id of any file passed to the -F flag.

Examples

Here is an example of the miditempo opcode. It uses the files midifilevents.csd.

Example of the midifilevents opcode.
<CsoundSynthesizer>
<CsOptions>
--midifile -odac
</CsOptions>
<CsInstruments>
0dbfs=1

mf@global:i = midifileopen("catherine.mid")

instr Events
evts:i = midifilevents(mf)
print evts
exitnow(0)
endin

schedule(Events,0,1)


</CsInstruments>
<CsScore>
</CsScore>
</CsoundSynthesizer>

See also

Sensing and Control: Tempo and Sequencing

Credits

Author: Victor Lazzarini
May 2025
New in Csound 7