module Libsamplerate

Constants

CONVERTERS
VERSION

Public Class Methods

get_float_buffer_from_mono_file(file) click to toggle source
# File lib/utils.rb, line 12
def self.get_float_buffer_from_mono_file file
  raise "This is not a mono file" if get_sound_file_info(file).channels == 1
  buffer = []
  RubyAudio::Sound.open(file) do |snd|
    snd.read(:float, snd.info.frames).each do |sample|
      buffer.push(sample)
    end
  end
  buffer
end
get_sound_file_info(file_path) click to toggle source
# File lib/utils.rb, line 23
def self.get_sound_file_info file_path
  info = nil
  RubyAudio::Sound.open(file_path) do |snd|
    info = snd.info
  end
  info
end
stereo_to_mono(file_path) click to toggle source
# File lib/utils.rb, line 2
def self.stereo_to_mono file_path
  buffer = []
  RubyAudio::Sound.open(file_path) do |snd|
    snd.read(:float, snd.info.frames).each do |sample|
      buffer.push(sample[0])
    end
  end
  buffer
end