csound-expression-2.0.0: library to make electronic music

Safe HaskellNone

Csound.Control.Mix

Synopsis

Documentation

data Mix a

Special type that represents a scores of sound signals. If an instrument is triggered with the scores the result is wrapped in the value of this type.

sco :: (CsdSco f, Arg a, Out b) => (a -> b) -> f a -> f (Mix (NoSE b))

Play a bunch of notes with the given instrument.

 res = sco instrument scores 
  • instrument is a function that takes notes and produces a tuple of signals (maybe with some side effect)
  • scores are some notes (see the type class CsdSco)

Let's try to understand the type of the output. It's CsdSco f => f (Mix (NoSE a)). What does it mean? Let's look at the different parts of this type:

  • CsdSco f => f a - you can think of it as a container of some values of type a (every value of type a starts at some time and lasts for some time in seconds)
  • Mix a - is an output of Csound instrument it can be one or several signals (Sig or CsdTuple).
  • NoSE a* - it's a tricky part of the output. NoSE means literaly 'no SE'. It tells to the type checker that it can skip the SE wrapper from the type a so that SE a becomes just a or SE (a, SE b, c) becomes (a, b, c). Why should it be? We need SE to deduce the order of the opcodes that have side effects. We need it within one instrument. But when instrument is rendered we no longer need SE type. So NoSE lets me drop it from the output type.

mix :: (Out (NoSE a), Out a, CsdSco f) => f (Mix a) -> NoSE a

Renders a scores to global variable that contains a resulting sound signals.

eff :: (CsdSco f, Out a, Out b) => (a -> b) -> f (Mix a) -> f (Mix b)

Applies an effect to the sound. Effect is applied to the sound on the give track.

 res = eff effect sco 
  • effect - a function that takes a tuple of signals and produces a tuple of signals.
  • sco - something that is constructed with sco or eff.

With the function eff you can apply a reverb or adjust the level of the signal. It functions like a mixing board but unlike mixing board it produces the value that you can arrange with functions from your favorite Score-generation library. You can delay it or mix with some other track and apply some another effect on top of it!