wavfile.base module
The main API for reading and writing wav files.
- class wavfile.base.Wavfile
Bases:
ABCAbstract base class for wave file read/write
- __init__() None
Initialise the base class.
- fp: IO | None
- property num_channels: int
Number of audio channels in the file
- property sample_rate: int
Sampling rate of the audio data
- property bits_per_sample: int
Number of bits per audio sample
- property num_frames: int
Number of audio frames in the file
- property duration: float
Duration of the file in seconds
- property hms: str
Duration of the file formatted as hh:mm:ss.tt
- property metadata: Dict[str, int | str] | None
Metadata from the .wav file
- seek(frame_number: int, whence: int = 0) Wavfile
Move to the specified frame number. The frame positioning mode
whenceare: 0 (default) = absolute positioning, 1 = relative to current position, 2 = relative to end of last frame.- Parameters:
frame_number – The frame number.
whence – The frame positioning mode.
- Returns:
The method returns the object.
- tell() int
Get the current frame number.
- close() None
Close the wav file.
- __exit__(*args: Tuple[Any, ...]) None