# HG changeset patch # User Chris Cannam # Date 1400167332 -3600 # Node ID d72c054fc8bf3a4cf30d54cd7791772cd4c5130c # Parent b218e23622462d706200ab2ae34fcd618f1878cd Limit white noise to +/-0.5 diff -r b218e2362246 -r d72c054fc8bf src/may/stream/syntheticstream.yeti --- 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;