Mercurial > hg > may
changeset 571:d72c054fc8bf
Limit white noise to +/-0.5
author | Chris Cannam |
---|---|
date | Thu, 15 May 2014 16:22:12 +0100 |
parents | b218e2362246 |
children | aca6a6604fdc |
files | src/may/stream/syntheticstream.yeti |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/may/stream/syntheticstream.yeti Tue May 13 16:42:07 2014 +0100 +++ b/src/may/stream/syntheticstream.yeti Thu May 15 16:22:12 2014 +0100 @@ -43,8 +43,20 @@ result); generated sampleRate generator); +/** + * Generate a white noise stream with a maximum amplitude of 0.5. + * + * This is limited to 0.5 rather than 1.0 to help avoid + * situations in which subsequent processing causes hard-to-spot + * clipping. For example, filtering noise to limit its bandwidth + * may increase the levels of some samples: if you do this naively + * and then export the result to an audio file, it will clip and + * the resulting noise will be neither correctly distributed nor + * band-limited. But because individual samples are random, it's + * very easy to miss what is happening. + */ whiteNoise sampleRate = - generated sampleRate \((Math#random() * 2.0) - 1.0); + generated sampleRate \((Math#random() * 1.0) - 0.5); silent sampleRate = generated sampleRate \0;