vivid-0.2.0.5: Sound synthesis with SuperCollider

Safe HaskellNone
LanguageHaskell98

Vivid.Actions

Description

Actions. VividAction has 3 instances:

Synopsis

Documentation

synth :: (VividAction m, VarList params, Subset (InnerVars params) args) => SynthDef args -> params -> m (Node args) Source

Create a real live music-playing synth from a boring, dead SynthDef.

If you haven't defined the SynthDef on the server, this will do it automatically (Note that this may cause jitters in musical timing)

Given...

>>> let foo = sd () $ out 0 [0.1 ~* whiteNoise]

...you can create a synth with...

>>> synth foo ()

Careful!: The SC server doesn't keep track of your nodes for you, so if you do something like...

>>> s <- synth someSynth ()
>>> s <- synth oops ()           -- 's' is overwritten

...you've got no way to refer to the first synth you've created, and if you want to stop it you have to cmdPeriod

(If you want to interop with SC's language, use sdNamed and synthNamed)

synthG :: (VividAction m, VarList params) => SynthDef a -> params -> m NodeId Source

Make a synth, Gradually typed -- doesn't check that _ is a subset of _ Useful e.g. if you want to send a bunch of args, some of which may be discarded

(Personally I'd recommend not using this function)

>>> let s = undefined :: SynthDef '["ok"]
>>> synth s (4::I "ok", 5::I "throwaway")
>>> <interactive>:275:7:
>>> Could not deduce (Elem "ignore" '[]) arising from a use of ‘synth’
>>> synthG s (4::I "ok", 5::I "throwaway")
>>> (works)

synthNamed :: (VividAction m, VarList params) => String -> params -> m (Node a) Source

synthNamedG :: (VividAction m, VarList params) => String -> params -> m NodeId Source

set :: (VividAction m, Subset (InnerVars params) sdArgs, VarList params) => Node sdArgs -> params -> m () Source

Set the given parameters of a running synth

e.g.

>>> let setTest = sd (0.05 ::I "pan") $ out 0 =<< pan2 (in_ $ 0.1 ~* whiteNoise, pos_ (A::A "pan"))
>>> s <- synth setTest ()
>>> set s (-0.05 ::I "pan")

Any parameters not referred to will be unaffected, and any you specify that don't exist will be (silently) ignored

play :: (VividAction m, MonoOrPoly s) => SDBody' `[]` s -> m (Node `[]`) Source

Given a UGen graph, just start playing it right away.

e.g.

play $ do
   s <- 0.2 ~* lpf (in_ whiteNoise, freq_ 440)
   out 0 [s, s]

The "out" is optional, too -- so you can write

play $ 0.2 ~* lpf (in_ whiteNoise, freq_ 440)

and an "out" will be added, in stereo

free :: (VividAction m, HasNodeId n) => n -> m () Source

Immediately stop a synth playing

This can create a "clipping" artifact if the sound goes from a high amplitude to 0 in an instant -- you can avoid that with e.g. lag or with an envelope (especially envGate)

quitSCServer :: IO () Source

Stop the SuperCollider server

makeSynth :: (VividAction m, VarList params) => ByteString -> params -> Int32 -> m NodeId Source

addAction options, from SC docs:

  • 0: add the new node to the the head of the group specified by the add target ID.
  • 1: add the new node to the the tail of the group specified by the add target ID.
  • 2: add the new node just before the node specified by the add target ID.
  • 3: add the new node just after the node specified by the add target ID.
  • 4: the new node replaces the node specified by the add target ID. The target node is freed.

synthWAction :: (VividAction m, VarList params, Subset (InnerVars params) args) => SynthDef args -> params -> Int32 -> m (Node args) Source