module Csound.Typed.Opcode.AbletonLinkOpcodes (
    
    
    
    link_beat_force, link_beat_get, link_beat_request, link_create, ableton_link_enable, link_is_enabled, link_metro, link_peers, link_tempo_get, link_tempo_set) where

import Control.Monad.Trans.Class
import Csound.Dynamic
import Csound.Typed

-- 

-- | 
-- Forces the global network Ableton Link session to adopt a specific beat number and time.
--
-- Forces the global network Ableton Link session to adopt a specific beat number and time, like a conductor stopping an orchestra and immediately starting it again.
--
-- >  link_beat_force   i_peer, k_beat [, k_at_time_seconds  [, k_quantum ]] 
--
-- csound doc: <http://csound.com/docs/manual/link_beat_force.html>
link_beat_force ::  D -> Sig -> SE ()
link_beat_force :: D -> Sig -> SE ()
link_beat_force D
b1 Sig
b2 = Dep () -> SE ()
forall a. Dep a -> SE a
SE (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ (E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (DepT GE E -> Dep ()) -> DepT GE E -> Dep ()
forall a b. (a -> b) -> a -> b
$ GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (GE E -> DepT GE E) -> GE E -> DepT GE E
forall a b. (a -> b) -> a -> b
$ E -> E -> E
f (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
unD D
b1 GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
unSig Sig
b2
    where f :: E -> E -> E
f E
a1 E
a2 = Name -> Spec1 -> [E] -> E
opcs Name
"link_beat_force" [(Rate
Xr,[Rate
Ir,Rate
Kr,Rate
Kr,Rate
Kr])] [E
a1,E
a2]

-- | 
-- Returns the beat, phase with respect to the local quantum, and current time for the session.
--
-- Returns the beat number, phase of the beat with respect to the local quantum of the beat, and current time for the global network Ableton Link session.
--
-- > k_beat_number, k_phase, k_current_time_seconds  link_beat_get  i_peer [, k_quantum]
--
-- csound doc: <http://csound.com/docs/manual/link_beat_get.html>
link_beat_get ::  D -> (Sig,Sig,Sig)
link_beat_get :: D -> (Sig, Sig, Sig)
link_beat_get D
b1 = GE (MultiOut [E]) -> (Sig, Sig, Sig)
forall a. Tuple a => GE (MultiOut [E]) -> a
pureTuple (GE (MultiOut [E]) -> (Sig, Sig, Sig))
-> GE (MultiOut [E]) -> (Sig, Sig, Sig)
forall a b. (a -> b) -> a -> b
$ E -> MultiOut [E]
f (E -> MultiOut [E]) -> GE E -> GE (MultiOut [E])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
unD D
b1
    where f :: E -> MultiOut [E]
f E
a1 = Name -> Specs -> [E] -> MultiOut [E]
mopcs Name
"link_beat_get" ([Rate
Kr,Rate
Kr,Rate
Kr],[Rate
Ir,Rate
Kr]) [E
a1]

-- | 
-- Requests the global network Ableton Link session to adopt a specific beat number and time.
--
-- >  link_beat_request   i_peer, k_beat [, k_at_time_seconds  [, k_quantum ]] 
--
-- csound doc: <http://csound.com/docs/manual/link_beat_request.html>
link_beat_request ::  D -> Sig -> SE ()
link_beat_request :: D -> Sig -> SE ()
link_beat_request D
b1 Sig
b2 = Dep () -> SE ()
forall a. Dep a -> SE a
SE (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ (E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (DepT GE E -> Dep ()) -> DepT GE E -> Dep ()
forall a b. (a -> b) -> a -> b
$ GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (GE E -> DepT GE E) -> GE E -> DepT GE E
forall a b. (a -> b) -> a -> b
$ E -> E -> E
f (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
unD D
b1 GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
unSig Sig
b2
    where f :: E -> E -> E
f E
a1 E
a2 = Name -> Spec1 -> [E] -> E
opcs Name
"link_beat_request" [(Rate
Xr,[Rate
Ir,Rate
Kr,Rate
Kr,Rate
Kr])] [E
a1,E
a2]

-- | 
-- Creates a peer in an Ableton Link network session.
--
-- Creates a peer in an Ableton Link network session. The first peer in a session determines the initial tempo of the session. The value returned must be passed as the first parameter to all subsequent Ableton Link opcode calls for this peer.
--
-- > i_peer  link_create  [i_bpm]
--
-- csound doc: <http://csound.com/docs/manual/link_create.html>
link_create ::   D
link_create :: D
link_create  = GE E -> D
D (GE E -> D) -> GE E -> D
forall a b. (a -> b) -> a -> b
$ E -> GE E
forall (m :: * -> *) a. Monad m => a -> m a
return (E -> GE E) -> E -> GE E
forall a b. (a -> b) -> a -> b
$ E
f 
    where f :: E
f  = Name -> Spec1 -> [E] -> E
opcs Name
"link_create" [(Rate
Ir,[Rate
Ir])] []

-- | 
-- Enable or disable synchronization with the Ableton Link session.
--
-- Enable or disable synchronization with the global network Ableton Link session tempo and beat.
--
-- >   ableton_link_enable  i_peer [, k_enable]
--
-- csound doc: <http://csound.com/docs/manual/link_enable.html>
ableton_link_enable ::  D -> SE ()
ableton_link_enable :: D -> SE ()
ableton_link_enable D
b1 = Dep () -> SE ()
forall a. Dep a -> SE a
SE (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ (E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (DepT GE E -> Dep ()) -> DepT GE E -> Dep ()
forall a b. (a -> b) -> a -> b
$ GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (GE E -> DepT GE E) -> GE E -> DepT GE E
forall a b. (a -> b) -> a -> b
$ E -> E
f (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
unD D
b1
    where f :: E -> E
f E
a1 = Name -> Spec1 -> [E] -> E
opcs Name
"ableton_link_enable" [(Rate
Xr,[Rate
Ir,Rate
Kr])] [E
a1]

-- | 
-- Returns whether or not this peer is synchronized with the global network Ableton Link session.
--
-- Returns whether or not the beat and time of his peer are synchronized with the global network Ableton Link session.
--
-- > k_is_enabled  link_is_enabled  i_peer
--
-- csound doc: <http://csound.com/docs/manual/link_is_enabled.html>
link_is_enabled ::  D -> Sig
link_is_enabled :: D -> Sig
link_is_enabled D
b1 = GE E -> Sig
Sig (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ E -> E
f (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
unD D
b1
    where f :: E -> E
f E
a1 = Name -> Spec1 -> [E] -> E
opcs Name
"link_is_enabled" [(Rate
Kr,[Rate
Ir])] [E
a1]

-- | 
-- Returns a trigger that is 1 on the beat and 0 otherwise along with beat, phase, and time for this session of Ableton Link.
--
-- Returns a trigger that is 1 on the beat and 0 otherwise along with the beat, phase, and current time of Ableton Link for this session for a given quantum.
--
-- > k_trigger, k_beat, k_phase, k_current_time_seconds  link_metro  i_peer [, k_quantum]
--
-- csound doc: <http://csound.com/docs/manual/link_metro.html>
link_metro ::  D -> (Sig,Sig,Sig,Sig)
link_metro :: D -> (Sig, Sig, Sig, Sig)
link_metro D
b1 = GE (MultiOut [E]) -> (Sig, Sig, Sig, Sig)
forall a. Tuple a => GE (MultiOut [E]) -> a
pureTuple (GE (MultiOut [E]) -> (Sig, Sig, Sig, Sig))
-> GE (MultiOut [E]) -> (Sig, Sig, Sig, Sig)
forall a b. (a -> b) -> a -> b
$ E -> MultiOut [E]
f (E -> MultiOut [E]) -> GE E -> GE (MultiOut [E])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
unD D
b1
    where f :: E -> MultiOut [E]
f E
a1 = Name -> Specs -> [E] -> MultiOut [E]
mopcs Name
"link_metro" ([Rate
Kr,Rate
Kr,Rate
Kr,Rate
Kr],[Rate
Ir,Rate
Kr]) [E
a1]

-- | 
-- Returns the number of peers in the session.
--
-- Returns the number of peers in the global network Ableton Link session.
--
-- > k_count  link_peers  i_peer
--
-- csound doc: <http://csound.com/docs/manual/link_peers.html>
link_peers ::  D -> Sig
link_peers :: D -> Sig
link_peers D
b1 = GE E -> Sig
Sig (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ E -> E
f (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
unD D
b1
    where f :: E -> E
f E
a1 = Name -> Spec1 -> [E] -> E
opcs Name
"link_peers" [(Rate
Kr,[Rate
Ir])] [E
a1]

-- | 
-- Returns the current tempo of the global network Ableton Link session.
--
-- > k_bpm  link_tempo_get  i_peer
--
-- csound doc: <http://csound.com/docs/manual/link_tempo_get.html>
link_tempo_get ::  D -> Sig
link_tempo_get :: D -> Sig
link_tempo_get D
b1 = GE E -> Sig
Sig (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ E -> E
f (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
unD D
b1
    where f :: E -> E
f E
a1 = Name -> Spec1 -> [E] -> E
opcs Name
"link_tempo_get" [(Rate
Kr,[Rate
Ir])] [E
a1]

-- | 
-- Sets the tempo.
--
-- Sets the local tempo if this peer is not enabled; sets the tempo of the global network Ableton Link session if this peer is enabled.
--
-- >  link_tempo_set  i_peer, k_bpm [, k_at_time_seconds]
--
-- csound doc: <http://csound.com/docs/manual/link_tempo_set.html>
link_tempo_set ::  D -> Sig -> SE ()
link_tempo_set :: D -> Sig -> SE ()
link_tempo_set D
b1 Sig
b2 = Dep () -> SE ()
forall a. Dep a -> SE a
SE (Dep () -> SE ()) -> Dep () -> SE ()
forall a b. (a -> b) -> a -> b
$ (E -> Dep ()
forall (m :: * -> *). Monad m => E -> DepT m ()
depT_ (E -> Dep ()) -> DepT GE E -> Dep ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<) (DepT GE E -> Dep ()) -> DepT GE E -> Dep ()
forall a b. (a -> b) -> a -> b
$ GE E -> DepT GE E
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (GE E -> DepT GE E) -> GE E -> DepT GE E
forall a b. (a -> b) -> a -> b
$ E -> E -> E
f (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> D -> GE E
unD D
b1 GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
unSig Sig
b2
    where f :: E -> E -> E
f E
a1 E
a2 = Name -> Spec1 -> [E] -> E
opcs Name
"link_tempo_set" [(Rate
Xr,[Rate
Ir,Rate
Kr,Rate
Kr])] [E
a1,E
a2]