Class: Mext::Sound::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/mext/sound/info.rb

Overview

Mext::Sound::Info

Mext::Sound::Info is a class that holds all the information about a given sound sample.

PLEASE NOTE: current implementation only supports wav files. You are welcome to contribute a more encompassing one.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(f, dir) ⇒ Info

Returns a new instance of Info.



19
20
21
22
23
# File 'lib/mext/sound/info.rb', line 19

def initialize(f, dir)
  @filename = f
  @sound_dir = dir
  setup
end

Instance Attribute Details

#channelsObject (readonly)

Returns the value of attribute channels.



17
18
19
# File 'lib/mext/sound/info.rb', line 17

def channels
  @channels
end

#filenameObject (readonly)

Returns the value of attribute filename.



16
17
18
# File 'lib/mext/sound/info.rb', line 16

def filename
  @filename
end

#num_framesObject (readonly)

Returns the value of attribute num_frames.



17
18
19
# File 'lib/mext/sound/info.rb', line 17

def num_frames
  @num_frames
end

#sample_rateObject (readonly)

Returns the value of attribute sample_rate.



17
18
19
# File 'lib/mext/sound/info.rb', line 17

def sample_rate
  @sample_rate
end

#sound_dirObject (readonly)

Returns the value of attribute sound_dir.



16
17
18
# File 'lib/mext/sound/info.rb', line 16

def sound_dir
  @sound_dir
end

Instance Method Details

#durObject

dur

returns the total duration in seconds, calculating it with sample precision



31
32
33
# File 'lib/mext/sound/info.rb', line 31

def dur
  self.num_frames.to_f / self.sample_rate.to_f
end