(***************************************************************)
(*                        Reactive Asco                        *)
(*             http://reactiveml.org/reactive_asco             *)
(*                                                             *)
(*                                                             *)
(*  Authors: Guillaume Baudart (guillaume.baudart@ens.fr)      *)
(*           Louis Mandel (louis.mandel@lri.fr)                *)
(*                                                             *)
(***************************************************************)

(** delay *)
type delay = float
(** label of an instrumental event *)
type instr_event_label = int
(** tempo *)
type tempo = float

(** Atomic action *)
type action =
  | Message of string  (** Max/MSP control message *)
  | Signal of (unit, unit list) event (** ReactiveML signal *)

(** Synchronization strategies *)
type sync = Tight | Loose

(** Error handling strategies *)
type err = Local | Global | Causal | Partial

(** Electronic score event *)
type score_event =
    { event : instr_event_label;
      seq : sequence; }

(** Sequence of electronic actions *)
and sequence =  (delay * asco_event) list

(** Generic asco event *)
and asco_event =
  | Group of group
  | Action of action
  | Until of asco_until

(** Asco group *)
and group =
      { group_synchro : sync;
        group_error : err;
        group_seq : sequence }

(** Preemption construct *)
and asco_until =
    { until_seq : sequence;
      until_event : instr_event_label; }

(** Instrumental score *)
type instr_score = delay list

(** Electronic score *)
type score = score_event list

(** Instrumental event *)
type instr_event =
    { index : instr_event_label;
      bps : float; }

(** Status for an event *)
type status = Detected | Missed of instr_event_label

(** Performance element *)
type perf_elem = instr_event_label * delay * action

(** Simulation of the listening machine *)
type simulation = (instr_event_label * delay * tempo) list

(** Type of input *)
type input_mode =
  | Udp
  | File of string
  | Score