API Reference
- adafruit_wave.open(f, mode=None)
Open a wave file in reading (default) or writing (
mode="w") mode.The argument may be a filename or an open file.
In reading mode, returns a
Wave_readobject. In writing mode, returns aWave_writeobject.
- class adafruit_wave.Wave_read(f)
Used for wave files opened in read mode.
Do not construct directly, but call
openinstead.- close()
Close the file
- getfp()
Get the underlying file object
- getframerate()
Get the sample rate in Hz
- getnchannels()
Get the number of channels (1 for mono, 2 for stereo)
- getnframes()
Get the number of frames
- getsampwidth()
Get the sample width in bytes
- readframes(nframes)
Read frames of audio data
- rewind()
Go back to the start of the audio data
- setpos(pos)
Seek to a particular position in the audio data
- tell()
Get the current position in the audio data
- class adafruit_wave.Wave_write(f)
Used for wave files opened in write mode.
Do not construct directly, but call
openinstead.- close()
Close the file
- getframerate()
Get the sample rate in Hz
- getnchannels()
Get the number of channels (1 for mono, 2 for stereo)
- getsampwidth()
Get the sample width in bytes
- setframerate(framerate)
Set the sample rate in Hz
- setnchannels(nchannels)
Set the number of channels (1 for mono, 2 for stereo)
- setparams(params)
Set all parameters at once
- setsampwidth(sampwidth)
Set the sample width in bytes
- tell()
Get the current position in the audio data
- writeframes(data)
Write data to the file and update the header if needed
- writeframesraw(data)
Write data to the file without updating the header