vivid- Sound synthesis with SuperCollider

Safe HaskellNone




Library for interacting with the SuperCollider server.

You don't need to use much of this day-to-day

There's a toplevel scServerState that stores the current state of the SC server



cmdPeriod :: VividAction m => m () Source #

Your "emergency" button. Run this and everything playing on the SC server will be freed -- silence!

Corresponds to the cmd-. / ctrl-. key command in the SuperCollider IDE

freeAll :: VividAction m => m () Source #

Alias of cmdPeriod


newtype Synth args Source #

This enforces type safety of the arguments -- e.g. if you have a synthdef

> let x = sd (3 ::I "foo") bar
> s <- synth x ()

Then this won't typecheck (because "bar" isn't an argument to x):

> set s (4 ::I "bar")

Note that if you don't want this type safety, you can e.g.

> Synth n <- synth foo ()
> setG n (0.1 ::I "vol")


> ns <- mapM (flip synth ()) [foo, bar, baz]
> map (setG (0::I "asdf") . unSynth) ns


> n <- synthG foo ()

(You also may want to look at shrinkSynthArgs if you want to construct a list which has synthdefs or nodes of different types)





Eq (Synth args) Source # 


(==) :: Synth args -> Synth args -> Bool #

(/=) :: Synth args -> Synth args -> Bool #

Ord (Synth args) Source # 


compare :: Synth args -> Synth args -> Ordering #

(<) :: Synth args -> Synth args -> Bool #

(<=) :: Synth args -> Synth args -> Bool #

(>) :: Synth args -> Synth args -> Bool #

(>=) :: Synth args -> Synth args -> Bool #

max :: Synth args -> Synth args -> Synth args #

min :: Synth args -> Synth args -> Synth args #

Read (Synth args) Source # 


readsPrec :: Int -> ReadS (Synth args) #

readList :: ReadS [Synth args] #

readPrec :: ReadPrec (Synth args) #

readListPrec :: ReadPrec [Synth args] #

Show (Synth args) Source # 


showsPrec :: Int -> Synth args -> ShowS #

show :: Synth args -> String #

showList :: [Synth args] -> ShowS #

SynthOrNodeId (Synth x) Source # 
IsNode (Synth a) Source # 


getNodeId :: Synth a -> NodeId Source #

newtype Group :: * #





newBuffer :: VividAction m => Int32 -> m BufferId Source #

Make an empty buffer

The Int32 is the buffer length in samples. Multiply seconds by the default sample rate of the server (usually 48000) to get the number of samples

Note that this is synchronous -- it doesn't return until the buffer is allocated (in theory, this could hang if e.g. the UDP packet is lost)

newBufferFromFile :: VividAction m => FilePath -> m BufferId Source #

Make a buffer and fill it with sound data from a file

The file path should be absolute (not relative), and if you're connecting to a non-localhost server don't expect it to be able to read files from your hard drive!

Note that like "makeBuffer" this is synchronous

saveBuffer :: VividAction m => BufferId -> FilePath -> m () Source #

Write a buffer to a file

Alias of writeBuffer


closeBuffer :: VividAction m => BufferId -> m () Source #

Close an open soundfile and write header information


zeroBuf :: VividAction m => BufferId -> m () Source #

Zero the sample data in a buffer


Manual management of SC server connection

createSCServerConnection :: SCConnectConfig -> IO (Either String Socket) Source #

You usually don't need to call this function

Use this if to connect on a non-default port or to a server not at localhost

Otherwise the connection is created when it's needed. You can also use this to explicitly create the connection, so the computation is done upfront

The HostName is the ip address or "localhost". The ServiceName is the port

closeSCServerConnection :: IO () Source #

Explicitly close Vivid's connection to a SC server.

Day-to-day, you can usually just let your program run without using this.

For example though, if you're running code that uses Vivid in ghci, and you ":r", you'll want to disconnect first -- there are processes running which can step on the toes of your new instance

Also if you want to change the params of your connection (e.g. to connect to a different server), you'll want to disconnect from the other connection first

data SCConnectConfig Source #




defaultConnectConfig :: SCConnectConfig Source #

The default _scConnectConfig_clientId is 1, and sclang's is 0, so you should be able to run vivid side-by-side with the SC IDE out of the box.

shrinkSynthArgs :: Subset new old => Synth old -> Synth new Source #

So let's say you have a node:

foo :: Synth '["amp", "freq", "phase"]

and you want to add it to a list of nodes:

ns :: [Synth '["freq", "phase"]]

If you don't plan on setting the "amp" argument, you can "shrink" to the compatible arguments:

ns' = shrinkSynthArgs foo : ns

(The same thing exists for SynthDefs -- shrinkSDArgs)