Class: WavFile::Format
- Inherits:
-
Object
- Object
- WavFile::Format
- Defined in:
- lib/wav-file/wav-file.rb
Instance Attribute Summary collapse
-
#bitPerSample ⇒ Object
Returns the value of attribute bitPerSample.
-
#blockSize ⇒ Object
Returns the value of attribute blockSize.
-
#bytePerSec ⇒ Object
Returns the value of attribute bytePerSec.
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#hz ⇒ Object
Returns the value of attribute hz.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #==(target) ⇒ Object
-
#initialize(chunk) ⇒ Format
constructor
A new instance of Format.
- #to_bin ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(chunk) ⇒ Format
Returns a new instance of Format.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wav-file/wav-file.rb', line 24 def initialize(chunk) return if chunk.class != Chunk return if chunk.name != 'fmt ' @id = chunk.data.slice(0,2).unpack('c')[0] @channel = chunk.data.slice(2,2).unpack('c')[0] @hz = chunk.data.slice(4,4).unpack('V').join.to_i @bytePerSec = chunk.data.slice(8,4).unpack('V').join.to_i @blockSize = chunk.data.slice(12,2).unpack('c')[0] @bitPerSample = chunk.data.slice(14,2).unpack('c')[0] end |
Instance Attribute Details
#bitPerSample ⇒ Object
Returns the value of attribute bitPerSample.
22 23 24 |
# File 'lib/wav-file/wav-file.rb', line 22 def bitPerSample @bitPerSample end |
#blockSize ⇒ Object
Returns the value of attribute blockSize.
22 23 24 |
# File 'lib/wav-file/wav-file.rb', line 22 def blockSize @blockSize end |
#bytePerSec ⇒ Object
Returns the value of attribute bytePerSec.
22 23 24 |
# File 'lib/wav-file/wav-file.rb', line 22 def bytePerSec @bytePerSec end |
#channel ⇒ Object
Returns the value of attribute channel.
22 23 24 |
# File 'lib/wav-file/wav-file.rb', line 22 def channel @channel end |
#hz ⇒ Object
Returns the value of attribute hz.
22 23 24 |
# File 'lib/wav-file/wav-file.rb', line 22 def hz @hz end |
#id ⇒ Object
Returns the value of attribute id.
22 23 24 |
# File 'lib/wav-file/wav-file.rb', line 22 def id @id end |
Instance Method Details
#==(target) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/wav-file/wav-file.rb', line 55 def ==(target) @id == target.id && @channel == target.channel && @hz == target.hz && @bytePerSec == target.bytePerSec && @bitPerSample == target.bitPerSample && @blockSize == target.blockSize end |
#to_bin ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/wav-file/wav-file.rb', line 46 def to_bin [@id].pack('v')+ [@channel].pack('v') + [@hz].pack('V') + [@bytePerSec].pack('V') + [@blockSize].pack('v') + [@bitPerSample].pack('v') end |
#to_s ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wav-file/wav-file.rb', line 35 def to_s <<EOS Format ID: #{@id} Channels: #{@channel} Sampling Ratio: #{@hz} (Hz) Byte per Sec: #{@bytePerSec} Bit per Sample: #{@bitPerSample} Block Size: #{blockSize} EOS end |