hsc3-0.20: Haskell SuperCollider
Safe HaskellSafe-Inferred
LanguageHaskell2010

Sound.Sc3.Server.Transport.Monad

Description

Monad variant of interaction with the scsynth server.

Synopsis

hosc variants

async :: DuplexOsc m => Message -> m Message Source #

sendMessage and waitReply for a /done reply.

maybe_async :: DuplexOsc m => Message -> m () Source #

If isAsync then async_ else sendMessage.

maybe_async_at :: DuplexOsc m => Time -> Message -> m () Source #

Variant that timestamps synchronous messages.

type Sc3_Address = (String, Int) Source #

Hostname and port number.

sc3_default_udp :: Sc3_Address Source #

Local host (ie. 127.0.0.1) at port sc3_port_def

sc3_udp_limit :: Num n => n Source #

Maximum packet size, in bytes, that can be sent over Udp. However, see also https://tools.ietf.org/html/rfc2675

withSc3At :: Sc3_Address -> Connection Udp a -> IO a Source #

Bracket Sc3 communication at indicated host and port.

withSc3 :: Connection Udp a -> IO a Source #

Bracket Sc3 communication, ie. withSc3At sc3_default_udp.

import Sound.Sc3.Server.Command
withSc3 (sendMessage status >> waitReply "/status.reply")

withSc3_tm :: Double -> Connection Udp a -> IO (Maybe a) Source #

timeout_r of withSc3

withSc3AtSeq :: Sc3_Address -> Int -> Connection Udp a -> IO [a] Source #

Run f at k scsynth servers with sequential port numbers starting at sc3_port_def.

withSc3AtSeq sc3_default_udp 2 (sendMessage status >> waitReply "/status.reply")

Server control

stop :: SendOsc m => m () Source #

Free all nodes (g_freeAll) at group 1.

Composite

reset :: SendOsc m => m () Source #

Runs clearSched and then frees and re-creates groups 1 and 2.

type Play_Opt = (Node_Id, AddAction, Group_Id, [(String, Double)]) Source #

(node-id,add-action,group-id,parameters)

play_graphdef_msg :: Play_Opt -> Graphdef -> Message Source #

Make s_new message to play Graphdef.

recv_or_load_graphdef :: Transport m => Graphdef -> m Message Source #

If the graph size is less than sc3_udp_limit encode and send using d_recv_bytes, else write to temporary directory and read using d_load.

playGraphdef :: Transport m => Play_Opt -> Graphdef -> m () Source #

Send d_recv and s_new messages to scsynth.

playSynthdef :: Transport m => Play_Opt -> Synthdef -> m () Source #

Send d_recv and s_new messages to scsynth.

playUgen :: Transport m => Play_Opt -> Ugen -> m () Source #

Send an anonymous instrument definition using playSynthdef.

Nrt

run_bundle :: Transport m => Time -> Bundle -> m () Source #

Wait (pauseThreadUntil) until bundle is due to be sent relative to the initial Time, then send each message, asynchronously if required.

nrt_play :: Transport m => Nrt -> m () Source #

Play an Nrt score (as would be rendered by writeNrt).

let sc = Nrt [bundle 1 [s_new0 "default" (-1) AddToHead 1]
             ,bundle 2 [n_set1 (-1) "gate" 0]]
in withSc3 (nrt_play sc)

nrt_play_reorder :: Transport m => Nrt -> m () Source #

Variant where asynchronous commands at time 0 are separated out and run before the initial time-stamp is taken. This re-orders synchronous commands in relation to asynchronous at time 0.

Audible

class Audible e where Source #

Class for values that can be encoded and send to scsynth for audition.

Minimal complete definition

playAt

Methods

playAt :: Transport m => Play_Opt -> e -> m () Source #

play :: Transport m => e -> m () Source #

Variant where id is -1.

Instances

Instances details
Audible Graphdef Source # 
Instance details

Defined in Sound.Sc3.Server.Transport.Monad

