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.WaveClass(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: RuntimeIntEnum

An enumeration for valid kinds of WAVE configurations.

MONO_8 = 1#
STEREO_16 = 4#
STEREO_8 = 2#
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>#
class quasimoto.wave.protocol.WaveType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: RuntimeIntEnum

Enumeration for WAVE data formats.

PCM = 1#

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.

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 = 44100, 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.

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 = 44100, 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.