{{fbdoc item="title" value="MIDI"}}---- Controls MIDI output through sfxlib where the target backend supports it. {{fbdoc item="syntax"}}## result = Midi Open(device) Midi Close result = Midi Close() result = Midi Play(filename) Midi Stop Midi Pause Midi Resume result = Midi Send(status, data1, data2) ## {{fbdoc item="desc"}} MIDI is not recorded audio. It is a stream of musical instructions sent to a MIDI device or synthesizer. Those instructions can say things like note on, note off, change instrument, or change controller value. Midi Open selects a MIDI output device by index. Midi Send sends one short MIDI message using a status byte and two data bytes. For example, &h90 is a common note-on status byte on channel 1, the first data byte is the note number, and the second is velocity. Midi Play attempts to play a MIDI file where the backend supports file playback. Stop, Pause, Resume, and Close control that MIDI path. MIDI support varies a lot by operating system and backend. Programs should check return values and continue gracefully if no MIDI device exists. {{fbdoc item="ex"}} %%(freebasic) if midi open(0) >= 0 then midi send &h90, 60, 100 ' note on: middle C sleep 250, 1 midi send &h80, 60, 0 ' note off midi close end if %% {{fbdoc item="target"}} - Use MUSIC for recorded music files such as WAV or decoded audio. - Use PLAY or NOTE for generated music that does not need a MIDI device. {{fbdoc item="diff"}} `t- New to ""FreeBASIC"". {{fbdoc item="see"}} - ##[[KeyPgDevice|DEVICE]]## - ##[[KeyPgMusic|MUSIC]]## - ##[[CatPgSfx|Sound Library Reference]]## {{fbdoc item="back" value="CatPgSfx|Sound Library Reference"}}