when working with ugens with lots of arguments, i think it could be
helpful to have infrastructure or conventions for named arguments,
e.g. something like this:
module Sound.SC3.UGen.Pitch (
Args(..),
pitch',
defaults
) where
import Sound.SC3 hiding (median)
data Args = Args {
initFreq :: UGen,
minFreq :: UGen,
maxFreq :: UGen,
execFreq :: UGen,
maxBinsPerOctave :: UGen,
median :: UGen,
ampThreshold :: UGen,
peakThreshold :: UGen,
downSample :: UGen
}
defaults :: Args
defaults = Args {
initFreq = 440,
minFreq = 60,
maxFreq = 4000,
execFreq = 100,
maxBinsPerOctave = 16,
median = 1,
ampThreshold = 0.01,
peakThreshold = 0.5,
downSample = 1.0
}
pitch' :: UGen -> Args -> UGen
pitch' input args = pitch
input
(initFreq args)
(minFreq args)
(maxFreq args)
(execFreq args)
(maxBinsPerOctave args)
(median args)
(ampThreshold args)
(peakThreshold args)
(downSample args)
so you can write things like this:
Pitch.pitch'
(mix (soundIn (mce audioInputChannels)))
Pitch.defaults { Pitch.initFreq = 100 }
which is slightly less ugly than providing all the defaults each
time. comments?
maybe it's possible to help writing the boilerplate with template
haskell? alternatively (somewhat more overhead): if we had some kind
of ugen database describing rates, inputs, outputs, documentation and
code examples in different languages, things like these could be
autogenerated (in fact most of the haskell ugen library).
<sk>
_______________________________________________
haskell-art mailing list
[email protected]
http://lists.lurk.org/mailman/listinfo/haskell-art