This is the LUA script library used in the MIDI Playable Piano Garry's Mod addon.
It integrates Starfall hooks and functions for the MIDI input interface of the addon.
Clients are required to have GMCL MIDI binary LUA module in order to use MIDI devices.
See Installation section of the GMCL MIDI README file.
midi_devices
- This allows you to select the MIDI device you wish to use.midi_debug [0|1]
- This boolean ConVar enables/disables debug prints in console, which show information about midi events as they occur.midi_reload
- This simply reloads the addon, and searches for GMCL MIDI binary LUA module again, allowing users to add the file without relog.midi_vel_clamp [32..127]
- This ConVar allows to clamp the MIDI key press velocity in order to get higher volume sounds out of gentle key presses.sv_midi_sf_note_quota
- This is a server-side quota for starfall playNote calls (per second) (def 30).
- The
MIDI
hook is now available on client-side, using the following syntax:
nil GM:MIDI( float time, int command, int note, int velocity )
or more often:
hook.add("MIDI", "my_unique_identifier", function(time, command, note, velocity) end)
- Entities now have the
boolean Entity:IsInstrument()
andboolean Entity:playNote(int note)
functions.
Entity:playNote
takes a note index from1-61
and returns a success boolean.
NOTE:Entity:playNote
is limited by thesv_midi_sf_note_quota
ConVar.
NOTE2:Entity:playNote
also requires the calling player have PhysGun access to the instrument entity.
This addon is based on the original Playable Piano addon. Its source code can be found at GitHub.
It also uses a modified version of the CFC MIDI Interface LUA script library to handle MIDI input.