# dawproject

> An arrangement to and from DAWproject, the open exchange format other DAWs read and write: tracks, returns and the main track with their mix and sends, audio clips with fades, loop and warp, MIDI clips, volume and pan automation, locators, tempo and time signatures, and the equalizer, compressor, gate and limiter; a report says what was left out. With the zip archives it is packed in.

```bash
npx shadcn@latest add @audio-ui/dawproject
```

```ts
import { writeDawproject, exportDawproject, readDawproject, importDawproject } from "@/lib/dawproject";
```

- Files: `lib/dawproject.ts`, `lib/zip.ts`
- Depends on: `arrangement`, `use-arrangement`, `compressor-device`, `equalizer-device`, `gate-device`, `limiter-device`; npm: `@audio-ui/core`, `@audio-ui/engine`, `fflate`
- Used by: nothing

| Export | Kind | What it is |
| --- | --- | --- |
| `DawprojectRecording` | interface | A recording an export packs: its file's name in the archive's `audio/` folder, its length in seconds, its channels and rate. |
| `ImportedRecording` | interface | A recording an import brings: the id its clips name it by, a name, and its file's bytes. |
| `writeDawproject` | function | The project's `project.xml` and `metadata.xml`, and what they leave out. |
| `exportDawproject` | function | A whole `.dawproject` file: the documents and the audio of every recording a clip plays, read with `bytesOf`. |
| `readDawproject` | function | A `project.xml` read into an arrangement: its tracks, return tracks and main track, its clips and automation, its locators, tempo and time signatures; the recordings its audio clips play, by the path of their file in the archive; and what it left out. |
| `importDawproject` | function | A whole `.dawproject` file read: the arrangement, the bytes of each recording, and what was left out or is missing. |

## Usage

The open DAWproject exchange format (a zip of XML and audio): an arrangement out to a `.dawproject` file other DAWs open, and one of theirs in, with a report of what was left out.

```ts
import { exportDawproject, importDawproject } from "@/lib/dawproject";

const { file, report } = await exportDawproject(doc, recordings, (id) => bytesOfRecording(id));
const opened = await importDawproject(droppedFile); // { doc, recordings, report }
```

It carries the tracks, mix, sends, clips, notes, volume and pan automation, locators, tempo and time signatures, and the equalizer, compressor, gate and limiter with their settings. `zip` (installed with it, on `fflate`) reads and writes the archive.
