Sha256: c76e745d2a287bb87880b5de3e5454b524a0571121cfed210c63b76c393e5ed3

Contents?: true

Size: 623 Bytes

Versions: 9

Compression:

Stored size: 623 Bytes

Contents

require "coreaudio"

inbuf = CoreAudio.default_input_device.input_buffer(1024)
outbuf = CoreAudio.default_output_device.output_buffer(1024)

th = Thread.start do
  ary = []
  loop do
    wav = inbuf.read(1024)
    ary.push(wav)
    # 1024*43 frames delayed. about 1 sec when sample rate = 44100Hz
    if ary.size > 43
      outbuf << ary.shift
    end
  end
end

inbuf.start
outbuf.start
$stdout.print "loopback..."
$stdout.flush
sleep 10;
inbuf.stop
outbuf.stop
$stdout.puts "done."
th.kill.join

puts "#{inbuf.dropped_frame} frame dropped at input buffer."
puts "#{outbuf.dropped_frame} frame dropped at output buffer."

Version data entries

9 entries across 9 versions & 1 rubygems

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