Class: AudioPlayback::Sound
- Inherits:
-
Object
- Object
- AudioPlayback::Sound
- Extended by:
- Forwardable
- Defined in:
- lib/audio-playback/sound.rb
Instance Attribute Summary collapse
-
#audio_file ⇒ Object
readonly
Returns the value of attribute audio_file.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Class Method Summary collapse
-
.load(file_or_path, options = {}) ⇒ Sound
Load a sound from the given file path.
Instance Method Summary collapse
-
#initialize(audio_file, options = {}) ⇒ Sound
constructor
A new instance of Sound.
-
#report(logger) ⇒ Boolean
Log a report about the sound.
Constructor Details
#initialize(audio_file, options = {}) ⇒ Sound
Returns a new instance of Sound.
23 24 25 26 27 |
# File 'lib/audio-playback/sound.rb', line 23 def initialize(audio_file, = {}) @audio_file = audio_file populate() report([:logger]) if [:logger] end |
Instance Attribute Details
#audio_file ⇒ Object (readonly)
Returns the value of attribute audio_file.
7 8 9 |
# File 'lib/audio-playback/sound.rb', line 7 def audio_file @audio_file end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/audio-playback/sound.rb', line 7 def data @data end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
7 8 9 |
# File 'lib/audio-playback/sound.rb', line 7 def size @size end |
Class Method Details
.load(file_or_path, options = {}) ⇒ Sound
Load a sound from the given file path
15 16 17 18 |
# File 'lib/audio-playback/sound.rb', line 15 def self.load(file_or_path, = {}) file = AudioPlayback::File.new(file_or_path) new(file, ) end |
Instance Method Details
#report(logger) ⇒ Boolean
Log a report about the sound
32 33 34 35 36 37 38 |
# 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 |