Skip to content

Commit c74ce25

Browse files
committed
Audio
1 parent 92695eb commit c74ce25

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,7 @@ def read_wav_file(filename):
28302830
return an_int - 128 * (width == 1)
28312831
with wave.open(filename, 'rb') as file:
28322832
width = file.getsampwidth()
2833-
frames = file.readframes(file.getnframes())
2833+
frames = file.readframes(-1)
28342834
byte_samples = (frames[i: i + width] for i in range(0, len(frames), width))
28352835
return [get_int(b) / pow(2, width * 8 - 1) for b in byte_samples]
28362836
```
@@ -2872,7 +2872,7 @@ write_to_wav_file('test.wav', samples_f)
28722872
from simpleaudio import play_buffer
28732873
with wave.open('test.wav', 'rb') as file:
28742874
p = file.getparams()
2875-
frames = file.readframes(p.nframes)
2875+
frames = file.readframes(-1)
28762876
play_buffer(frames, p.nchannels, p.sampwidth, p.framerate)
28772877
```
28782878

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,7 @@
24132413
<span class="hljs-keyword">return</span> an_int - <span class="hljs-number">128</span> * (width == <span class="hljs-number">1</span>)
24142414
<span class="hljs-keyword">with</span> wave.open(filename, <span class="hljs-string">'rb'</span>) <span class="hljs-keyword">as</span> file:
24152415
width = file.getsampwidth()
2416-
frames = file.readframes(file.getnframes())
2416+
frames = file.readframes(<span class="hljs-number">-1</span>)
24172417
byte_samples = (frames[i: i + width] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">0</span>, len(frames), width))
24182418
<span class="hljs-keyword">return</span> [get_int(b) / pow(<span class="hljs-number">2</span>, width * <span class="hljs-number">8</span> - <span class="hljs-number">1</span>) <span class="hljs-keyword">for</span> b <span class="hljs-keyword">in</span> byte_samples]
24192419
</code></pre></div>
@@ -2447,7 +2447,7 @@
24472447
<span class="hljs-keyword">from</span> simpleaudio <span class="hljs-keyword">import</span> play_buffer
24482448
<span class="hljs-keyword">with</span> wave.open(<span class="hljs-string">'test.wav'</span>, <span class="hljs-string">'rb'</span>) <span class="hljs-keyword">as</span> file:
24492449
p = file.getparams()
2450-
frames = file.readframes(p.nframes)
2450+
frames = file.readframes(<span class="hljs-number">-1</span>)
24512451
play_buffer(frames, p.nchannels, p.sampwidth, p.framerate)
24522452
</code></pre></div>
24532453

0 commit comments

Comments
 (0)