Class: WinDSP
- Inherits:
-
Object
- Object
- WinDSP
- Defined in:
- lib/windsp.rb
Defined Under Namespace
Modules: WinMM
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #flush ⇒ Object
-
#initialize(*rest) ⇒ WinDSP
constructor
A new instance of WinDSP.
- #write(str) ⇒ Object (also: #binwrite, #print, #syswrite, #<<)
Constructor Details
#initialize(*rest) ⇒ WinDSP
Returns a new instance of WinDSP.
54 55 56 |
# File 'lib/windsp.rb', line 54 def initialize(*rest) @buf = "" end |
Class Method Details
.open(*rest, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/windsp.rb', line 41 def self.open(*rest, &block) io = self.new(rest) if block begin block.call(io) ensure io.close end else io end end |
Instance Method Details
#close ⇒ Object
58 59 60 61 |
# File 'lib/windsp.rb', line 58 def close flush WinMM.PlaySound(nil, nil, 0) end |
#flush ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/windsp.rb', line 63 def flush if @buf.bytesize >= 0 until WinMM.play_pcm(@buf, sync: false) sleep 0.1 end end @buf = "" WinMM.play_pcm("", sync: true) end |
#write(str) ⇒ Object Also known as: binwrite, print, syswrite, <<
73 74 75 76 |
# File 'lib/windsp.rb', line 73 def write(str) @buf << str flush if @buf.bytesize > 8000 * 1 * 1 * 4 end |