windsp 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/windsp.rb +12 -26
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81e89dccef9d88f8fae21b7da567b2991da228d5
4
- data.tar.gz: 294759c25508f6297fcdb1d23ce87bf98e336712
3
+ metadata.gz: 7bd9b0b2b5d44ad0e4cce1542022924f804c79e1
4
+ data.tar.gz: 002f119768a18623728a64ab143843e5a1c1c4b8
5
5
  SHA512:
6
- metadata.gz: 37dbac93fac09343ab3c75a777190e6743c2dc01026c4c7b74a248440aec40a0a6e20a681c9c1079bb6483cb2b871bfec68ed13640b79d3d75d0288963283f81
7
- data.tar.gz: e800d0ef21df75b53de9c60d477927c51f584175598acf2f01c4703056a1432bdb039c36b4a4d3228c5ec87460dbfc2559ca43f409d1393a01cbc824cda1bbe1
6
+ metadata.gz: 228ae67e257b1f6fc2a966bf11511b29e48f0835d76f8fa83a1cd8740c2a277b4322fc44129f06ed376c8101ecd435339b250c152a774c22ddfd5c2e0f083db7
7
+ data.tar.gz: 9c0918fa7a9dfc8b882b22c41b1a75c5821ba546168c38c159d337096bfc1ebccb865c496c8465441a4652786ed4312134c4fe7fea4fb6a6d82ece66ce9703c5
@@ -1,22 +1,22 @@
1
1
  require 'fiddle/import'
2
2
 
3
3
  class WinDSP
4
- VERSION = "0.0.3"
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
- int_ptr = "long long"
10
+ PACK = "Q!"
11
11
  else
12
- int_ptr = "long"
12
+ PACK = "L!"
13
13
  end
14
- extern "int waveOutOpen(void *, #{int_ptr}, void *, #{int_ptr}, #{int_ptr}, long)"
15
- extern "int waveOutClose(#{int_ptr})"
16
- extern "int waveOutPrepareHeader(#{int_ptr}, void *, int)"
17
- extern "int waveOutUnprepareHeader(#{int_ptr}, void *, int)"
18
- extern "int waveOutWrite(#{int_ptr}, void *, int)"
19
- extern "int waveOutGetPosition(#{int_ptr}, void *, int)"
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
- if /64/ =~ RUBY_PLATFORM
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#{x}VVp#{x}")[4] & WinMM::WHDR_DONE) == WinMM::WHDR_DONE
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
- if /64/ =~ RUBY_PLATFORM
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.3
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-05-21 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler