externi MIDI vystup
This commit is contained in:
parent
b5dcefc1bb
commit
cca61fab8b
|
@ -12,6 +12,7 @@ LEN = 33
|
|||
step = 1
|
||||
mout = midiwire.open_out(0)
|
||||
active_pat = 1
|
||||
chan = 10
|
||||
|
||||
instruments = {
|
||||
[1] = {"clap", 39},
|
||||
|
@ -55,6 +56,8 @@ print_instruments()
|
|||
playbtn = iup.button{title="play"}
|
||||
stopbtn = iup.button{title="stop"}
|
||||
|
||||
midi_setup = iup.button{title="MIDI output"}
|
||||
|
||||
-- TODO - maskovat tyhle věci a validovat ať to necrashuje
|
||||
|
||||
bpm = iup.text{spin="YES", value="120", spinmin=30, spinmax=240} -- todo: min max sensible
|
||||
|
@ -65,7 +68,7 @@ dlg = iup.dialog{
|
|||
iup.vbox{
|
||||
iup.hbox{pat_a, pat_b, pat_c, pat_d, pat_rec ,pat_load, pat_save; gap=5},
|
||||
iup.hbox{matrix},
|
||||
iup.hbox{playbtn, stopbtn, iup.label{title="tempo: "} , bpm, iup.label{title="/"}, factor, iup.label{title=" || len: "}, len; alignment="ACENTER", gap="5"}
|
||||
iup.hbox{playbtn, stopbtn, iup.label{title="tempo: "} , bpm, iup.label{title="/"}, factor, iup.label{title=" || len: "}, len, midi_setup; alignment="ACENTER", gap="5"}
|
||||
}
|
||||
; title = "DRUMsheet " .. VERSION, size = "560x170"
|
||||
}
|
||||
|
@ -86,7 +89,10 @@ function timer:action_cb()
|
|||
|
||||
for i=1,#instruments do
|
||||
if matrix:getcell(i, step)=="x" then
|
||||
midiwire.drum(mout, instruments[i][2])
|
||||
midiwire.note_on(mout, instruments[i][2], 100, chan)
|
||||
end
|
||||
if matrix:getcell(i, step)=="*" then
|
||||
midiwire.note_on(mout, instruments[i][2], 127, chan)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -154,6 +160,29 @@ function len:valuechanged_cb()
|
|||
end
|
||||
end
|
||||
|
||||
function midi_setup:action()
|
||||
local devices , sel2id = {}, {}
|
||||
for i=0,midiwire.device_count()-1 do
|
||||
if midiwire.name(i) then
|
||||
devices[#devices+1] = midiwire.name(i)
|
||||
sel2id[#devices] = i
|
||||
end
|
||||
end
|
||||
|
||||
local selected = iup.ListDialog(1, "select MIDI output", #devices, devices, 1, 1, #devices)
|
||||
if selected>-1 and sel2id[selected+1] then
|
||||
if sel2id[selected+1]==0 then
|
||||
-- Microsoft GS Wavetable Synth
|
||||
mout = midiwire.open_out(sel2id[selected+1])
|
||||
chan = 9
|
||||
else
|
||||
mout = midiwire.open_out(sel2id[selected+1])
|
||||
chan = iup.Scanf("Select port\nchannel number%2.2%d\n", 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- easier editing of patterns
|
||||
|
||||
|
@ -184,6 +213,7 @@ function pat_rec:action()
|
|||
end
|
||||
|
||||
function pat_recall(patno)
|
||||
if not patterns[patno] then return end
|
||||
local was_running = timer.run == "YES"
|
||||
timer.run="NO" -- pause while recalling to not glitch
|
||||
for x=1,8 do
|
||||
|
@ -331,10 +361,10 @@ function pat_load:action()
|
|||
len.value = data.len
|
||||
adjust_time(data.bpm, data.factor)
|
||||
adjust_len(data.len)
|
||||
instruments = data.instruments
|
||||
instruments = data.instruments or {}
|
||||
print_instruments()
|
||||
patterns = data.patterns
|
||||
pat_recall(1)
|
||||
patterns = data.patterns or { {}, {}, {}, {} }
|
||||
if patterns[1] then pat_recall(1) end
|
||||
pat_a.fontstyle="Bold"; pat_b.fontstyle=""; pat_c.fontstyle=""; pat_d.fontstyle=""
|
||||
matrix.redraw = "YES"
|
||||
end
|
||||
|
@ -347,6 +377,10 @@ end
|
|||
adjust_time(120, 4)
|
||||
dlg:showxy( iup.CENTER, iup.CENTER )
|
||||
|
||||
if midiwire.device_count()<2 then
|
||||
midi_setup.active = "NO"
|
||||
end
|
||||
|
||||
if (iup.MainLoopLevel()==0) then
|
||||
iup.MainLoop()
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue