diff --git a/README.md b/README.md index fb0e67c..befd343 100644 --- a/README.md +++ b/README.md @@ -2689,7 +2689,7 @@ nframes = <Wave_read>.getnframes() # Number of frames. +-----------+-------------+------+-------------+ ``` -### Read Float Samples from WAV File +### Read Float Frames from WAV File ```python def read_wav_file(filename): def get_int(a_bytes): @@ -2702,7 +2702,7 @@ def read_wav_file(filename): return [get_int(a) / pow(2, width * 8 - 1) for a in chunks] ``` -### Write Float Samples to WAV File +### Write Float Frames to WAV File ```python def write_to_wav_file(filename, frames_float, nchannels=1, sampwidth=2, framerate=44100): def get_bytes(a_float): diff --git a/index.html b/index.html index 774ab09..ef6197d 100644 --- a/index.html +++ b/index.html @@ -2285,7 +2285,7 @@ nframes = <Wave_read>.getnframes() <span class="hljs-comment" +-----------+-------------+------+-------------+ </code></pre></div> -<div><h3 id="readfloatsamplesfromwavfile">Read Float Samples from WAV File</h3><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">read_wav_file</span><span class="hljs-params">(filename)</span>:</span> +<div><h3 id="readfloatframesfromwavfile">Read Float Frames from WAV File</h3><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">read_wav_file</span><span class="hljs-params">(filename)</span>:</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_int</span><span class="hljs-params">(a_bytes)</span>:</span> an_int = int.from_bytes(a_bytes, <span class="hljs-string">'little'</span>, signed=width!=<span class="hljs-number">1</span>) <span class="hljs-keyword">return</span> an_int - <span class="hljs-number">128</span> * (width == <span class="hljs-number">1</span>) @@ -2296,7 +2296,7 @@ nframes = <Wave_read>.getnframes() <span class="hljs-comment" <span class="hljs-keyword">return</span> [get_int(a) / 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> a <span class="hljs-keyword">in</span> chunks] </code></pre></div> -<div><h3 id="writefloatsamplestowavfile">Write Float Samples to WAV File</h3><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">write_to_wav_file</span><span class="hljs-params">(filename, frames_float, nchannels=<span class="hljs-number">1</span>, sampwidth=<span class="hljs-number">2</span>, framerate=<span class="hljs-number">44100</span>)</span>:</span> +<div><h3 id="writefloatframestowavfile">Write Float Frames to WAV File</h3><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">write_to_wav_file</span><span class="hljs-params">(filename, frames_float, nchannels=<span class="hljs-number">1</span>, sampwidth=<span class="hljs-number">2</span>, framerate=<span class="hljs-number">44100</span>)</span>:</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_bytes</span><span class="hljs-params">(a_float)</span>:</span> a_float = max(<span class="hljs-number">-1</span>, min(<span class="hljs-number">1</span> - <span class="hljs-number">2e-16</span>, a_float)) a_float += sampwidth == <span class="hljs-number">1</span>