forked from Artoria/RMSFX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibvf.rb
More file actions
31 lines (29 loc) · 770 Bytes
/
libvf.rb
File metadata and controls
31 lines (29 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'ext'
class LibVF < ExternalWrapper
def self.init
const_set :LIBVF, self.find(['libvorbisfile.dll'])
end
OV_CALLBACKS_NOCLOSE = [
Seiran20.funcaddr('msvcrt', 'fread'),
Seiran20.funcaddr('msvcrt', 'fseek'),
0,
Seiran20.funcaddr('msvcrt', 'ftell'),
].pack("L*")
def self.decode_file(filename)
fp = Seiran20.capi('msvcrt', 'fopen').call(filename, 'rb')
vf = "\0"*4096
self[:ov_open_callbacks].call fp, vf, 0, 0, OV_CALLBACKS_NOCLOSE
buf = "\0"*4096
cur = "RGBA"
wavout = ""
while (ret = self[:ov_read].call(vf, buf, 4096, 0,2,1,cur))!=0
if ret > 0
wavout << ret
Graphics.update if VER::XP
end
end
self[:ov_clear].call vf
wavout
end
init
end