Class: WaveFile::UnvalidatedFormat

Inherits:
Format
  • Object
show all
Defined in:
lib/wavefile/unvalidated_format.rb

Overview

Represents information about the data format for a Wave file, such as number of channels, bits per sample, sample rate, and so forth. A Format instance is used by Reader to indicate what format to read samples out as, and by Writer to indicate what format to write samples as.

This class is immutable - once a new Format is constructed, it can’t be modified.

Instance Attribute Summary collapse

Attributes inherited from Format

#bits_per_sample, #block_align, #byte_rate, #channels, #sample_format, #sample_rate

Instance Method Summary collapse

Methods inherited from Format

#mono?, #stereo?

Constructor Details

#initialize(fields) ⇒ UnvalidatedFormat

Constructs a new immutable UnvalidatedFormat.



10
11
12
13
14
15
16
17
# File 'lib/wavefile/unvalidated_format.rb', line 10

def initialize(fields)
  @audio_format = fields[:audio_format]
  @channels = fields[:channels]
  @sample_rate = fields[:sample_rate]
  @byte_rate = fields[:byte_rate]
  @block_align = fields[:block_align]
  @bits_per_sample = fields[:bits_per_sample]
end

Instance Attribute Details

#audio_formatObject (readonly)

Returns a number indicating the sample format, such as 1 (PCM) or 3 (Float)



20
21
22
# File 'lib/wavefile/unvalidated_format.rb', line 20

def audio_format
  @audio_format
end