class AudioStream::AudioOutputFile

Public Class Methods

new(fname, soundinfo:) click to toggle source
Calls superclass method AudioStream::AudioOutput::new
# File lib/audio_stream/audio_output_file.rb, line 3
def initialize(fname, soundinfo:)
  super()
  @fname = fname
  @soundinfo = soundinfo
end

Public Instance Methods

connect() click to toggle source
# File lib/audio_stream/audio_output_file.rb, line 9
def connect
  @sound = RubyAudio::Sound.open(@fname, "w", @soundinfo)
end
disconnect() click to toggle source
# File lib/audio_stream/audio_output_file.rb, line 13
def disconnect
  if @sound && !@sound.closed?
    @sound.close
  end
end
on_completed() click to toggle source
# File lib/audio_stream/audio_output_file.rb, line 35
def on_completed
  disconnect
end
on_error(error) click to toggle source
# File lib/audio_stream/audio_output_file.rb, line 29
def on_error(error)
  puts error
  puts error.backtrace.join("\n")
  @sound.close
end
on_next(input) click to toggle source
# File lib/audio_stream/audio_output_file.rb, line 19
def on_next(input)
  case @soundinfo.channels
  when 1
    input = input.mono
  when 2
    input = input.stereo
  end
  @sound.write(input.to_rabuffer)
end