# ============================================================
# TASK FILE - Concerto Live "Band Example"
# Yamaha TF5 Mixer Controller
# ============================================================

event:
  name: "Concerto Live - Band Example"
  date: "2025-06-14"
  venue: "Teatro Comunale"
  notes: "FOH setup. Mix 1=IEM Vocalist, Mix 2=IEM Chitarra, Mix 3=Wedge Batteria"

cues:

  # ----------------------------------------------------------
  # PRE-SHOW: tutto silenzioso, scene base caricata
  # ----------------------------------------------------------
  - id: "CUE_01"
    name: "Pre-Show - Carica scena base"
    description: "Richiama la scena di partenza e porta tutto a zero"
    on_error: "stop"
    steps:
      - action: recall_scene
        bank: "a"
        scene: 1

      - action: wait
        ms: 3000                      # attendi che il mixer elabori la scena

      - action: refresh_cache
        wait_ms: 500

      - action: mute_channels
        channels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

      - action: set_mix_on_off
        mix: 1
        state: false
      - action: set_mix_on_off
        mix: 2
        state: false
      - action: set_mix_on_off
        mix: 3
        state: false

  # ----------------------------------------------------------
  # SOUNDCHECK: apri i canali uno alla volta con fade-in
  # ----------------------------------------------------------
  - id: "CUE_02"
    name: "Soundcheck - Fade-in canali batteria"
    description: "Canali 1-4 (kick, snare, OH sx, OH dx) portati a -10 dB gradualmente"
    on_error: "continue"
    steps:
      # Kick
      - action: set_channel_level
        channel: 1
        level_db: -40.0
      - action: set_channel_on_off
        channel: 1
        state: true
        wait_ms: 200
      - action: set_channel_level
        channel: 1
        level_db: -20.0
        wait_ms: 200
      - action: set_channel_level
        channel: 1
        level_db: -10.0
        wait_ms: 300

      # Snare
      - action: set_channel_level
        channel: 2
        level_db: -40.0
        delay_ms: 500
      - action: set_channel_on_off
        channel: 2
        state: true
        wait_ms: 200
      - action: set_channel_level
        channel: 2
        level_db: -10.0
        wait_ms: 300

      # Overhead Sx + Dx insieme
      - action: set_channel_level
        channel: 3
        level_db: -40.0
        delay_ms: 500
      - action: set_channel_level
        channel: 4
        level_db: -40.0
      - action: set_channel_on_off
        channel: 3
        state: true
      - action: set_channel_on_off
        channel: 4
        state: true
        wait_ms: 200
      - action: set_channel_pan
        channel: 3
        pan: -30                      # OH sx → sinistra
      - action: set_channel_pan
        channel: 4
        pan: 30                       # OH dx → destra
        wait_ms: 200
      - action: set_channel_level
        channel: 3
        level_db: -14.0
      - action: set_channel_level
        channel: 4
        level_db: -14.0

  # ----------------------------------------------------------
  # IEM MIX 1 (Vocalist): setup invii
  # ----------------------------------------------------------
  - id: "CUE_03"
    name: "IEM Mix 1 - Setup invii vocalist"
    description: "Configura il mix 1 per il vocalist: voce principale alta, resto basso"
    on_error: "continue"
    steps:
      - action: set_mix_level
        mix: 1
        level_db: 0.0
      - action: set_mix_on_off
        mix: 1
        state: true
        wait_ms: 200

      # Voce principale (ch 9) → Mix 1 alta
      - action: set_channel_to_mix_level
        channel: 9
        mix: 1
        level_db: 0.0
      - action: set_channel_to_mix_on_off
        channel: 9
        mix: 1
        state: true

      # Chitarra ritmica (ch 5) → Mix 1 media
      - action: set_channel_to_mix_level
        channel: 5
        mix: 1
        level_db: -6.0
        delay_ms: 100
      - action: set_channel_to_mix_on_off
        channel: 5
        mix: 1
        state: true

      # Kick (ch 1) → Mix 1 bassa (solo click per tempo)
      - action: set_channel_to_mix_level
        channel: 1
        mix: 1
        level_db: -12.0
        delay_ms: 100
      - action: set_channel_to_mix_on_off
        channel: 1
        mix: 1
        state: true

  # ----------------------------------------------------------
  # SHOW START: tutto ON, master a 0 dB
  # ----------------------------------------------------------
  - id: "CUE_04"
    name: "SHOW START - Apri tutto"
    description: "Porta tutti i canali attivi e il master a nominal"
    on_error: "stop"
    steps:
      - action: unmute_channels
        channels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

      - action: set_mix_on_off
        mix: 1
        state: true
      - action: set_mix_on_off
        mix: 2
        state: true
      - action: set_mix_on_off
        mix: 3
        state: true

      - action: recall_scene
        bank: "a"
        scene: 10                     # scena "SHOW" pre-salvata
        wait_ms: 2000

      - action: refresh_cache

  # ----------------------------------------------------------
  # PAUSA: muta rapidamente tutto il palco
  # ----------------------------------------------------------
  - id: "CUE_05"
    name: "PAUSA - Muta palco"
    description: "Muta tutti i canali di palco, lascia accesa la diffusione BG music"
    on_error: "continue"
    steps:
      - action: mute_channels
        channels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

      - action: set_channel_on_off   # ch 16 = BG music playback
        channel: 16
        state: true
        delay_ms: 200
      - action: set_channel_level
        channel: 16
        level_db: -6.0

  # ----------------------------------------------------------
  # FINE SHOW: fade-out master in 5 step da 1 secondo
  # ----------------------------------------------------------
  - id: "CUE_06"
    name: "FINE SHOW - Fade out generale"
    description: "Abbassa tutti i canali gradualmente in 5 secondi"
    on_error: "continue"
    steps:
      - action: set_channel_level
        channel: 9
        level_db: -6.0
        wait_ms: 1000
      - action: set_channel_level
        channel: 9
        level_db: -12.0
        wait_ms: 1000
      - action: set_channel_level
        channel: 9
        level_db: -20.0
        wait_ms: 1000
      - action: set_channel_level
        channel: 9
        level_db: -40.0
        wait_ms: 1000
      - action: mute_channels
        channels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16]

      - action: recall_scene
        bank: "a"
        scene: 0                      # scena vuota / safe
        delay_ms: 500
