Skip to content

midifilemute

Toggle-mutes playback of a MIDI file (without pausing playback).

If the file is already muted, it is unmuted. This opcode can be called from anywhere, it is also a non-op if used in an instrument triggered by a MIDI event.

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

Syntax

 midifilemute([id:i])
midifilemute [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 midifilemute.csd.

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

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

instr Midisynth
 midifileplay(mf)
 amp:i = ampmidi(0.2)
 cps:i = cpsmidi()
 sig:a  = vco2(amp,cps)
 env:a  = madsr(0.001, 0.5, 0.1, 0.1)
   out(sig*env)
endin

instr Mute
 midifilemute(mf)
endin


schedule(Midisynth,0,0)
schedule(Mute,5,0)
schedule(Mute,7,0)
event_i("e", 0, midifilelen(mf))

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

See also

Sensing and Control: Tempo and Sequencing

Credits

Author: Victor Lazzarini
May 2025
New in Csound 7