# openalice-media

> Rust + WASM AI-agent-native audio creation platform — audio graph, euclidean rhythms, Schroeder reverb, 9 genre KBs, MIDI export, 1342 WAV samples.

## At a glance
| field | value |
|---|---|
| kind | `service` |
| priority | `P4` |
| default branch | `main` |
| last activity | 2026-05-22T01:02:43+00:00 |
| features catalogued | **9** |
| runtime deps declared | **0** |

## Manifest
`.atlas-deps.yml` — parsed cleanly: **yes**

### Exposes
- `cargo_crate` — openalice-media-core
- `cargo_crate` — openalice-media-music
- `cargo_crate` — openalice-media-tools
- `cargo_crate` — openalice-media-voice
- `cargo_crate` — openalice-media-sfx

## Features (9)

### media/core
- **`media.core.music-theory`** — Tempo (BPM↔samples, swing offset), Note (12 pitch classes, MIDI, Hz), 15-scale Scale enum (Major → Chromatic), and octave-range MIDI note sets. Shared music-theory primitives used by sequencer, melody, and genre modules.  
  *crates/media-core/src/time.rs:3*
- **`media.core.pcm-buffer`** — Interleaved f32 PCM buffer with mono/stereo helpers, WAV read/write (hound), equal-power crossfade, peak normalize, and clamp. Shared foundation for all audio processing in the openalice-media workspace.  
  *crates/media-core/src/buffer.rs:3*

### media/music
- **`media.music.arrangement`** — `Song` holds named `Track`s and ordered `Section`s (intro→build→drop→outro). Each section activates a subset of tracks with gain overrides; master chain applies compressor + saturator per section. `demo_song` builds a 32-bar structured track from the sample library at runtime. A `Song` consists of named `Section`s (intro, verse, drop, etc.) arranged in sequence. Each section specifies which tracks are active and at what gain. The engine renders sections sequentially with optional crossfades.  
  *crates/media-music/src/arrangement.rs:3*
- **`media.music.audio-graph`** — Directed acyclic graph (petgraph StableGraph) of DspNode processors. Topological sort ensures correct processing order; cycle detection prevents hangs. Core routing primitive for all rendered audio in openalice-media. Topological sort ensures correct processing order (sources → sinks). Multiple inputs to a node are passed as `&[&Block]`.  
  *crates/media-music/src/graph.rs:3*
- **`media.music.automation`** — Keyframed `Automation` curves (step/linear/S-curve/exponential), `FilterSweep` (LP/HP with perceptually-linear exponential sweep), `SidechainCompressor` with `house_pump()` preset, and `NoiseRiser` (white noise through sweeping HP filter). All implemented as `DspNode`s for direct placement in the audio graph. These are time-varying DSP nodes that change parameters over the course of a section or song, enabling professional production techniques.  
  *crates/media-music/src/automation.rs:3*
- **`media.music.genre-knowledge`** — 9 GenrePresets (House, Techno, DnB, Hip-Hop, Lo-fi, Psytrance, Classical, EDM, Ambient) each with BPM range, sub-genres, moods (energy/darkness/tempo bias), AI prompt template, drum hints, effects chain, and recommended samples. `genre_prompt(genre, mood, sub_genre)` builds a structured prompt for an LLM agent to generate genre-correct music from scratch. Each genre defines: BPM range, time signature, recommended samples, chord progressions, patterns, effects chain, and sub-genres with moods. An AI agent reads these presets to generate genre-appropriate tracks.  
  *crates/media-music/src/genres.rs:3*
- **`media.music.mini-notation`** — Compact pattern DSL: sequences, subdivisions `[a b]`, alternations `<a b>`, Euclidean rhythms `(3,8)`, speed `*n`/`/n`, rests `~`. Bjorklund algorithm for Euclidean distribution. Pattern→DrumPattern conversion for audio rendering. Compact notation for patterns: ```text "bd sd [hh hh] cp"       → kick, snare, two hi-hats (subdivided), clap "bd*2 sd"                 → kick played twice fast, then snare "bd/2"                    → kick at half speed "<bd sd cp>"              → alternate between kick, snare, clap each cycle "(3,8)"                   → euclidean rhythm: 3 hits in 8 steps "~ bd"                    → rest, then kick ```  
  *crates/media-music/src/notation.rs:3*
- **`media.music.pattern-dsl`** — Human- and LLM-writable grid notation: "kick: x . x . | . . x ." Parses named tracks, maps instrument names to DrumSound variants, and renders to AudioBuffer via BPM-locked sample placement. Patterns use a simple grid notation that is both human-readable and LLM-parseable: ```text ``` Each `x` = hit, `.` = rest, `|` = bar divider (visual only).  
  *crates/media-music/src/pattern.rs:3*

### media/tools
- **`media.tools.agent-interface`** — JSON-schema tool definitions + typed Rust handlers for OpenAI/Anthropic function-calling: `music_pattern_create`, `music_render` (→WAV), `music_midi_export` (→SMF). The main OpenAlice agent calls these tools; handlers dispatch to media-music internals and return human-readable results. Provides tool schemas and handlers for the OpenAlice agent system: - `music_pattern_create` — create drum/melody patterns from notation - `music_render` — render patterns to audio (WAV) - `music_midi_export` — export patterns to MIDI files - `music_play` — preview audio in the browser  
  *crates/media-tools/src/lib.rs:3*

---

*Generated by [openalice-atlas](https://atlas.blal.pro) — single source of truth for the openalicelabs ecosystem.*
