PyWave
Open and read Wave files
PyWave is a small extension that enables you to open and read the data of any WAVE-RIFF file.
It supports PCM, IEEE-FLOAT, EXTENSIBLE and a few other wave formats (including 32 and 64 bit waves).
Tiny documentation
About PyWave
PyWave is supposed to replace the builtin Python extension wave, which doesn't support >16-bit wave files.
Using PyWave
To install PyWave you can use the PyPI:
pip install PyWave
To use PyWave in a script, you have to import the package PyWave using
import PyWave
or a wildcard import:
from PyWave import *
The Wave class
You can use open(path) to open and read a wave file.
It will return an instance of the Wave class.
The following methods are provided by the Wave class:
Wave.read([max_bytes = None]) -> <bytes> data
    Reads and returns at most <max_bytes> bytes of data.
If <max_bytes> is None, reads until the end.
Wave.read_samples(number_of_samples) -> <bytes> data
Reads and returns at most <number_of_samples> samples of data.
Wave.seek(offset[, whence = 0]) -> None
Sets the current position in the data stream.
If <whence> is 0, <offset> is the absolute position of the
data stream in bytes.
If <whence> is 1, <offset> is added to the current position
in the data stream in bytes.
If <whence> is 2, the position will be set to the end of
the file plus <offset>.
Wave.tell() -> <int> position
Returns the current position in the data stream.
Wave.close() -> None
Closes the file handle.
And it has the following members:
Wave.format <int>
Format of the audio data. Can be any of:
- WAVE_FORMAT_PCM
- WAVE_FORMAT_IEEE_FLOAT
- WAVE_FORMAT_ALAW
- WAVE_FORMAT_MULAW
- WAVE_FORMAT_EXTENSIBLE
Otherwise the format is unknown
Wave.channels <int>
The number of audio channels present in the audio stream
Wave.frequency <int>
Sample rate of the audio stream
Wave.bitrate <int>
Number of bits per second
Wave.bits_per_sample <int>
Number of bits per sample (usually 8, 16 or 32)
Wave.samples <int>
Total number of samples in the audio data
Wave.data <bytes>
(only if <auto_read> was set to True)
Audio data as bytes
Wave.metadata <dict>
A dictionary containing metadata specified in the wave file
Example
import PyWave
PATH = "path/to/a/wave/file.wav"
wf = PyWave.open(PATH)
print("This WAVE file has the following properties:")
print(wf.channels, "channels")
print(wf.frequency, "Hz sample rate")
print(wf.bitrate, "bits per second")
print(wf.samples, "total samples")
Release files for PyWave 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| PyWave-0.3.0.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| PyWave-0.3.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size:11.6 kB
Release files / PyWave-0.3.0.tar.gz
| Download URL | PyWave-0.3.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6e365c9a50c2aff4ddc308b93bdf70a873fba4b4ecf0c24d2ba34a855b20b11
|
|
BLAKE2b-256 checksum How to use checksums |
a2d712399959f23346738497a619134cef8104f0c2e52489ee1a80484cd99cea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / PyWave-0.3.0-py2.py3-none-any.whl
| Download URL | PyWave-0.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a8ce8ffa651b842a11ec5917d5397a5a6639d3f3723d020f9d019af812cca3b9
|
|
BLAKE2b-256 checksum How to use checksums |
40ece52986a9e03e90884a99c970b032187f2f6a3dd2cec2f6c588ea811a5b44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|