class AudioPlayback::Sound
Attributes
audio_file[R]
data[R]
size[R]
Public Class Methods
load(file_or_path, options = {})
click to toggle source
Load a sound from the given file path @param [::File, String] file_or_path @param [Hash] options @option options [IO] logger @return [Sound]
# File lib/audio-playback/sound.rb, line 15 def self.load(file_or_path, options = {}) file = AudioPlayback::File.new(file_or_path) new(file, options) end
new(audio_file, options = {})
click to toggle source
@param [AudioPlayback::File] audio_file
@param [Hash] options @option options [IO] logger
# File lib/audio-playback/sound.rb, line 23 def initialize(audio_file, options = {}) @audio_file = audio_file populate(options) report(options[:logger]) if options[:logger] end
Public Instance Methods
report(logger)
click to toggle source
Log a report about the sound @param [IO] logger @return [Boolean]
# File lib/audio-playback/sound.rb, line 32 def report(logger) logger.puts("Sound report for #{@audio_file.path}") logger.puts(" Sample rate: #{@audio_file.sample_rate}") logger.puts(" Channels: #{@audio_file.num_channels}") logger.puts(" File size: #{@audio_file.size}") true end
Private Instance Methods
populate(options = {})
click to toggle source
Populate the sound meta/data @param [Hash] options @option options [IO] :logger @return [Sound]
# File lib/audio-playback/sound.rb, line 46 def populate(options = {}) @data = @audio_file.read(options) @size = data.size self end