spell-music / csound-expression

Haskell Framework for Electronic Music
320 stars 31 forks source link

fvdelay: haddock mentions balance, but there is no such parameter? #67

Open jwaldmann opened 2 years ago

jwaldmann commented 2 years ago
Prelude Csound.Base> :doc fvdelay
 Delay with feedback.

 > fdelay maxDelayLength delayLength feedback balance

the last parameter balance does not exist, as the type shows:

Prelude Csound.Base> :i fvdelay
fvdelay :: MaxDelayTime -> DelayTime -> Feedback -> Sig -> Sig
anton-k commented 2 years ago

Thanks to mention that, sorry for late reply. I look at the sources and can see a blunder:

-- | The simplest delay with feedback. Arguments are: delay length and decay ratio.
--
-- > echo delayLength ratio
echo :: MaxDelayTime -> Feedback -> Sig -> Sig
echo len fb x = x + flanger x (sig len) fb `withD` (len + 0.005)

-- | Delay with feedback.
--
-- > fdelay maxDelayLength delayLength feedback balance
fvdelay :: MaxDelayTime -> DelayTime -> Feedback -> Sig -> Sig
fvdelay len dt fb a = a + flanger a dt fb `withD` len

So the balance is fixed to 0.5 which is a bad idea. I wonder how to deal with that? Idiomatic change is to use all wet signal in both cases and apply balance with mixAt function.

But of course it will break the code for those who already used that

anton-k commented 2 years ago

Great tip with using doc in the ghci. I was not aware of that Do you provide your own compilation routine that sets -haddock flag?

jwaldmann commented 2 years ago

Hi. I have this in $HOME/.cabal/config:

...
program-default-options
  ...
  ghc-options: -haddock

then it is applied for any cabal install --lib ... command.