-- | This module provides variations of the asynchronous server commands that
-- expect a /completion packet/ as the first argument. The completion packet
-- is executed by the server when the asynchronous command has finished. Note
-- that this mechanism is for synchronizing server side processes only, for
-- client side synchronization use @\/done@ message notification or the
-- @\/sync@ barrier.
module Sound.Sc3.Server.Command.Completion where

import Sound.Osc.Core {- hosc -}

import Sound.Sc3.Server.Enum
import Sound.Sc3.Server.Synthdef

-- | Encode an Osc packet as an Osc blob.
encode_blob :: Packet -> Datum
encode_blob :: Packet -> Datum
encode_blob = Blob -> Datum
Blob forall b c a. (b -> c) -> (a -> b) -> a -> c
. Packet -> Blob
encodePacket

-- | Install a bytecode instrument definition. (Asynchronous)
d_recv :: Packet -> Synthdef -> Message
d_recv :: Packet -> Synthdef -> Message
d_recv Packet
pkt Synthdef
d = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/d_recv" [Blob -> Datum
Blob (Synthdef -> Blob
synthdefData Synthdef
d),Packet -> Datum
encode_blob Packet
pkt]

-- | Load an instrument definition from a named file. (Asynchronous)
d_load :: Packet -> String -> Message
d_load :: Packet -> Address_Pattern -> Message
d_load Packet
pkt Address_Pattern
p = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/d_load" [Address_Pattern -> Datum
string Address_Pattern
p,Packet -> Datum
encode_blob Packet
pkt]

-- | Load a directory of instrument definitions files. (Asynchronous)
d_loadDir :: Packet -> String -> Message
d_loadDir :: Packet -> Address_Pattern -> Message
d_loadDir Packet
pkt Address_Pattern
p = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/d_loadDir" [Address_Pattern -> Datum
string Address_Pattern
p,Packet -> Datum
encode_blob Packet
pkt]

-- | Allocates zero filled buffer to number of channels and samples. (Asynchronous)
b_alloc :: Packet -> Int -> Int -> Int -> Message
b_alloc :: Packet -> Int -> Int -> Int -> Message
b_alloc Packet
pkt Int
nid Int
frames Int
channels = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/b_alloc" [forall n. Integral n => n -> Datum
int32 Int
nid,forall n. Integral n => n -> Datum
int32 Int
frames,forall n. Integral n => n -> Datum
int32 Int
channels,Packet -> Datum
encode_blob Packet
pkt]

-- | Allocate buffer space and read a sound file. (Asynchronous)
b_allocRead :: Packet -> Int -> String -> Int -> Int -> Message
b_allocRead :: Packet -> Int -> Address_Pattern -> Int -> Int -> Message
b_allocRead Packet
pkt Int
nid Address_Pattern
p Int
f Int
n = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/b_allocRead" [forall n. Integral n => n -> Datum
int32 Int
nid,Address_Pattern -> Datum
string Address_Pattern
p,forall n. Integral n => n -> Datum
int32 Int
f,forall n. Integral n => n -> Datum
int32 Int
n,Packet -> Datum
encode_blob Packet
pkt]

-- | Allocate buffer space and read a sound file, picking specific channels. (Asynchronous)
b_allocReadChannel :: Packet -> Int -> String -> Int -> Int -> [Int] -> Message
b_allocReadChannel :: Packet -> Int -> Address_Pattern -> Int -> Int -> [Int] -> Message
b_allocReadChannel Packet
pkt Int
nid Address_Pattern
p Int
f Int
n [Int]
cs = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/b_allocReadChannel" ([forall n. Integral n => n -> Datum
int32 Int
nid,Address_Pattern -> Datum
string Address_Pattern
p,forall n. Integral n => n -> Datum
int32 Int
f,forall n. Integral n => n -> Datum
int32 Int
n] forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> Datum
int32 [Int]
cs forall a. [a] -> [a] -> [a]
++ [Packet -> Datum
encode_blob Packet
pkt])

