Sha256: 052c01136d3ab491959c434e181f24388349383df047085a034a1c70125e2eba

Contents?: true

Size: 406 Bytes

Versions: 9

Compression:

Stored size: 406 Bytes

Contents

require "coreaudio"

dev = CoreAudio.default_output_device
buf = dev.output_buffer(1024)

phase = Math::PI * 2.0 * 440.0 / dev.nominal_rate
th = Thread.start do
  i = 0
  wav = NArray.sint(1024)
  loop do
    1024.times {|j| wav[j] = (0.4 * Math.sin(phase*(i+j)) * 0x7FFF).round }
    i += 1024
    buf << wav
  end
end

buf.start
sleep 2
buf.stop

puts "#{buf.dropped_frame} frame dropped."

th.kill.join

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
coreaudio-0.0.12 examples/outbuffer_sine.rb
coreaudio-0.0.11 examples/outbuffer_sine.rb
coreaudio-0.0.10 examples/outbuffer_sine.rb
coreaudio-0.0.9 examples/outbuffer_sine.rb
coreaudio-0.0.8 examples/outbuffer_sine.rb
coreaudio-0.0.7 examples/outbuffer_sine.rb
coreaudio-0.0.6 examples/outbuffer_sine.rb
coreaudio-0.0.5 examples/outbuffer_sine.rb
coreaudio-0.0.4 examples/outbuffer_sine.rb