# acids-ircam/platune architecture

> Architecture diagram of the GitHub repository acids-ircam/platune, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/acids-ircam/platune
- Repository: https://github.com/acids-ircam/platune

## Overview

PLaTune adds time-varying musical controls to pretrained audio-generation latents. The documented data path prepares audio, codec latents, and attributes in LMDB, then trains a latent flow model; the intended user-facing capabilities are feature extraction, feature editing, and descriptor-conditioned synthesis. Source-index references establish several internal calls, while inference implementation details are not shown, so those capability links are documented rather than inferred from unsampled code.

Main entry points: [`scripts/prepare_dataset.py`](https://github.com/acids-ircam/platune/blob/main/scripts/prepare_dataset.py) (Dataset preparation), [`platune/datasets/basic_pitch_torch/inference.py`](https://github.com/acids-ircam/platune/blob/main/platune/datasets/basic_pitch_torch/inference.py) (Pitch inference), [`scripts/train.py`](https://github.com/acids-ircam/platune/blob/main/scripts/train.py) (Training entry), [`platune/model.py`](https://github.com/acids-ircam/platune/blob/main/platune/model.py) (PLaTune flow model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_prepare["Dataset preparation<br/>[prepare_dataset.py]"]
  node_parsers["Dataset parsers<br/>[parsers.py]"]
  node_record["AudioExample records<br/>[audio_example.py]"]
  node_store[("LMDB dataset<br/>[base.py]")]
  node_dataset["Training dataset<br/>[dataset.py]"]
end

subgraph group_controls["Control extraction"]
  node_attributes["Audio attributes"]
  node_timbral["Timbral models"]
  node_pitchmodel["Pitch model<br/>[model.py]"]
  node_pitchinfer["Pitch inference<br/>[inference.py]"]
  node_notes["Note conversion<br/>[note_creation.py]"]
end

subgraph group_learning["Latent modeling"]
  node_train["Training entry<br/>[train.py]"]
  node_model["PLaTune flow model<br/>[model.py]"]
  node_transformer["Transformer networks<br/>[transformer.py]"]
  node_transformerv2["Transformer v2<br/>[transformerv2.py]"]
  node_rotary["Rotary embeddings"]
end

subgraph group_interfaces["Model interfaces"]
  node_loader["Model loaders<br/>[model_loaders.py]"]
  node_extraction["Feature extraction<br/>[model.py]"]
  node_editing["Feature editing<br/>[model.py]"]
  node_synthesis["Descriptor synthesis<br/>[model.py]"]
end

node_user(("Researcher"))
node_audio["Audio files"]
node_codec{{"Pretrained codec"}}
node_controls_result["Control features"]
node_audio_result["Generated audio"]

node_user -->|"prepares data"| node_prepare
node_audio -->|"provides audio"| node_prepare
node_prepare -->|"uses parsers"| node_parsers
node_prepare -->|"computes descriptors"| node_attributes
node_attributes -->|"uses models"| node_timbral
node_prepare -->|"extracts MIDI"| node_pitchinfer
node_pitchinfer -->|"runs model"| node_pitchmodel
node_pitchinfer -->|"converts notes"| node_notes
node_prepare -->|"serializes examples"| node_record
node_prepare -->|"writes database"| node_store
node_record -->|"decodes examples"| node_dataset
node_store -->|"reads samples"| node_dataset
node_user -->|"trains model"| node_train
node_train -->|"loads training data"| node_dataset
node_train -->|"trains model"| node_model
node_model -.->|"uses flow"| node_transformer
node_transformerv2 -->|"uses embeddings"| node_rotary
node_loader -->|"loads model"| node_model
node_user -->|"requests features"| node_extraction
node_codec -.->|"provides latents"| node_extraction
node_extraction -->|"extracts controls"| node_controls_result
node_user -->|"edits features"| node_editing
node_editing -->|"generates audio"| node_audio_result
node_user -->|"sets descriptors"| node_synthesis
node_synthesis -->|"generates audio"| node_audio_result
node_codec -.->|"decodes latents"| node_audio_result

click node_prepare "https://github.com/acids-ircam/platune/blob/main/scripts/prepare_dataset.py"
click node_parsers "https://github.com/acids-ircam/platune/blob/main/platune/datasets/parsers.py"
click node_attributes "https://github.com/acids-ircam/platune/blob/main/platune/datasets/audio_descriptors.py"
click node_timbral "https://github.com/acids-ircam/platune/tree/main/platune/datasets/timbral_models"
click node_pitchmodel "https://github.com/acids-ircam/platune/blob/main/platune/datasets/basic_pitch_torch/model.py"
click node_pitchinfer "https://github.com/acids-ircam/platune/blob/main/platune/datasets/basic_pitch_torch/inference.py"
click node_notes "https://github.com/acids-ircam/platune/blob/main/platune/datasets/basic_pitch_torch/note_creation.py"
click node_record "https://github.com/acids-ircam/platune/blob/main/platune/datasets/audio_example/audio_example.py"
click node_store "https://github.com/acids-ircam/platune/blob/main/platune/datasets/base.py"
click node_dataset "https://github.com/acids-ircam/platune/blob/main/platune/datasets/dataset.py"
click node_train "https://github.com/acids-ircam/platune/blob/main/scripts/train.py"
click node_model "https://github.com/acids-ircam/platune/blob/main/platune/model.py"
click node_transformer "https://github.com/acids-ircam/platune/blob/main/platune/networks/transformer.py"
click node_transformerv2 "https://github.com/acids-ircam/platune/blob/main/platune/networks/transformerv2.py"
click node_rotary "https://github.com/acids-ircam/platune/blob/main/platune/networks/rotary_embedding.py"
click node_loader "https://github.com/acids-ircam/platune/blob/main/platune/helpers/model_loaders.py"
click node_extraction "https://github.com/acids-ircam/platune/blob/main/platune/model.py"
click node_editing "https://github.com/acids-ircam/platune/blob/main/platune/model.py"
click node_synthesis "https://github.com/acids-ircam/platune/blob/main/platune/model.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_prepare,node_parsers,node_record,node_store,node_dataset toneBlue
class node_attributes,node_timbral,node_pitchmodel,node_pitchinfer,node_notes toneAmber
class node_train,node_model,node_transformer,node_transformerv2,node_rotary toneMint
class node_loader,node_extraction,node_editing,node_synthesis toneRose
class node_user,node_audio,node_codec,node_controls_result,node_audio_result toneIndigo
```

## Components

### Data preparation

- [Dataset preparation](https://github.com/acids-ircam/platune/blob/main/scripts/prepare_dataset.py): `scripts/prepare_dataset.py`
- [Dataset parsers](https://github.com/acids-ircam/platune/blob/main/platune/datasets/parsers.py): `platune/datasets/parsers.py`
- [AudioExample records](https://github.com/acids-ircam/platune/blob/main/platune/datasets/audio_example/audio_example.py): `platune/datasets/audio_example/audio_example.py`
- [LMDB dataset](https://github.com/acids-ircam/platune/blob/main/platune/datasets/base.py): `platune/datasets/base.py`
- [Training dataset](https://github.com/acids-ircam/platune/blob/main/platune/datasets/dataset.py): `platune/datasets/dataset.py`

### Control extraction

- [Audio attributes](https://github.com/acids-ircam/platune/blob/main/platune/datasets/audio_descriptors.py): `platune/datasets/audio_descriptors.py`
- [Timbral models](https://github.com/acids-ircam/platune/tree/main/platune/datasets/timbral_models): `platune/datasets/timbral_models`
- [Pitch model](https://github.com/acids-ircam/platune/blob/main/platune/datasets/basic_pitch_torch/model.py): `platune/datasets/basic_pitch_torch/model.py`
- [Pitch inference](https://github.com/acids-ircam/platune/blob/main/platune/datasets/basic_pitch_torch/inference.py): `platune/datasets/basic_pitch_torch/inference.py`
- [Note conversion](https://github.com/acids-ircam/platune/blob/main/platune/datasets/basic_pitch_torch/note_creation.py): `platune/datasets/basic_pitch_torch/note_creation.py`

### Latent modeling

- [Training entry](https://github.com/acids-ircam/platune/blob/main/scripts/train.py): `scripts/train.py`
- [PLaTune flow model](https://github.com/acids-ircam/platune/blob/main/platune/model.py): `platune/model.py`
- [Transformer networks](https://github.com/acids-ircam/platune/blob/main/platune/networks/transformer.py): `platune/networks/transformer.py`
- [Transformer v2](https://github.com/acids-ircam/platune/blob/main/platune/networks/transformerv2.py): `platune/networks/transformerv2.py`
- [Rotary embeddings](https://github.com/acids-ircam/platune/blob/main/platune/networks/rotary_embedding.py): `platune/networks/rotary_embedding.py`

### Model interfaces

- [Model loaders](https://github.com/acids-ircam/platune/blob/main/platune/helpers/model_loaders.py): `platune/helpers/model_loaders.py`
- [Feature extraction](https://github.com/acids-ircam/platune/blob/main/platune/model.py): `platune/model.py`
- [Feature editing](https://github.com/acids-ircam/platune/blob/main/platune/model.py): `platune/model.py`
- [Descriptor synthesis](https://github.com/acids-ircam/platune/blob/main/platune/model.py): `platune/model.py`

### Other components

- **Researcher**
- **Audio files**
- **Pretrained codec**
- **Control features**
- **Generated audio**

## Connections

- Researcher → Dataset preparation: prepares data (evidence: `README.md`)
- Audio files → Dataset preparation: provides audio (evidence: `README.md`)
- Dataset preparation → Dataset parsers: uses parsers (evidence: `scripts/prepare_dataset.py`)
- Dataset preparation → Audio attributes: computes descriptors (evidence: `scripts/prepare_dataset.py`)
- Audio attributes → Timbral models: uses models (evidence: `platune/datasets/audio_descriptors.py`)
- Dataset preparation → Pitch inference: extracts MIDI (evidence: `README.md`)
- Pitch inference → Pitch model: runs model (evidence: `platune/datasets/basic_pitch_torch/inference.py`)
- Pitch inference → Note conversion: converts notes (evidence: `platune/datasets/basic_pitch_torch/inference.py`)
- Dataset preparation → AudioExample records: serializes examples (evidence: `scripts/prepare_dataset.py`)
- Dataset preparation → LMDB dataset: writes database (evidence: `README.md`)
- AudioExample records → Training dataset: decodes examples (evidence: `platune/datasets/dataset.py`)
- LMDB dataset → Training dataset: reads samples (evidence: `platune/datasets/dataset.py`)
- Researcher → Training entry: trains model (evidence: `README.md`)
- Training entry → Training dataset: loads training data (evidence: `scripts/train.py`)
- Training entry → PLaTune flow model: trains model (evidence: `scripts/train.py`)
- PLaTune flow model → Transformer networks: uses flow
- Transformer v2 → Rotary embeddings: uses embeddings (evidence: `platune/networks/transformerv2.py`)
- Model loaders → PLaTune flow model: loads model (evidence: `platune/helpers/model_loaders.py`)
- Researcher → Feature extraction: requests features (evidence: `README.md`)
- Pretrained codec → Feature extraction: provides latents
- Feature extraction → Control features: extracts controls (evidence: `README.md`)
- Researcher → Feature editing: edits features (evidence: `README.md`)
- Feature editing → Generated audio: generates audio (evidence: `README.md`)
- Researcher → Descriptor synthesis: sets descriptors (evidence: `README.md`)
- Descriptor synthesis → Generated audio: generates audio (evidence: `README.md`)
- Pretrained codec → Generated audio: decodes latents
