Browse Source

Audio

pull/42/head
Jure Šorn 5 years ago
parent
commit
1928712d04
2 changed files with 12 additions and 10 deletions
  1. 11
      README.md
  2. 11
      index.html

11
README.md

@ -2666,11 +2666,11 @@ nframes = <Wave_read>.getnframes() # Number of frames.
<Wave_write>.writeframes(<bytes>)
```
* **Bytes object contains a seqence of frames, each consisting of one or more samples.**
* **Each sample consists of one or more bytes that, when converted to an integer, indicate the displacement of a speaker membrane at a given moment.**
* **If sample width is one, then the integer is interpreted as unsigned.**
* **For all other sample sizes the integer is interpreted as signed with little-endian byte order.**
* **Bytes object contains a sequence of frames, each consisting of one or more samples.**
* **In stereo signal first sample of a frame belongs to the left channel.**
* **Each sample consists of one or more bytes that, when converted to an integer, indicate the displacement of a speaker membrane at a given moment.**
* **If sample width is one, then the integer should be encoded as unsigned.**
* **For all other sizes the integer should be encoded as signed with little-endian byte order.**
### Sample Values
@ -2724,7 +2724,8 @@ write_to_wav_file('test.wav', frames_f)
#### Adds noise to a mono WAV file:
```python
from random import random
frames_f = (a + (random()-0.5) * 0.03 for a in read_wav_file('test.wav'))
add_noise = lambda value: value + (random()-0.5) * 0.03
frames_f = (add_noise(a) for a in read_wav_file('test.wav'))
write_to_wav_file('test.wav', frames_f)
```

11
index.html

@ -2267,11 +2267,11 @@ nframes = &lt;Wave_read&gt;.getnframes() <span class="hljs-comment"
&lt;Wave_write&gt;.writeframes(&lt;bytes&gt;)
</code></pre>
<ul>
<li><strong>Bytes object contains a seqence of frames, each consisting of one or more samples.</strong></li>
<li><strong>Each sample consists of one or more bytes that, when converted to an integer, indicate the displacement of a speaker membrane at a given moment.</strong></li>
<li><strong>If sample width is one, then the integer is interpreted as unsigned.</strong></li>
<li><strong>For all other sample sizes the integer is interpreted as signed with little-endian byte order.</strong></li>
<li><strong>Bytes object contains a sequence of frames, each consisting of one or more samples.</strong></li>
<li><strong>In stereo signal first sample of a frame belongs to the left channel.</strong></li>
<li><strong>Each sample consists of one or more bytes that, when converted to an integer, indicate the displacement of a speaker membrane at a given moment.</strong></li>
<li><strong>If sample width is one, then the integer should be encoded as unsigned.</strong></li>
<li><strong>For all other sizes the integer should be encoded as signed with little-endian byte order.</strong></li>
</ul>
<div><h3 id="samplevalues">Sample Values</h3><pre><code class="text language-text">┏━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━━━━┓
┃ sampwidth │ min │ zero │ max ┃
@ -2314,7 +2314,8 @@ write_to_wav_file(<span class="hljs-string">'test.wav'</span>, frames_f)
<div><h4 id="addsnoisetoamonowavfile">Adds noise to a mono WAV file:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> random <span class="hljs-keyword">import</span> random
frames_f = (a + (random()<span class="hljs-number">-0.5</span>) * <span class="hljs-number">0.03</span> <span class="hljs-keyword">for</span> a <span class="hljs-keyword">in</span> read_wav_file(<span class="hljs-string">'test.wav'</span>))
add_noise = <span class="hljs-keyword">lambda</span> value: value + (random()<span class="hljs-number">-0.5</span>) * <span class="hljs-number">0.03</span>
frames_f = (add_noise(a) <span class="hljs-keyword">for</span> a <span class="hljs-keyword">in</span> read_wav_file(<span class="hljs-string">'test.wav'</span>))
write_to_wav_file(<span class="hljs-string">'test.wav'</span>, frames_f)
</code></pre></div>

|||||||
100:0
Loading…
Cancel
Save