
On Thu, 15 Nov 2007, Bulat Ziganshin wrote:
Hello Henning,
Thursday, November 15, 2007, 2:31:07 PM, you wrote:
Btw. I would write here min 1 (max (-1) x) or even better define a function for such clipping, since it is needed quite often.
min 1 . max (-1) is pretty standard, although i renamed them: atMax 1 . atLeast (-1)
I like to add, that it is not just fancy to use functions instead of guards here. If you work with wrappers for software synthesizers like CSound and SuperCollider, you cannot map a Haskell function over a signal, say map (\x -> case x of _ | x < -1 -> -1 | x>1 -> 1 | otherwise -> x) signal but you can write Synth.min 1 $ Synth.max (-1) signal given that 'Synth.min' and 'Synth.max' call the pointwise minimum and maximum functions of the software synthesizers.