Difference between revisions of "Lua Midi"

From GiderosMobile
Line 18: Line 18:
 
<source lang="lua">
 
<source lang="lua">
 
require "luamidi"
 
require "luamidi"
</source>
+
 
 
local midiCount=luamidi.getinportcount()
 
local midiCount=luamidi.getinportcount()
 
   if midiCount==0 then return end -- no midi device
 
   if midiCount==0 then return end -- no midi device
Line 24: Line 24:
 
   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>
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|

Revision as of 13:37, 27 June 2022

Supported platforms: Platform mac.pngPlatform pc.png
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.

Example for getting a message:

require "luamidi"

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

Methods

luamidi:base0 sets that when sending messages the channels are in the range 0-15
luamidi:base1 sets that when sending messages the channels are in the range 1-16
luamidi:enumerateinports gets a table of Midi IN port names
luamidi:enumerateoutports gets a table of Midi OUT port names
luamidi:getInPortName gets the Midi IN port name
luamidi:getMessage gets the next incoming message from the queue from to chosen IN port
luamidi:getOutPortName gets the Midi OUT port name
luamidi:getinportcount gets the number of Midi IN ports
luamidi:getoutportcount gets the number of Midi OUT ports
luamidi:noteOff sends a Note Off message to the chosen OUT port
luamidi:noteOn sends a Note On message to the chosen OUT port
luamidi:openin opens the Midi IN port
luamidi:openout opens the Midi OUT port
luamidi:sendMessage sends a message to the chosen OUT port
luamidi:setQueueSizeLimit sets the Midi queue size limit

Events

Constants