lazy_wav
Module¶
Resources for opening data from Wave (.wav) files
Summary of module contents:
Name | Description |
---|---|
WavStream | A Stream related to a Wave file |
-
class
WavStream
(wave_file, keep=False)[source]¶ Bases:
audiolazy.lazy_stream.Stream
A Stream related to a Wave file
A WavStream instance is a Stream with extra attributes:
rate
: sample rate in samples per second;channels
: number of channels (1 for mono, 2 for stereo);bits
: bits per sample, a value in[8, 16, 24, 32]
.
song = WavStream("my_song.wav") with AudioIO(True) as player: player.play(song, rate=song.rate, channels=song.channels)
Note
Stereo data is kept serialized/flat, so the resulting Stream yields first a sample from one channel, then the sample from the other channel for that same time instant. Use
Stream.blocks(2)
to get a Stream with the stereo blocks.-
__add__
(other)¶
-
__and__
(other)¶
-
__eq__
(other)¶
-
__floordiv__
(other)¶
-
__ge__
(other)¶
-
__gt__
(other)¶
-
__init__
(wave_file, keep=False)[source]¶ Loads a Wave audio file.
Parameters: - wave_file – Wave file name or a already open wave file as a file-behaved object.
- keep – This flag allows keeping the data on the original range and datatype, keeping each sample an int, as stored. False by default, meaning that the resulting range is already scaled (but not normalized) to fit [-1,1). When True, data scales from
- (2 ** (bits - 1))
to2 ** (bits - 1) - 1
(signed int), except for 8 bits, where it scales from0
to255
(unsigned).
-
__invert__
()¶
-
__le__
(other)¶
-
__lshift__
(other)¶
-
__lt__
(other)¶
-
__matmul__
(other)¶
-
__mod__
(other)¶
-
__mul__
(other)¶
-
__ne__
(other)¶
-
__neg__
()¶
-
__or__
(other)¶
-
__pos__
()¶
-
__pow__
(other)¶
-
__radd__
(other)¶
-
__rand__
(other)¶
-
__rfloordiv__
(other)¶
-
__rlshift__
(other)¶
-
__rmatmul__
(other)¶
-
__rmod__
(other)¶
-
__rmul__
(other)¶
-
__ror__
(other)¶
-
__rpow__
(other)¶
-
__rrshift__
(other)¶
-
__rshift__
(other)¶
-
__rsub__
(other)¶
-
__rtruediv__
(other)¶
-
__rxor__
(other)¶
-
__sub__
(other)¶
-
__truediv__
(other)¶
-
__xor__
(other)¶
-
_unpackers
= {8: <built-in function ord>, 16: <function WavStream.<lambda>.<locals>.<lambda>>, 24: <function WavStream.<lambda>.<locals>.<lambda>>, 32: <function WavStream.<lambda>.<locals>.<lambda>>}¶