Methods

playAt :: Transport m => Play_Opt -> Graphdef -> m () Source #

play :: Transport m => Graphdef -> m () Source #

Audible Synthdef Source # 
Instance details

Defined in Sound.Sc3.Server.Transport.Monad

Methods

playAt :: Transport m => Play_Opt -> Synthdef -> m () Source #

play :: Transport m => Synthdef -> m () Source #

Audible Ugen Source # 
Instance details

Defined in Sound.Sc3.Server.Transport.Monad

Methods

playAt :: Transport m => Play_Opt -> Ugen -> m () Source #

play :: Transport m => Ugen -> m () Source #

def_play_opt :: Play_Opt Source #

Default Play_Opt, ie. (-1,addToHead,1,[])

Notifications

withNotifications :: DuplexOsc m => m a -> m a Source #

Turn on notifications, run f, turn off notifications, return result.

Buffer & control & node variants.

b_getn1_data :: DuplexOsc m => Int -> (Int, Int) -> m [Double] Source #

Variant of b_getn1 that waits for return message and unpacks it.

withSc3_tm 1.0 (b_getn1_data 0 (0,5))

b_getn1_data_segment :: DuplexOsc m => Int -> Int -> (Int, Int) -> m [Double] Source #

Variant of b_getn1_data that segments individual b_getn messages to n elements.

withSc3_tm 1.0 (b_getn1_data_segment 1 0 (0,5))

b_fetch :: DuplexOsc m => Int -> Int -> m [[Double]] Source #

Variant of b_getn1_data_segment that gets the entire buffer.

b_fetch1 :: DuplexOsc m => Int -> Int -> m [Double] Source #

First channel of b_fetch, errors if there is no data.

withSc3 (b_fetch1 512 123456789)

b_fetch_hdr :: Transport m => Int -> Int -> m ((Int, Int, Int, Double), [[Double]]) Source #

Combination of b_query1_unpack and b_fetch.

b_query1_unpack_generic :: (DuplexOsc m, Num n, Fractional r) => Int -> m (n, n, n, r) Source #

b_info_unpack_err of b_query1.

b_query1_unpack :: DuplexOsc m => Buffer_Id -> m (Int, Int, Int, Double) Source #

Type specialised b_query1_unpack_generic.

withSc3 (b_query1_unpack 0)

c_getn1_data :: (DuplexOsc m, Floating t) => (Int, Int) -> m [t] Source #

Variant of c_getn1 that waits for the reply and unpacks the data.

n_query1_unpack_f :: DuplexOsc m => (Message -> t) -> Node_Id -> m t Source #

Apply f to result of n_query.

n_query1_unpack :: DuplexOsc m => Node_Id -> m (Maybe (Int, Int, Int, Int, Int, Maybe (Int, Int))) Source #

Variant of n_query that waits for and unpacks the reply.

n_query1_unpack_plain :: DuplexOsc m => Node_Id -> m [Int] Source #

Variant of n_query1_unpack that returns plain (un-lifted) result.

g_queryTree1_unpack :: DuplexOsc m => Group_Id -> m Query_Node Source #

Variant of g_queryTree that waits for and unpacks the reply.

Status

serverStatus :: DuplexOsc m => m [String] Source #

Collect server status information.

withSc3 serverStatus >>= mapM putStrLn

server_status_concise :: DuplexOsc m => m String Source #

Collect server status information.

withSc3 server_status_concise >>= putStrLn

serverSampleRateNominal :: DuplexOsc m => m Double Source #

Read nominal sample rate of server.

withSc3 serverSampleRateNominal

serverSampleRateActual :: DuplexOsc m => m Double Source #

Read actual sample rate of server.

withSc3 serverSampleRateActual

serverStatusData :: DuplexOsc m => m [Datum] Source #

Retrieve status data from server.

Tree

serverTree :: DuplexOsc m => m [String] Source #

Collect server node tree information.

withSc3 serverTree >>= mapM_ putStrLn