Difference between revisions of "Lua Midi"
Line 12: | Line 12: | ||
</source> | </source> | ||
− | See [https://github.com/dwiel/luamidi/blob/master/src/luamidi.cpp luamidi syntax] for full syntax. | + | See '''[https://github.com/dwiel/luamidi/blob/master/src/luamidi.cpp luamidi syntax]''' for full syntax. |
− | |||
− | |||
+ | === Examples === | ||
+ | '''Example for getting a message''' | ||
<source lang="lua"> | <source lang="lua"> | ||
local midiCount=luamidi.getinportcount() | local midiCount=luamidi.getinportcount() | ||
Line 22: | Line 22: | ||
local s, n, v, _t = pcall(luamidi.getMessage, 0) -- get message at first IN port | local s, n, v, _t = pcall(luamidi.getMessage, 0) -- get message at first IN port | ||
− | if not status then return end | + | if not status then return end |
</source> | </source> | ||
− | Example for sending a message | + | '''Example for sending a message''' |
− | |||
<source lang="lua"> | <source lang="lua"> | ||
local midiCount=luamidi.getoutportcount() | local midiCount=luamidi.getoutportcount() | ||
Line 34: | Line 33: | ||
luamidi.sendMessage(0, 144, 60, 127) -- send a maximum velocity (volume/strength) Note On middle C message to first OUT port | luamidi.sendMessage(0, 144, 60, 127) -- send a maximum velocity (volume/strength) Note On middle C message to first OUT port | ||
luamidi.sendMessage(0, 144, 60, 0) -- send a Note Off middle C message to first OUT port | luamidi.sendMessage(0, 144, 60, 0) -- send a Note Off middle C message to first OUT port | ||
− | |||
− | |||
</source> | </source> | ||
Revision as of 23:52, 1 March 2023
Supported platforms:
Available since: Gideros 2018.12
Description
Provides a simple interface for MIDI I/O.
To add Midi support to your application you call:
require "luamidi"
See luamidi syntax for full syntax.
Examples
Example for getting a message
local midiCount=luamidi.getinportcount()
if midiCount==0 then return end -- no midi device
_midiDeviceName=luamidi.enumerateinports()[0] -- the name of the device at first IN port
local s, n, v, _t = pcall(luamidi.getMessage, 0) -- get message at first IN port
if not status then return end
Example for sending a message
local midiCount=luamidi.getoutportcount()
if midiCount==0 then return end -- no midi device
_midiDeviceName=luamidi.enumerateoutports()[0] -- the name of the device at first OUT port
luamidi.sendMessage(0, 144, 60, 127) -- send a maximum velocity (volume/strength) Note On middle C message to first OUT port
luamidi.sendMessage(0, 144, 60, 0) -- send a Note Off middle C message to first OUT port
Methodsluamidi:base0 sets that when sending messages the channels are in the range 0-15 |
EventsConstants |