Browse Source

Audio

pull/195/head
Jure Šorn 2 months ago
parent
commit
ae8c002011
2 changed files with 6 additions and 6 deletions
  1. 4
      README.md
  2. 8
      index.html

4
README.md

@ -2078,7 +2078,7 @@ Memory View
```
```python
<list> = list(<mview>) # Returns a list of ints, floats, or bytes.
<list> = list(<mview>) # Returns a list of ints, floats or bytes.
<str> = str(<mview>, 'utf-8') # Treats memoryview as a bytes object.
<str> = <mview>.hex() # Returns hex pairs. Accepts `sep=<str>`.
```
@ -2942,7 +2942,7 @@ write_to_wav_file('test.wav', samples_f)
from random import uniform
samples_f, params = read_wav_file('test.wav')
samples_f = (f + uniform(-0.05, 0.05) for f in samples_f)
write_to_wav_file('test.wav', samples_f, params)
write_to_wav_file('test.wav', samples_f, p=params)
```
#### Plays the WAV file:

8
index.html

@ -56,7 +56,7 @@
<body>
<header>
<aside>March 2, 2025</aside>
<aside>March 3, 2025</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -1721,7 +1721,7 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
&lt;array&gt; = array(<span class="hljs-string">'&lt;typecode&gt;'</span>, &lt;mview&gt;) <span class="hljs-comment"># Treats memoryview as a sequence of numbers.</span>
&lt;file&gt;.write(&lt;mview&gt;) <span class="hljs-comment"># Writes `bytes(&lt;mview&gt;)` to the binary file.</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;list&gt; = list(&lt;mview&gt;) <span class="hljs-comment"># Returns a list of ints, floats, or bytes.</span>
<pre><code class="python language-python hljs">&lt;list&gt; = list(&lt;mview&gt;) <span class="hljs-comment"># Returns a list of ints, floats or bytes.</span>
&lt;str&gt; = str(&lt;mview&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Treats memoryview as a bytes object.</span>
&lt;str&gt; = &lt;mview&gt;.hex() <span class="hljs-comment"># Returns hex pairs. Accepts `sep=&lt;str&gt;`.</span>
</code></pre>
@ -2409,7 +2409,7 @@ write_to_wav_file(<span class="hljs-string">'test.wav'</span>, samples_f)
<div><h4 id="addsnoisetothewavfile">Adds noise to the WAV file:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> random <span class="hljs-keyword">import</span> uniform
samples_f, params = read_wav_file(<span class="hljs-string">'test.wav'</span>)
samples_f = (f + uniform(<span class="hljs-number">-0.05</span>, <span class="hljs-number">0.05</span>) <span class="hljs-keyword">for</span> f <span class="hljs-keyword">in</span> samples_f)
write_to_wav_file(<span class="hljs-string">'test.wav'</span>, samples_f, params)
write_to_wav_file(<span class="hljs-string">'test.wav'</span>, samples_f, p=params)
</code></pre></div>
<div><h4 id="playsthewavfile">Plays the WAV file:</h4><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install simpleaudio</span>
@ -2942,7 +2942,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active
<footer>
<aside>March 2, 2025</aside>
<aside>March 3, 2025</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

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