windsp 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/windsp.rb +12 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bd9b0b2b5d44ad0e4cce1542022924f804c79e1
|
4
|
+
data.tar.gz: 002f119768a18623728a64ab143843e5a1c1c4b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 228ae67e257b1f6fc2a966bf11511b29e48f0835d76f8fa83a1cd8740c2a277b4322fc44129f06ed376c8101ecd435339b250c152a774c22ddfd5c2e0f083db7
|
7
|
+
data.tar.gz: 9c0918fa7a9dfc8b882b22c41b1a75c5821ba546168c38c159d337096bfc1ebccb865c496c8465441a4652786ed4312134c4fe7fea4fb6a6d82ece66ce9703c5
|
data/lib/windsp.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'fiddle/import'
|
2
2
|
|
3
3
|
class WinDSP
|
4
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.4"
|
5
5
|
|
6
6
|
module WinMM
|
7
7
|
extend Fiddle::Importer
|
8
8
|
dlload "winmm.dll"
|
9
9
|
if /64/ =~ RUBY_PLATFORM
|
10
|
-
|
10
|
+
PACK = "Q!"
|
11
11
|
else
|
12
|
-
|
12
|
+
PACK = "L!"
|
13
13
|
end
|
14
|
-
extern "int waveOutOpen(void *,
|
15
|
-
extern "int waveOutClose(
|
16
|
-
extern "int waveOutPrepareHeader(
|
17
|
-
extern "int waveOutUnprepareHeader(
|
18
|
-
extern "int waveOutWrite(
|
19
|
-
extern "int waveOutGetPosition(
|
14
|
+
extern "int waveOutOpen(void *, intptr_t, void *, intptr_t, intptr_t, long)"
|
15
|
+
extern "int waveOutClose(intptr_t)"
|
16
|
+
extern "int waveOutPrepareHeader(intptr_t, void *, int)"
|
17
|
+
extern "int waveOutUnprepareHeader(intptr_t, void *, int)"
|
18
|
+
extern "int waveOutWrite(intptr_t, void *, int)"
|
19
|
+
extern "int waveOutGetPosition(intptr_t, void *, int)"
|
20
20
|
|
21
21
|
WAVE_FORMAT_PCM = 1
|
22
22
|
WAVE_ALLOWSYNC = 0x0002
|
@@ -47,11 +47,7 @@ class WinDSP
|
|
47
47
|
form = [WinMM::WAVE_FORMAT_PCM, CHANNELS, FREQUENCY, rate, (BITS / 8) * CHANNELS, BITS, 0].pack("vvVVvvv")
|
48
48
|
ret = WinMM.waveOutOpen(tmp, 0, form, 0, 0, WinMM::WAVE_ALLOWSYNC | WinMM::WAVE_MAPPED)
|
49
49
|
raise "cannot open wave device: #{ret}" if ret != 0
|
50
|
-
|
51
|
-
@handle, = tmp.unpack("Q!")
|
52
|
-
else
|
53
|
-
@handle, = tmp.unpack("L!")
|
54
|
-
end
|
50
|
+
@handle, = tmp.unpack(WinMM::PACK)
|
55
51
|
@hdr = nil
|
56
52
|
@buffer = ""
|
57
53
|
end
|
@@ -67,24 +63,14 @@ class WinDSP
|
|
67
63
|
end
|
68
64
|
|
69
65
|
def wait(hdr)
|
70
|
-
if /64/ =~ RUBY_PLATFORM
|
71
|
-
x = "Q!"
|
72
|
-
else
|
73
|
-
x = "L!"
|
74
|
-
end
|
75
66
|
while true
|
76
|
-
break if (hdr.unpack("pVV#{
|
67
|
+
break if (hdr.unpack("pVV#{WinMM::PACK}VVp#{WinMM::PACK}")[4] & WinMM::WHDR_DONE) == WinMM::WHDR_DONE
|
77
68
|
sleep 0
|
78
69
|
end
|
79
70
|
end
|
80
71
|
|
81
72
|
def flush
|
82
|
-
|
83
|
-
x = "Q!"
|
84
|
-
else
|
85
|
-
x = "L!"
|
86
|
-
end
|
87
|
-
hdr = [@buffer, @buffer.bytesize, 0, 0, 0, 0, nil, 0].pack("pVV#{x}VVp#{x}")
|
73
|
+
hdr = [@buffer, @buffer.bytesize, 0, 0, 0, 0, nil, 0].pack("pVV#{WinMM::PACK}VVp#{WinMM::PACK}")
|
88
74
|
@buffer = ""
|
89
75
|
ret = WinMM.waveOutPrepareHeader(@handle, hdr, hdr.bytesize)
|
90
76
|
raise "error in waveOutPrepareHeader: #{ret}" if ret != 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: windsp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- U.Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|