1 year ago

#189271

test-img

Benjámin Hudák

How can I write float array into stereo wav file with ruby?

So... I am using ruby box in flowstone and I am stucked.I created a stereo wav file and I am capturing audio buffer frames from mono audio signal and converting into float array,however I don't know how can I address my 2nd float array (from the 2nd audio channel) to the stereo wav file. Basically it needs to be like this somehow: Float array1-left audio channel in the wav file,Float array2-right audio channel in the wav file.

ruby box in flowstone,how to write to stereo file

def init
  @mode=false
  @file=nil
end

def event(i,v,t)
  case i
  when "rec"
    if @file #close file if open
      @file.close
      @file=nil
    end
    @file=WavFile.new(@path,2,@samplerate)
    @mode=true
  when "stop"
    @mode=false
    if @file
      @file.close
      @file=nil
    end
  when "frame"
    if @mode and @file
      @file.write(@frame.to_array)
    end
    output "recout",@mode
  end
end

arrays

ruby

audio

floating

0 Answers

Your Answer

Accepted video resources