Files
strudel/website/src/pages/learn/metadata.mdx
T
2025-12-21 10:47:01 +01:00

95 lines
2.3 KiB
Plaintext

---
title: Music metadata
layout: ../../layouts/MainLayout.astro
---
import { MiniRepl } from '../../docs/MiniRepl';
import { JsDoc } from '../../docs/JsDoc';
# Music metadata
You can optionally add some music metadata in your Strudel code, by using tags in code comments:
```js
// @title My Cool Song
// @by John Doe
// @license CC-BY-SA-4.0
```
Like other comments, those are ignored by Strudel, but it can be used by other tools to retrieve some information about the music.
## Alternative syntax
You can also use comment blocks:
```js
/*
@title My Cool Song
@by John Doe
@license CC-BY-SA-4.0
*/
```
Or define multiple tags in one line:
```js
// @title My Cool Song @by John Doe @license CC-BY-SA-4.0
```
The `title` tag has an alternative syntax using quotes (must be defined at the very begining):
```js
// "My Cool Song" @by John Doe
```
## Tags list
Available tags are:
- `@title`: music title
- `@by`: music author(s), separated by comma, eventually followed with a link in `<>` (ex: `@by John Doe <https://example.com>`)
- `@license`: music license(s), separated by comma. Each license should be specified by using the correct identifier in the [https://spdx.org/licenses/](SPDX License List). Example: CC-BY-SA-4.0. Unsure? [Choose a Creative Commons license here](https://creativecommons.org/choose/).
- `@details`: some additional information about the music
- `@url`: web page(s) related to the music (git repository, Soundcloud link, etc.)
- `@genre`: music genre(s) (pop, jazz, etc.)
- `@album`: music album name
Note to tool authors: _Never_ trust that a song has filled those fields with syntactically correct values; make sure your software is robust enough it doesn't break if it encounters bad values
## Multiple values
Some of them accepts several values, using the comma or new line separator, or duplicating the tag:
```js
/*
@by John Doe
Jane Doe
@genre pop, jazz
@url https://example.com
@url https://example.org
*/
```
You can also add optional prefixes and use tags where you want:
```js
/*
song @by John Doe
samples @by Jane Doe
*/
...
note("a3 c#4 e4 a4") // @by Sandy Sue
```
## Multiline
If a tag doesn't accept a list, it can take multi-line values:
```js
/*
@details I wrote this song in February 19th, 2023.
It was around midnight and I was lying on
the sofa in the living room.
*/
```