Difference between revisions of "Lua Midi"

From GiderosMobile
(Created page with "__NOTOC__ <!-- GIDEROSOBJ:luamidi--> '''Supported platforms:''' File:Platform mac.pngFile:Platform pc.png<br/> '''Available since:''' Gideros 2018.12<br/> === Descrip...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(25 intermediate revisions by 3 users not shown)
Line 8: Line 8:
  
 
To add Midi support to your application you call:
 
To add Midi support to your application you call:
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
require "luamidi"
 
require "luamidi"
</source>
+
</syntaxhighlight>
 +
 
 +
See '''[https://github.com/dwiel/luamidi/blob/master/src/luamidi.cpp luamidi syntax]''' for full syntax.
 +
 
 +
=== Examples ===
 +
'''Example for getting a message'''
 +
<syntaxhighlight lang="lua">
 +
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
 +
</syntaxhighlight>
 +
 
 +
'''Example for sending a message'''
 +
<syntaxhighlight lang="lua">
 +
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
 +
</syntaxhighlight>
  
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 +
 
=== Methods ===
 
=== Methods ===
 +
[[luamidi:base0]] ''sets that when sending messages the channels are in the range 0-15''<br/><!--GIDEROSMTD: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''<br/><!--GIDEROSMTD: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''<br/><!--GIDEROSMTD:luamidi:enumerateinports() gets a table of Midi IN port names (its size is equal to luamidi:getinportcount())-->
 +
[[luamidi:enumerateoutports]] ''gets a table of Midi OUT port names''<br/><!--GIDEROSMTD:luamidi:enumerateoutports() gets a table of Midi OUT port names (its size is equal to luamidi:getoutportcount())-->
 +
[[luamidi:getInPortName]] ''gets the Midi IN port name''<br/><!--GIDEROSMTD:luamidi:getInPortName() gets the Midi IN port name-->
 +
[[luamidi:getMessage]] ''gets the next incoming message from the queue of the chosen IN port''<br/><!--GIDEROSMTD:luamidi:getMessage(i) gets the next incoming message from the queue from IN port i; in the format c,n,v,_t-->
 +
[[luamidi:getOutPortName]] ''gets the Midi OUT port name''<br/><!--GIDEROSMTD:luamidi:getOutPortName() gets the Midi OUT port name-->
 
[[luamidi:getinportcount]] ''gets the number of Midi IN ports''<br/><!--GIDEROSMTD:luamidi:getinportcount() gets the number of Midi IN ports-->
 
[[luamidi:getinportcount]] ''gets the number of Midi IN ports''<br/><!--GIDEROSMTD:luamidi:getinportcount() gets the number of Midi IN ports-->
 
[[luamidi:getoutportcount]] ''gets the number of Midi OUT ports''<br/><!--GIDEROSMTD:luamidi:getoutportcount() gets the number of Midi OUT ports-->
 
[[luamidi:getoutportcount]] ''gets the number of Midi OUT ports''<br/><!--GIDEROSMTD:luamidi:getoutportcount() gets the number of Midi OUT ports-->
[[luamidi:enumerateoutports]] ''xxx''<br/><!--GIDEROSMTD:luamidi:enumerateoutports() xxx-->
+
[[luamidi:noteOff]] ''sends a Note Off message to the chosen OUT port''<br/><!--GIDEROSMTD:luamidi:noteOff() sends a Note Off message to the chosen OUT port-->
[[luamidi:enumerateinports]] ''xxx''<br/><!--GIDEROSMTD:luamidi:enumerateinports() xxx-->
+
[[luamidi:noteOn]] ''sends a Note On message to the chosen OUT port''<br/><!--GIDEROSMTD:luamidi:noteOn() sends a Note On message to the chosen OUT port-->
 +
[[luamidi:openin]] ''opens the Midi IN port''<br/><!--GIDEROSMTD:luamidi:openin() opens the Midi IN port-->
 +
[[luamidi:openout]] ''opens the Midi OUT port''<br/><!--GIDEROSMTD:luamidi:openout() opens the Midi OUT port-->
 +
[[luamidi:sendMessage]] ''sends a message to the chosen OUT port''<br/><!--GIDEROSMTD:luamidi:sendMessage(i,c,n,v) sends a message to OUT port i-->
 +
[[luamidi:setQueueSizeLimit]] ''sets the Midi queue size limit''<br/><!--GIDEROSMTD:luamidi:setQueueSizeLimit() sets the Midi queue size limit-->
  
[[luamidi:getInPortName]] ''xxx''<br/><!--GIDEROSMTD:luamidi:getInPortName() xxx-->
+
| style="width: 50%; vertical-align:top;"|
[[luamidi:getOutPortName]] ''xxx''<br/><!--GIDEROSMTD:luamidi:getOutPortName() xxx-->
 
[[luamidi:openout]] ''xxx''<br/><!--GIDEROSMTD:luamidi:openout() xxx-->
 
[[luamidi:openin]] ''xxx''<br/><!--GIDEROSMTD:luamidi:openin() xxx-->
 
[[luamidi:noteOn]] ''xxx''<br/><!--GIDEROSMTD:luamidi:noteOn() xxx-->
 
[[luamidi:noteOff]] ''xxx''<br/><!--GIDEROSMTD:luamidi:noteOff() xxx-->
 
[[luamidi:sendMessage]] ''xxx''<br/><!--GIDEROSMTD:luamidi:sendMessage() xxx-->
 
[[luamidi:getMessage]] ''xxx''<br/><!--GIDEROSMTD:luamidi:getMessage() xxx-->
 
[[luamidi:base0]] ''xxx''<br/><!--GIDEROSMTD:luamidi:base0() xxx-->
 
[[luamidi:base1]] ''xxx''<br/><!--GIDEROSMTD:luamidi:base1() xxx-->
 
[[luamidi:setQueueSizeLimit]] ''xxx''<br/><!--GIDEROSMTD:luamidi:setQueueSizeLimit() xxx-->
 
  
| style="width: 50%; vertical-align:top;"|
 
 
=== Events ===
 
=== Events ===
 
=== Constants ===
 
=== Constants ===

Latest revision as of 15:30, 13 July 2023

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.

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

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 of the 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