quasimoto.wave package#

Submodules#

quasimoto.wave.mixins module#

A module hosting mixin classes related to WAVE files.

class quasimoto.wave.mixins.FormatMixin[source]#

Bases: LoggerMixin

A class mixin for classes that use wave format data.

byte_order = 2#
property channels: int#

Get the number of channels in this stream.

property sample_bits: int#

Get the number of bits per sample.

property sample_bytes: int#

Get the number of bytes per sample.

property sample_period: float#

Get the sample period for this data.

property sample_rate: int#

Get the sample rate.

validate_header(header: Protocol) None[source]#

Validate the ‘fmt ‘ chunk data.

quasimoto.wave.protocol module#

A module implementing a protocol factory for the ‘fmt ‘ chunk data.

class quasimoto.wave.protocol.WaveFormat[source]#

Bases: ProtocolFactory

Parse the WAVE format data from bytes.

classmethod initialize(protocol: Protocol) None[source]#

Initialize this protocol.

protocol: Protocol = <runtimepy.codec.protocol.Protocol object>#

quasimoto.wave.reader module#

A module implementing interfaces for reading WAVE files.

class quasimoto.wave.reader.WaveReader(riff: RiffInterface)[source]#

Bases: FormatMixin

A class for reading and writing WAVE files.

chunked_samples(count: int) Iterator[list[tuple[int, ...]]][source]#

Iterate over samples in chunks.

property duration_s: float#

Get the duration in seconds of this data.

property duration_str: str#

Get this data’s duration as a human-readable string.

static from_path(path: Path) Iterator[WaveReader][source]#

Get a WAVE reader from a path.

property num_samples: int#

Get the number of samples contained.

property samples: Iterator[tuple[int, ...]]#

Get raw samples as a generator.

quasimoto.wave.writer module#

A module implementing interfaces for writing WAVE files.

class quasimoto.wave.writer.WaveWriter(riff: RiffInterface, num_channels: int = 2, sample_rate: int = 48000, bits_per_sample: int = 16)[source]#

Bases: FormatMixin

A class for reading and writing WAVE files.

static from_path(path: Path, **kwargs) Iterator[WaveWriter][source]#

Get a WAVE reader from a path.

classmethod to_bytes(value: int) bytes[source]#

Convert a sample value to bytes.

classmethod to_stream(stream: BinaryIO, value: int) int[source]#

Write a value to a stream.

write(samples: Iterable[tuple[int, ...]]) None[source]#

Write samples to the output.

Module contents#

A module implementing interfaces for WAVE files.

class quasimoto.wave.WaveReader(riff: RiffInterface)[source]#

Bases: FormatMixin

A class for reading and writing WAVE files.

chunked_samples(count: int) Iterator[list[tuple[int, ...]]][source]#

Iterate over samples in chunks.

property duration_s: float#

Get the duration in seconds of this data.

property duration_str: str#

Get this data’s duration as a human-readable string.

static from_path(path: Path) Iterator[WaveReader][source]#

Get a WAVE reader from a path.

property num_samples: int#

Get the number of samples contained.

property samples: Iterator[tuple[int, ...]]#

Get raw samples as a generator.

class quasimoto.wave.WaveWriter(riff: RiffInterface, num_channels: int = 2, sample_rate: int = 48000, bits_per_sample: int = 16)[source]#

Bases: FormatMixin

A class for reading and writing WAVE files.

static from_path(path: Path, **kwargs) Iterator[WaveWriter][source]#

Get a WAVE reader from a path.

classmethod to_bytes(value: int) bytes[source]#

Convert a sample value to bytes.

classmethod to_stream(stream: BinaryIO, value: int) int[source]#

Write a value to a stream.

write(samples: Iterable[tuple[int, ...]]) None[source]#

Write samples to the output.