# Audacity: Project-Specific Analysis & SOP ## Architecture Summary Audacity is a multi-platform audio editor built on PortAudio for I/O and libsndfile for file format support. Its native `.aup3` format is a SQLite database containing audio data and project metadata. ``` +-------------------------------------------------+ | Audacity GUI | | +----------+ +----------+ +----------------+ | | | Timeline | | Mixer | | Effects | | | | (wxGTK) | | (wxGTK) | | (wxGTK) | | | +----+-----+ +----+-----+ +------+---------+ | | | | | | | +----+-------------+--------------+----------+ | | | Internal Audio Engine | | | | Block-based audio storage, real-time | | | | processing, effect chain, undo history | | | +--------------------+-----------------------+ | +------------------------+------------------------+ | +--------------+--------------+ | PortAudio (I/O) | libsndfile | | SoX resampler | LAME (MP3) | +---------------------------------+ ``` ## CLI Strategy: Python stdlib + JSON Project Unlike applications with XML project files, Audacity's .aup3 is SQLite, making direct manipulation complex. Our strategy: 1. **JSON project format** tracks all state (tracks, clips, effects, labels) 2. **Python stdlib** (`wave`, `struct`, `math`) handles WAV I/O and audio processing 3. **pydub** (optional) for advanced format support (MP3, FLAC, OGG) ### Why Not .aup3 Directly? The .aup3 format is a SQLite database with: - Binary audio block storage (custom compression) - Complex relational schema for tracks, clips, envelopes - Undo history embedded in the database - Project metadata interleaved with audio data Parsing and writing this format requires deep knowledge of Audacity internals. Instead, we use a JSON manifest and render to standard audio formats. ## The Project Format (.audacity-cli.json) ```json { "version": "1.0", "name": "my_podcast", "settings": { "sample_rate": 44100, "bit_depth": 16, "channels": 2 }, "tracks": [...], "labels": [...], "selection": {"start": 0.0, "end": 0.0}, "metadata": {"title": "", "artist": "", "album": "", ...} } ``` ## Command Map: GUI Action -> CLI Command | GUI Action | CLI Command | |-----------|-------------| | File -> New | `project new --name "My Project"` | | File -> Open | `project open ` | | File -> Save | `project save [path]` | | File -> Export Audio | `export render [--preset wav]` | | Tracks -> Add New -> Audio | `track add --name "Track"` | | Track -> Remove | `track remove ` | | Track -> Mute/Solo | `track set mute true` | | Track -> Volume | `track set volume 0.8` | | Track -> Pan | `track set pan -0.5` | | File -> Import -> Audio | `clip add ` | | Edit -> Remove | `clip remove ` | | Edit -> Clip Boundaries -> Split | `clip split