From da506c355a7b7a6a5bd26bc02c84ef49ac9adc33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Garc=C3=ADa=20Garz=C3=B3n?= Date: Mon, 13 Nov 2023 22:18:40 +0100 Subject: [PATCH] Update README.md --- README.md | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/README.md b/README.md index 5545581..0c5d03e 100644 --- a/README.md +++ b/README.md @@ -186,36 +186,6 @@ with WaveReader(sys.argv[1]) as r: w.write(.8*data) ``` -While `read_iter` is simpler and recommended, -you can still use the read function, -which is closer to the C one. - -```python -import sys, numpy as np -from wavefile import WaveReader, WaveWriter - -with WaveReader(sys.argv[1]) as r: - with WaveWriter( - 'output.wav', - channels=r.channels, - samplerate=r.samplerate, - ) as w: - w.metadata.title = r.metadata.title + " II" - w.metadata.artist = r.metadata.artist - - data = np.zeros((r.channels,512), np.float32, order='F') - nframes = r.read(data) - while nframes: - sys.stdout.write("."); sys.stdout.flush() - w.write(.8*data[:,:nframes]) - nframes = r.read(data) -``` - -Notice that with ```read``` you have to reallocate the data yourself, -the loop structure is somewhat more complex, -and you have to slice to the actual ```nframes``` because -the last block usually does not have the size you asked for. - ```read_iter``` simplifies the code by transparently: - allocating the data block for you, @@ -223,8 +193,6 @@ the last block usually does not have the size you asked for. - slicing it when the last incomplete block arrives. - - Existing alternatives (what i like and dislike) -----------------------------------------------