diff --git a/README.md b/README.md index 0ae7728..9ce4cd8 100644 --- a/README.md +++ b/README.md @@ -2666,11 +2666,11 @@ nframes = .getnframes() # Number of frames. .writeframes() ``` -* **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) ``` diff --git a/index.html b/index.html index c48c8ad..5caf685 100644 --- a/index.html +++ b/index.html @@ -2267,11 +2267,11 @@ nframes = <Wave_read>.getnframes()
    -
  • 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

┏━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━━━━┓
 ┃ sampwidth │     min     │ zero │     max     ┃
@@ -2314,7 +2314,8 @@ write_to_wav_file('test.wav', frames_f)
 
 
 

Adds noise to a mono WAV file:

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)