| 赞 | 2 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2020-7-27 |
| 在线时间 | 1379 小时 |
- 梦石
- 0
- 星屑
- 76
- 在线时间
- 1379 小时
- 注册时间
- 2012-7-5
- 回帖
- 1643

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
我弃坑了 总之还是要把成果发出来
首先你需要有一个1.9.3的ruby然后gem install midilib <几秒钟就行了
然后你就可以运行这个了
需要midilib和1.9.3.rar
(8.85 KB, 下载次数: 57)
或者我也可以把代码扔出来 FILE部分自己改文件名即可
[pre lang="ruby" line="1"]$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'win32api'
require 'midilib'
MIDIOUTOPEN = Win32API.new("winmm","midiOutOpen","pllll","l")
MIDIOUTCLOSE = Win32API.new("winmm","midiOutClose","l","l")
MIDIOUTSHORTMSG = Win32API.new("winmm","midiOutShortMsg","ll","l")
#MCISENDSTRING = Win32API.new("winmm","mciSendString","pll","l")
hmidi = [0].pack("L")
MIDIOUTOPEN.call(hmidi,-1,0,0,0)
$hMidiOut = hmidi.unpack("L").first
FILE = './2012822182130.mid'
seq = MIDI::Sequence.new()
File.open(FILE, 'rb') { | file |
seq.read(file) { | track, num_tracks, i |
}
}
def MidiOutMessage (iStatus,iChannel,iData1,iData2)
dwMessage = iStatus | iChannel | (iData1 << 8) | (iData2 << 16)
return MIDIOUTSHORTMSG.call($hMidiOut, dwMessage)
end
seq.each{|track|
track.each{|event|
print_decimal_numbers = true
print_note_names = true
note = event.instance_variable_get(:@note)
time = event.instance_variable_get(:@delta_time)
status = event.instance_variable_get(:@status)
channel = event.instance_variable_get(:@channel)
velocity = event.instance_variable_get(:@velocity)
print "#{note} #{time} #{status} #{channel} #{velocity}\n" if note != nil
next if note == nil
sleep(time/1000.0)
MidiOutMessage(status, channel, note, velocity)
}
}
MIDIOUTCLOSE.call[/pre]
以及几秒钟的演示视频:http://v.youku.com/v_show/id_XNjQ0NDc1MDk2.html本来就转码转的渣你们就不要吐槽了 |
|