Firstly, I really enjoy the documentation. But, I can't seem to find n
or notes
documented anywhere?
Good question. I was wondering myself, and now I wanted to get to the bottom of this.
".. the documentation" - there are several. As far as the Haskell part of tidal is concerned, use :type
and :doc
in ghci. It gives good hints:
$ ghci -package tidal
ghci> import Sound.Tidal.Context
ghci> :doc n
n :: Pattern Note -> ControlPattern
-- Identifier defined in ‘Sound.Tidal.Params’
-- | The note or sample number to choose for a synth or sampleset
ghci> :doc note
note :: Pattern Note -> ControlPattern
-- Identifier defined in ‘Sound.Tidal.Params’
-- | The note or pitch to play a sound or synth with
Experimentation confirms:
for a sample set, n
sets sample number, note
sets pitch (try change each of them in the following)
d1 $ s "casio" # n 0 # note (-12)
for a synth, both n
and note
set pitch, and note
takes precedence in case both are there.
d1 $ s "superpiano" # n 42 # note (-12)
It's ultimately up to superdirt how to interpret keys and values in ControlMap
constructed by tidal. See, for example, separate out ~n and ~note parameters for samples, optionally for synths by telephon · Pull Request #79 · musikinformatik/SuperDirt · GitHub
("Other synths may use n
and note
separately if so defined")
And don't forget Hoogle, where you can search by substrings, by signature, etc.
Yes. - Search by signature does work in ghci (see 6.2.18. Typed Holes — Glasgow Haskell Compiler 9.8.1 User's Guide)
ghci> _ :: Pattern [a] -> Pattern a
<interactive>:2:1: error: [GHC-88464]
• Found hole: _ :: Pattern [a1] -> Pattern a1
Where: ‘a1’ is a rigid type variable bound by
an expression type signature:
forall a1. Pattern [a1] -> Pattern a1
at <interactive>:2:6-30
• In the expression: _ :: Pattern [a] -> Pattern a
In an equation for ‘it’: it = _ :: Pattern [a] -> Pattern a
• Relevant bindings include
it :: Pattern [a] -> Pattern a (bound at <interactive>:2:1)
Valid hole fits include
uncollect :: forall a. Pattern [a] -> Pattern a
with uncollect @a1
(imported from ‘Sound.Tidal.Context’
(and originally defined in ‘Sound.Tidal.Pattern’))
flatpat :: forall a. Pattern [a] -> Pattern a
with flatpat @a1
(imported from ‘Sound.Tidal.Context’
(and originally defined in ‘Sound.Tidal.UI’))
(NB: in languages without static types, people pray to LLMs to complete their code ...)
That too! (Typed) holes are great.
Thanks! Did not think about using ghci
for that. Neat.
Although my ghci
is not so clever as yours:
~ $ ghci
GHCi, version 9.8.2: https://www.haskell.org/ghc/ :? for help
ghci> import Sound.Tidal.Context
ghci> :doc note
Can't find any documentation for Sound.Tidal.Params.
Try re-compiling with '-haddock'.
ghci>
Might need to re-compile?
ah, thanks for reminding me, I forgot that I have this default setting in $HOME/.cabal/config
:
program-default-options
ghc-options: -haddock
Everybody should have this. Can't live without!
The manual 5.1. Using GHC — Glasgow Haskell Compiler 9.8.1 User's Guide is vastly under-selling this. "parse Haddock comments and include them in the interface file" is technically correct, but does not mention the reasion: to make them available for the :doc
command in ghci
. The command is here 3. Using GHCi — Glasgow Haskell Compiler 9.8.1 User's Guide but does not mention interface files.
If you didn't have the flag set, perhaps you can do cabal install --reinstall --lib --ghc-options=-haddock tidal
but I'm not sure. When in doubt - remove the package, or remove $HOME/.cabal/store
just to be sure ... and recompile the world.
Setting the flag in the config alone didn't change much, but cabal install --reinstall ..
did the trick!
Thanks!