/**
 * Audio library (Workstream 13). One `audio_files` store backs a flexible sound
 * library: each row is a `file` (uploaded binary), a `url` (external link) or a
 * `recipe` (client-synthesized sound). `file`/`url` populate `url`; `recipe`
 * populates `recipe` and is played purely via the Web Audio API.
 */
export type AudioFileKind = 'file' | 'url' | 'recipe';

export type SoundRecipeWaveform = 'sine' | 'triangle' | 'square' | 'sawtooth';

export interface SoundRecipeNote {
  readonly freq: number;
  readonly startAt: number;
  readonly duration: number;
  readonly gain: number;
  readonly attack?: number;
  readonly rampFreqTo?: number;
}

export interface SoundRecipeVoice {
  readonly waveform: SoundRecipeWaveform;
  readonly notes: readonly SoundRecipeNote[];
}

export interface SoundRecipe {
  readonly voices: readonly SoundRecipeVoice[];
}

export interface AudioFileDto {
  readonly id: string;
  readonly title: string;
  readonly kind: AudioFileKind;
  readonly url: string | null;
  readonly recipe: SoundRecipe | null;
  readonly is_default: boolean;
  readonly organizationId: string | null;
  readonly campusId: string | null;
  readonly createdAt: string;
  readonly updatedAt: string;
}

export interface AudioFileMutationDto {
  readonly kind: AudioFileKind;
  readonly title: string;
  readonly url?: string;
  readonly recipe?: SoundRecipe;
}
