Class: RubyAudio::SoundInfo
- Inherits:
-
CSoundInfo
- Object
- CSoundInfo
- RubyAudio::SoundInfo
- Defined in:
- lib/ruby-audio/sound_info.rb
Overview
Class SoundInfo
provides information about open sound files’ format, length, samplerate, channels, and other things.
Example:
snd = RubyAudio::Sound.open("snd.wav")
puts snd.info.channels #=> 2
puts snd.info.samplerate #=> 48000
snd.close
In addition it can be used to specify the format of new sound files:
info = RubyAudio::SoundInfo.new :channels => 1, :samplerate => 48000, :format => RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
snd = RubyAudio::Sound.open("new.wav", 'w', info)
Instance Method Summary collapse
-
#clone ⇒ Object
Returns a new
SoundInfo
object that is has the same channel count, sample rate, and format. -
#initialize(options = {}) ⇒ SoundInfo
constructor
Creates a new SoundInfo object and populates it using the given data.
Methods inherited from CSoundInfo
#channels, #channels=, #format, #format=, #frames, #samplerate, #samplerate=, #sections, #seekable, #valid?
Constructor Details
#initialize(options = {}) ⇒ SoundInfo
Creates a new SoundInfo object and populates it using the given data
Example:
info = RubyAudio::SoundInfo.new :channels => 1, :samplerate => 48000, :format => RubyAudio::FORMAT_WAV|RubyAudio::FORMAT_PCM_16
20 21 22 23 24 25 |
# File 'lib/ruby-audio/sound_info.rb', line 20 def initialize ={} # Populate from options if given unless .empty? .each {|key,value| send("#{key}=", value)} end end |