sndread_chunked
- sndfileio.sndread_chunked(path, chunksize=2048, start=0.0, stop=0.0)[source]
Read a soundfile in chunks
- Parameters:
path (
str) – the path to readchunksize (
int) – the chunksize, in samplesstart (
float) – time to skip before readingstop (
float) – time to stop reading (0=end of file)
- Return type:
Iterator[ndarray]- Returns:
a generator yielding numpy arrays (float64) of at most chunksize frames
Example
>>> with sndwrite_chunked("out.flac", 44100) as writer: ... for buf in sndread_chunked("in.flac"): ... # do some processing, like changing the gain ... buf *= 0.5 ... writer.write(buf)