lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Cool! This would go really well with that Lua libao binding (http://github.com/thelinx/lao/)- if only I could figure out how to compile lao on Windows...

On Mon, 13 Sep 2010 21:10:43 -0400, <pj@pjb.com.au> wrote:

Greetings,

Another module: http://www.pjb.com.au/comp/lua/MIDI.lua
doc homepage:   http://www.pjb.com.au/comp/lua/MIDI.html
test script:    http://www.pjb.com.au/comp/lua/test_mi.lua
version:        3.7

MIDI.lua - for Reading, writing and manipulating MIDI data
translates the MIDI data into Lua variables and back, e.g.

 local MIDI = require 'MIDI'
 local my_score = {
    96,  -- ticks per beat
    {    -- first track
       {'patch_change', 0, 1, 11}, -- vibraphone on channel 1
       {'set_tempo', 0, 750000},   -- microseconds per beat
       {'note', 5, 96, 1, 25, 100},
       {'note', 101, 96, 1, 29, 100},
    },  -- end of first track
 }
 local f = assert(io.open('f.mid','wb'))
 f:write(MIDI.score2midi(my_score))
 f:close()

and, aside from offering this low-level access, also offers a
number of different functions to perform common manipulations.

It's a translation into Lua of my Python module:
  http://www.pjb.com.au/midi/MIDI.html
  http://www.pjb.com.au/midi/free/MIDI.py
which is the basis of my midisox program, which already has a
Perl version, and may soon get a Lua version...

( Translating is a process which I find really instructive; plus
  I really like having compatible calling-interfaces to my most-
  -needed-stuff in different languages; also the resulting study
  of the code and the new test-scripts finds and fixes lots of
  little bugs that no-one seems to spot otherwise. )

May it be useful,  let me know of problems,
Peter Billam

http://www.pjb.com.au       pj@pjb.com.au      (03) 6278 9410
"Was der Meister nicht kann,   vermöcht es der Knabe, hätt er
 ihm immer gehorcht?"   Siegfried to Mime, from Act 1 Scene 2