I've done crude MIDI-to-gain hacks using syntax like let vol = map (* 0.01) [75,78..110]
and then gain (choose(vol))
. However, something like gain vol!!10
does not work (type error). So I'm wondering a) how to get an element from that list without the type error, and b) if there is a more straightforward approach to converting MIDI velocity to gain, such that I can write a pattern like "127 100 110 90" for gain.
gain
expects a pattern as argument, but vol !! 10
is a number.
ghci> :t gain
gain :: Pattern Double -> ControlPattern
ghci> :t vol
vol :: (Fractional b, Enum b) => [b]
You can make a number into a (constant) pattern with pure
, so:
ghci> gain $ pure $ vol !! 10
(0>1)|gain: 1.05f