f8g

MIDIでド

おお、鳴った。

require "dl/import"

module MidiOut
	LIB = DL.dlopen("winmm")

	module_function
	def open
		midiOutOpen = LIB["midiOutOpen", "Ilpppp"]
		r, rs = midiOutOpen.call(0, nil, nil, nil, nil)
		return rs[0]
	end

	module_function
	def close(handle)
		midiOutClose = LIB["midiOutClose", "IL"]
		r, rs = midiOutClose.call(handle)
		return r
	end

	module_function
	def shortMsg(handle, sound)
		midiOutShortMsg = LIB["midiOutShortMsg", "ILL"]
		r, rs = midiOutShortMsg.call(handle, sound)
		return r
	end

end

h = MidiOut.open
MidiOut.shortMsg(h, 0x7f3c90)
MidiOut.close(h)