From e376490106e1e118f03c21ccd7ef1d1d5e00f59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 26 Dec 2022 05:38:49 +0100 Subject: [PATCH] Audio --- README.md | 2 +- index.html | 6 +++--- parse.js | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 38bf01a..5091bbe 100644 --- a/README.md +++ b/README.md @@ -2907,7 +2907,7 @@ def write_to_wav_file(filename, float_samples, nchannels=1, sampwidth=2, framera #### Saves a 440 Hz sine wave to a mono WAV file: ```python from math import pi, sin -samples_f = (sin(i * 2 * pi * 440 / 44100) for i in range(100000)) +samples_f = (sin(i * 2 * pi * 440 / 44100) for i in range(100_000)) write_to_wav_file('test.wav', samples_f) ``` diff --git a/index.html b/index.html index 0145148..8700b8f 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -2371,7 +2371,7 @@ nframes = <Wave_read>.getnframes()

Examples

Saves a 440 Hz sine wave to a mono WAV file:

from math import pi, sin
-samples_f = (sin(i * 2 * pi * 440 / 44100) for i in range(100000))
+samples_f = (sin(i * 2 * pi * 440 / 44100) for i in range(100_000))
 write_to_wav_file('test.wav', samples_f)
 
@@ -2915,7 +2915,7 @@ $ pyinstaller script.py --add-data '<path>:.'
- +
diff --git a/parse.js b/parse.js index dcd16a0..56cd3ad 100755 --- a/parse.js +++ b/parse.js @@ -168,6 +168,11 @@ const PROGRESS_BAR = '... sleep(1)\n' + 'Processing: 100%|████████████████████| 3/3 [00:03<00:00, 1.00s/it]\n'; +const AUDIO = + 'from math import pi, sin\n' + + 'samples_f = (sin(i * 2 * pi * 440 / 44100) for i in range(100_000))\n' + + 'write_to_wav_file(\'test.wav\', samples_f)\n'; + const MARIO = 'import collections, dataclasses, enum, io, itertools as it, pygame as pg, urllib.request\n' + 'from random import randint\n' + @@ -742,6 +747,7 @@ function fixHighlights() { $(`code:contains(ValueError: malformed node)`).html(EVAL); $(`code:contains(import asyncio, collections, curses, curses.textpad, enum, random)`).html(COROUTINES); $(`code:contains(pip3 install tqdm)`).html(PROGRESS_BAR); + $(`code:contains(samples_f = (sin(i *)`).html(AUDIO); $(`code:contains(collections, dataclasses, enum, io, itertools)`).html(MARIO); $(`code:contains(pip3 install pyinstaller)`).html(PYINSTALLER); $(`ul:contains(Only available in)`).html(INDEX);