Class: WaveFile::ChunkReaders::RiffReader::BaseChunkReader

Inherits:
Object
  • Object
show all
Defined in:
lib/wavefile/chunk_readers/header_reader.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#raise_error(exception_class, message) ⇒ Object

Raises:

  • (exception_class)


63
64
65
# File 'lib/wavefile/chunk_readers/header_reader.rb', line 63

def raise_error(exception_class, message)
  raise exception_class, "File '#{@file_name}' is not a supported wave file. #{message}"
end

#read_chunk_sizeObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/wavefile/chunk_readers/header_reader.rb', line 49

def read_chunk_size
  chunk_size = @file.sysread(4).unpack(UNSIGNED_INT_32).first || 0

  # The RIFF specification requires that each chunk be aligned to an even number of bytes,
  # even if the byte count is an odd number.
  #
  # See http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Docs/riffmci.pdf, page 11.
  if chunk_size.odd?
    chunk_size += 1
  end

  chunk_size
end