Uz vim jak na ten input.

This commit is contained in:
severak 2019-10-22 16:05:36 +02:00
parent 78ef09ebf6
commit 6156a16cad
2 changed files with 51 additions and 2 deletions

View File

@ -1,19 +1,31 @@
local mw = require "midiwire"
require "iuplua"
print "ports:"
for i=0,mw.device_count()-1 do
print(i, mw.name(i))
end
port, err = mw.open_in(1)
port, err = mw.open_in(0)
if not port then
print("ERR " .. err)
return
end
--[[
dlg = iup.dialog{size="100x100"}
dlg:showxy( iup.CENTER, iup.CENTER )
if (iup.MainLoopLevel()==0) then
iup.MainLoop()
end
]]
while true do
io.stdout:write "."
-- io.stdout:write "."
mw.sleep(100)
-- chyta inputy
end

View File

@ -214,7 +214,35 @@ void CALLBACK MidiInProc(HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance, DWORD dwP
return;
}
void PrintMidiInDevices()
{
UINT nMidiDeviceNum;
MIDIINCAPS caps;
nMidiDeviceNum = midiInGetNumDevs();
if (nMidiDeviceNum == 0) {
fprintf(stderr, "midiInGetNumDevs() return 0...");
return;
}
printf("== PrintMidiDevices() == \n");
unsigned int i;
for (i = 0; i < nMidiDeviceNum; ++i) {
midiInGetDevCaps(i, &caps, sizeof(MIDIINCAPS));
printf("\t%d : name = %s\n", i, caps.szPname);
}
printf("=====\n");
}
// https://gist.github.com/yoggy/1485181
// TODO - inputy jsou jinak číslované
// po otevření musím zavolat midiInStart
// pro uzavření midiInStop & midiInClose
static int midiwire_open_in (lua_State *L) {
PrintMidiInDevices();
unsigned long result;
HMIDIIN inHandle;
int port = luaL_checkinteger(L, 1);
@ -226,6 +254,15 @@ static int midiwire_open_in (lua_State *L) {
lua_pushinteger (L, result);
return 2;
}
midiInStart(inHandle);
if (result != MMSYSERR_NOERROR)
{
lua_pushnil (L);
lua_pushinteger (L, result);
return 2;
}
lua_pushlightuserdata (L, inHandle);
return 1;
}