pytimbre.audio.FormatChunk

class pytimbre.audio.FormatChunk(reader: FileIO = None, chunk_offset: int = None, chunk_size: int = None, chunk_name: str = None)

Bases: ChunkInformation

The format chunk is a specialized data chunk found within the wav formatted files.

__init__(reader: FileIO = None, chunk_offset: int = None, chunk_size: int = None, chunk_name: str = None)

The constructor for the format chunk. This will contain the ability to read the 16 and 40 byte formatted header :param reader: File - The binary reader that will represent the data file that we are reading :param chunk_offset: int - offset from the beginning of the file where the format chunk data begins :param chunk_size: int - the number of bytes to read that contain the data

Methods

__init__([reader, chunk_offset, chunk_size, ...])

The constructor for the format chunk.

from_waveform(wfm)

This creates an instance of the FormatChunk with the information from the waveform as the various properties of the FormatChunk class :param wfm: the audio data that is the foundation of the FormatChunk :type wfm: Waveform :return: The properly formatted FormatChunk object :rtype: FormatChunk

write_chunk(writer)

This function writes the contents of the chunk to the output file in the correct format for a canonical wav file :param writer: FileIO - the writer for the data - it is assumed that the data will be written to the current location of the writer :param sample_rate: int - the number of samples per seconds :param bits_per_sample: int - the number of bytes per sample :param channel_count: int - the number of channels

Attributes

channel_count

chunk_name

chunk_offset

chunk_size

sample_bit_size

sample_rate

waveform_format

static from_waveform(wfm: Waveform)

This creates an instance of the FormatChunk with the information from the waveform as the various properties of the FormatChunk class :param wfm: the audio data that is the foundation of the FormatChunk :type wfm: Waveform :return: The properly formatted FormatChunk object :rtype: FormatChunk

write_chunk(writer)

This function writes the contents of the chunk to the output file in the correct format for a canonical wav file :param writer: FileIO - the writer for the data - it is assumed that the data will be written to the current

location of the writer

Parameters:
  • sample_rate – int - the number of samples per seconds

  • bits_per_sample – int - the number of bytes per sample

  • channel_count – int - the number of channels