-- | Free buffer data. (Asynchronous)
b_free :: Packet -> Int -> Message
b_free :: Packet -> Int -> Message
b_free Packet
pkt Int
nid = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/b_free" [forall n. Integral n => n -> Datum
int32 Int
nid,Packet -> Datum
encode_blob Packet
pkt]

-- | Close attached soundfile and write header information. (Asynchronous)
b_close :: Packet -> Int -> Message
b_close :: Packet -> Int -> Message
b_close Packet
pkt Int
nid = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/b_close" [forall n. Integral n => n -> Datum
int32 Int
nid,Packet -> Datum
encode_blob Packet
pkt]

-- | Read sound file data into an existing buffer. (Asynchronous)
b_read :: Packet -> Int -> String -> Int -> Int -> Int -> Bool -> Message
b_read :: Packet
-> Int -> Address_Pattern -> Int -> Int -> Int -> Bool -> Message
b_read Packet
pkt Int
nid Address_Pattern
p Int
f Int
n Int
f' Bool
z = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/b_read" [forall n. Integral n => n -> Datum
int32 Int
nid,Address_Pattern -> Datum
string Address_Pattern
p,forall n. Integral n => n -> Datum
int32 Int
f,forall n. Integral n => n -> Datum
int32 Int
n,forall n. Integral n => n -> Datum
int32 Int
f',forall n. Integral n => n -> Datum
int32 (forall a. Enum a => a -> Int
fromEnum Bool
z),Packet -> Datum
encode_blob Packet
pkt]

-- | Read sound file data into an existing buffer. (Asynchronous)
b_readChannel :: Packet -> Int -> String -> Int -> Int -> Int -> Bool -> [Int] -> Message
b_readChannel :: Packet
-> Int
-> Address_Pattern
-> Int
-> Int
-> Int
-> Bool
-> [Int]
-> Message
b_readChannel Packet
pkt Int
nid Address_Pattern
p Int
f Int
n Int
f' Bool
z [Int]
cs = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/b_readChannel" ([forall n. Integral n => n -> Datum
int32 Int
nid,Address_Pattern -> Datum
string Address_Pattern
p,forall n. Integral n => n -> Datum
int32 Int
f,forall n. Integral n => n -> Datum
int32 Int
n,forall n. Integral n => n -> Datum
int32 Int
f',forall n. Integral n => n -> Datum
int32 (forall a. Enum a => a -> Int
fromEnum Bool
z)] forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map forall n. Integral n => n -> Datum
int32 [Int]
cs forall a. [a] -> [a] -> [a]
++ [Packet -> Datum
encode_blob Packet
pkt])

-- | Write sound file data. (Asynchronous)
b_write :: Packet -> Int -> String -> SoundFileFormat -> SampleFormat -> Int -> Int -> Bool -> Message
b_write :: Packet
-> Int
-> Address_Pattern
-> SoundFileFormat
-> SampleFormat
-> Int
-> Int
-> Bool
-> Message
b_write Packet
pkt Int
nid Address_Pattern
p SoundFileFormat
h SampleFormat
t Int
f Int
s Bool
z = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/b_write" [forall n. Integral n => n -> Datum
int32 Int
nid,Address_Pattern -> Datum
string Address_Pattern
p,Address_Pattern -> Datum
string (SoundFileFormat -> Address_Pattern
soundFileFormatString SoundFileFormat
h),Address_Pattern -> Datum
string (SampleFormat -> Address_Pattern
sampleFormatString SampleFormat
t),forall n. Integral n => n -> Datum
int32 Int
f,forall n. Integral n => n -> Datum
int32 Int
s,forall n. Integral n => n -> Datum
int32 (forall a. Enum a => a -> Int
fromEnum Bool
z),Packet -> Datum
encode_blob Packet
pkt]

-- | Zero sample data. (Asynchronous)
b_zero :: Packet -> Int -> Message
b_zero :: Packet -> Int -> Message
b_zero Packet
pkt Int
nid = Address_Pattern -> [Datum] -> Message
Message Address_Pattern
"/b_zero" [forall n. Integral n => n -> Datum
int32 Int
nid,Packet -> Datum
encode_blob Packet
pkt]

-- Local Variables:
-- truncate-lines:t
-- End: