Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

Sound guides: the review's fixes. tonejs-instruments is CC-BY 3.0 (its README), so every example that plays it credits it, and MusyngKite and FatBoy are left out as share-alike, not unlicensed. The SAO licence text says what Stability's Community License says: the person owns what it makes as far as the law allows, its sounds train no other generative model, its duties to ship the agreement, a notice and "Powered by Stability AI" fall on raea, and until raea settles them (SN2) the agent names the licence and links it instead of telling the person what it requires. Setup takes uv and git from raea's pinned tools/ensure.sh instead of an unpinned installer, names the Command Line Tools stub's status 1, and says RAEA_AUDIO_AUTOSETUP=0 stops setup-audio too. sources.md gives a one-line fetch for VSCO 2 CE and VCSL (their SFZ branches), Salamander V3, Groove MIDI (checked against its published SHA-256) and MuseScore General, each with its licence beside it; takes Mixkit's sound effects on the same terms as Pixabay's and FreePats' CC0 and CC-BY banks only. The MIDI converter pairs note-ons with note-offs, keeps a track per channel and writes raea/music's MidiFile shape, and the drum map is Roland's, which Groove MIDI was recorded on (hi-hat edges at 22 and 26, an open hi-hat take in the kit). Samplers get a root every 3 to 4 semitones: the examples fetch roots with no --notes and write the urls the command prints. The game example plays VCSL's recorded marimba instead of a TokenSynth one, raea/music's named instruments are marked as synth sketches, raea gen makes music only when the person asks for a track, the reel's bed is the person's own track or nothing, and raea sao and raea tokensynth take --dir so a take lands in the edit's asset store.

shinyobjectz9c5ab64141ea
diff --git a/sdk/guides/craft/bevy/games.md b/sdk/guides/craft/bevy/games.md
index 27270a1f..3a04dd6c 100644
--- a/sdk/guides/craft/bevy/games.md
+++ b/sdk/guides/craft/bevy/games.md
@@ -269,4 +269,5 @@ function Game() {
}
```
-sdk/react/bench/tone/game is a working game with all of this (a machine, a ducked bed, an SAO coin, a voice line).
+sdk/react/bench/tone/game is a working game with all of this (a machine, a chiptune loop that asks and answers,
+ducked under a voice line, an SAO coin).
diff --git a/sdk/guides/craft/motion.md b/sdk/guides/craft/motion.md
index 7db8c5cf..c964e8dd 100644
--- a/sdk/guides/craft/motion.md
+++ b/sdk/guides/craft/motion.md
@@ -88,8 +88,9 @@ import * as Tone from "raea/tone";
import { css } from "./styles.gen";
// the music: a chord on the title and a two-note lift after it, on a library piano (`raea sounds get
-// salamander/piano --notes C4,C5`); a sting, not a bed (motion/music)
-const piano = new Tone.Sampler({ urls: { C4: staticFile("sounds/salamander-piano/C4.mp3"), C5: staticFile("sounds/salamander-piano/C5.mp3") }, release: 1, volume: -10 }).connect(Tone.buses.music);
+// salamander/piano`: roots a minor third apart, D#4 as Ds4.mp3); a sting, not a bed (motion/music)
+const ROOTS = ["C4", "D#4", "F#4", "A4", "C5", "D#5"];
+const piano = new Tone.Sampler({ urls: Object.fromEntries(ROOTS.map((n) => [n, staticFile(`sounds/salamander-piano/${n.replace("#", "s")}.mp3`)])), release: 1, volume: -10 }).connect(Tone.buses.music);
new Tone.Part((t, n) => piano.triggerAttackRelease(n.notes, n.dur, t, n.vel), [
{ time: "0:0", notes: ["C4", "E4", "G4", "C5"], dur: "2n", vel: 0.8 },
{ time: "0:2", notes: ["D5"], dur: "8n", vel: 0.55 },
diff --git a/sdk/guides/craft/motion/gen.md b/sdk/guides/craft/motion/gen.md
index 8c7ef164..67900cdd 100644
--- a/sdk/guides/craft/motion/gen.md
+++ b/sdk/guides/craft/motion/gen.md
@@ -3,7 +3,9 @@
## What to do
- Generate a picture, a clip, music, an effect, a voice, a 3D model or words with `raea gen` when the piece needs
- something that isn't in the footage, the stock or the scene. `-o` is the folder; each command prints the files it wrote; use it like any
+ something that isn't in the footage, the stock or the scene. Music only when the person asks for a generated
+ track: a score is composed on instruments for the cut (`motion/music`), and a generated track can't be cut on the
+ bar or edited note by note. `-o` is the folder; each command prints the files it wrote; use it like any
other media (`<Img src>`, `<Video src>`, `<Audio src>`, `<Model src>`).
- Quote first. `raea gen plan FLOW` and `--plan` on a one-shot cost nothing and say where each step runs and what it
costs in cents. A run past its cap is refused before anything is spent: `--max-cents N`, else
diff --git a/sdk/guides/craft/motion/music.md b/sdk/guides/craft/motion/music.md
index ff67003b..a2f6ccb6 100644
--- a/sdk/guides/craft/motion/music.md
+++ b/sdk/guides/craft/motion/music.md
@@ -36,8 +36,9 @@ drone under a long reverb is what generated music sounds like. Before any instru
`raea sounds get tonejs-instruments/cello` copies its notes into `media/sounds/` and prints the `Sampler` that
plays them. Drums and hits come as takes for `Tone.Player`s. Whole orchestras, multi-velocity kits and drummers'
grooves are fetched by hand (`motion/sources`).
- - **TokenSynth** for a timbre no library has: `Tone.tokensynth("a bowed saw, close, eerie", ["C3", "C4", "C5"],
- { seconds: 2 })` renders those root notes once on this computer, and the Sampler pitches between them. Describe
+ - **TokenSynth** for a timbre no library has: `Tone.tokensynth("a bowed saw, close, eerie", ["C3", "E3", "G#3",
+ "C4", "E4", "G#4", "C5"], { seconds: 2 })` renders those root notes, a major third apart, once on this computer,
+ and the Sampler pitches between them. Describe
the timbre the way you'd describe a patch ("a soft wooden marimba, felt mallet, warm"; "a bright analog synth
lead, saw, short decay"); a note's `seconds` is how long it's held (under 5). Its takes need curating (below).
- Tone's own synths (`Synth`, `PolySynth`, `MonoSynth`, `MembraneSynth`, `MetalSynth`, `NoiseSynth`, `FMSynth`) for
@@ -64,10 +65,11 @@ drone under a long reverb is what generated music sounds like. Before any instru
`Tone.vary(instrument, { pitch: 0.3, volume: 2 })` so repeats don't sound copied (the variation is seeded by the
frame, so a replay is the same). Cap their voices with `maxPolyphony` (the oldest is stolen, faded in 5 ms).
- In a timeline, cut on the music: `Tone.Time("1m").toFrames(fps)` is a bar in frames, and `Tone.Time("4n")` a beat.
-- To hear a sound before writing it in, `raea sao "PROMPT" --seconds 1 -o media/sfx/try.wav` or `raea tokensynth
- "TIMBRE" --notes C3 -o media/try/` makes it now; the edit's own call with the same words and settings then plays
- what was made instead of making it again. Another `--seed` makes another take; play a seed's file by its path
- (`staticFile("sfx/try.wav")`), since `sao()` in the edit has no seed.
+- To hear a sound before writing it in, `raea sao "PROMPT" --seconds 1 --dir EDIT_DIR -o EDIT_DIR/media/sfx/try.wav`
+ or `raea tokensynth "TIMBRE" --notes C3 --dir EDIT_DIR -o EDIT_DIR/media/try/` makes it now and keeps it in the
+ edit's asset store (`--dir` is the edit's folder; without it, the folder you run it from), so the edit's own call
+ with the same words and settings then plays what was made instead of making it again. Another `--seed` makes
+ another take; play a seed's file by its path (`staticFile("sfx/try.wav")`), since `sao()` in the edit has no seed.
- When SAO or TokenSynth isn't installed yet, `raea setup-audio` installs it (`motion/sources` says what it fetches
and what to do when it fails).
@@ -171,11 +173,13 @@ remote music model, is retired: an older edit keeps the take it made, and a new
- `new Tone.Synth()` inside a component. Make instruments at the top level.
- A `https://` URL for a Sampler or a Player. Sources are media files or generated assets, and the render has no
network: `raea sounds get` puts a library's files in `media/` first.
-- One TokenSynth root for a whole part. A Sampler stretched three octaves from one note sounds chipmunked or
- muddy; give it a root every octave (or `raea sounds get` a library's roots, a minor third apart).
+- One root for a whole part, or one an octave. A Sampler stretched far from its root sounds chipmunked or muddy;
+ give it a root every 3 to 4 semitones over the range the part plays: a library's own roots (`raea sounds get`
+ with no `--notes` takes them a minor third apart, or every note the library sampled if it's sparser), or as many
+ TokenSynth roots.
- Rewording a `tokensynth()` timbre on every pass: each new wording makes its notes again. Settle the timbre first.
-- A sample library's licence ignored. CC-BY ones (FluidR3, Salamander) need their credit where the piece is shown;
- `LICENCE.txt` beside the files has the line. VCSL is CC0.
+- A sample library's licence ignored. CC-BY ones (FluidR3, Salamander, tonejs-instruments) need their credit where
+ the piece is shown; `LICENCE.txt` beside the files has the line. VCSL is CC0.
- `part.loop = true` after `part.start()`: the Part plays once. Set `loop` and `loopEnd` first.
- `Tone.Draw.schedule` for visuals. There's no draw loop: read the frame (`useCurrentFrame`) and the same times.
- Cutting on `Tone.Time("1m").toFrames(fps)` across a tempo ramp. `Tone.getTransport().bpm.rampTo(120, 4)` bends the
@@ -190,13 +194,14 @@ remote music model, is retired: an older edit keeps the take it made, and a new
Spotted as one cue over nine one-bar cards: A (bars 1 to 4) piano and a pizzicato ostinato, the flute's motif from
bar 3; B (bars 5 to 8) the ostinato drops out, bass and kit come in, the motif climbs; the button on the end card's
-cut. The instruments came from:
+cut. The instruments came from these commands, each printing the roots it fetched (with no `--notes`, a minor third
+apart from C1 to C7, or every note the library sampled when that's sparser):
```sh
-raea sounds get salamander/piano --notes C3,C4,C5
-raea sounds get fluid/pizzicato_strings --notes A2,C3,E3,A3
-raea sounds get tonejs-instruments/flute --notes C4,E4,A4,C5,E5,A5
-raea sounds get fluid/acoustic_bass --notes E1,A1,D2
+raea sounds get salamander/piano
+raea sounds get fluid/pizzicato_strings
+raea sounds get tonejs-instruments/flute
+raea sounds get fluid/acoustic_bass
raea sounds get vcsl/bass-drum-1 && raea sounds get vcsl/snare-drum-modern-1 && raea sounds get vcsl/hi-hat-cymbal
```
@@ -207,12 +212,13 @@ import * as Tone from "raea/tone";
Tone.getTransport().bpm.value = 96; // first: a Part reads its times at the tempo when it's made
const BAR = Tone.Time("1m").toFrames(30); // 75 frames
-const notes = (dir: string, names: string[]) => Object.fromEntries(names.map((n) => [n, staticFile(`sounds/${dir}/${n}.mp3`)]));
+// the roots each part's range needs, of those `raea sounds get` printed (D#3 is the file Ds3.mp3)
+const notes = (dir: string, names: string[]) => Object.fromEntries(names.map((n) => [n, staticFile(`sounds/${dir}/${n.replace("#", "s")}.mp3`)]));
const room = new Tone.Reverb({ decay: 1.6, wet: 0.2 }).connect(Tone.buses.music);
-const piano = new Tone.Sampler({ urls: notes("salamander-piano", ["C3", "C4", "C5"]), release: 1, volume: -8 }).connect(room);
-const pizz = new Tone.Sampler({ urls: notes("fluid-pizzicato_strings", ["A2", "C3", "E3", "A3"]), release: 0.2, volume: -12 }).connect(room);
-const flute = new Tone.Sampler({ urls: notes("tonejs-instruments-flute", ["C4", "E4", "A4", "C5", "E5", "A5"]), release: 0.4, volume: -6 }).connect(room);
-const bass = new Tone.Sampler({ urls: notes("fluid-acoustic_bass", ["E1", "A1", "D2"]), release: 0.3, volume: -6 }).connect(Tone.buses.music);
+const piano = new Tone.Sampler({ urls: notes("salamander-piano", ["A2", "C3", "D#3", "F#3", "A3", "C4", "D#4", "F#4"]), release: 1, volume: -8 }).connect(room);
+const pizz = new Tone.Sampler({ urls: notes("fluid-pizzicato_strings", ["D#2", "F#2", "A2", "C3", "D#3", "F#3", "A3", "C4"]), release: 0.2, volume: -12 }).connect(room);
+const flute = new Tone.Sampler({ urls: notes("tonejs-instruments-flute", ["E4", "A4", "C5", "E5", "A5", "C6"]), release: 0.4, volume: -6 }).connect(room);
+const bass = new Tone.Sampler({ urls: notes("fluid-acoustic_bass", ["D#1", "F#1", "A1", "C2", "D#2"]), release: 0.3, volume: -6 }).connect(Tone.buses.music);
const kit = new Tone.Players({
kick: staticFile("sounds/vcsl-bass-drum-1/BDrumNew_hit_v5_rr1_Sum.wav"),
snare: staticFile("sounds/vcsl-snare-drum-modern-1/Snare2_HitSN_v5_rr1_Mid.wav"),
@@ -283,8 +289,8 @@ const Edit = () => (
registerRoot(() => <Composition id="cue" component={Edit} width={1080} height={1920} fps={30} durationInFrames={BAR * 9} />);
```
-FluidR3 and Salamander are CC-BY 3.0, so the piece credits them (the line is in each `LICENCE.txt`); the flute's
-`LICENCE.txt` says its source's licence; VCSL is CC0.
+FluidR3, Salamander and tonejs-instruments (the flute) are CC-BY 3.0, so the piece credits all three (the line is in
+each `LICENCE.txt`); VCSL is CC0.
## Example: a game's sound
@@ -301,7 +307,12 @@ Tone.getTransport().bpm.value = 112;
Tone.buses.music.duck(Tone.buses.voice, { amount: -12 });
const thump = Tone.vary(new Tone.MembraneSynth({ octaves: 4, maxPolyphony: 4, poly: true }), { pitch: 0.5, volume: 2 }).connect(Tone.buses.sfx);
const coin = new Tone.Sampler({ urls: { C5: Tone.sao("a bright arcade coin chime, short", { seconds: 1 }) } }).connect(Tone.buses.sfx);
-const marimba = new Tone.Sampler({ urls: Tone.tokensynth("a soft wooden marimba, felt mallet, warm", ["C3", "C4", "C5"], { seconds: 2 }), volume: -10 }).connect(Tone.buses.music);
+// a recorded marimba (`raea sounds get vcsl/marimba`: CC0, the notes VCSL sampled, a fourth or a fifth apart)
+const marimba = new Tone.Sampler({
+ urls: Object.fromEntries(["F3", "C4", "G4", "B4", "F5"].map((n) => [n, staticFile(`sounds/vcsl-marimba/${n}.wav`)])),
+ release: 0.4,
+ volume: -10,
+}).connect(new Tone.Reverb({ decay: 1.2, wet: 0.15 }).connect(Tone.buses.music));
// a loop that wants to come round: a question (bars 1-2) and its answer (bars 3-4), rhythm before pitch
const tune = new Tone.Part((t, n) => marimba.triggerAttackRelease(n.note, "8n", t, n.vel), [
{ time: "0:0", note: "C4", vel: 0.8 }, { time: "0:0:2", note: "E4", vel: 0.5 }, { time: "0:1:2", note: "G4", vel: 0.6 }, { time: "0:3", note: "A4", vel: 0.7 },
@@ -335,4 +346,6 @@ registerRoot(() => <Composition id="game" component={Game} width={1920} height={
```
`raea/music` is the shorthand for notes on named instruments (`new Part("bass", [...])`, `<Music>`). It plays
-through the same Tone layer, so the two mix.
+through the same Tone layer, so the two mix. Its named instruments are Tone synth presets (`pad` is a PolySynth of
+fat saws, `kick` a MembraneSynth), good for a sketch or a test, not a score: write the score on sampled instruments,
+as above. It also reads and writes MIDI files (`parseMidi`, `toMidi`; `motion/sources`).
diff --git a/sdk/guides/craft/motion/parts.md b/sdk/guides/craft/motion/parts.md
index 53ee3df3..7f6d5bfd 100644
--- a/sdk/guides/craft/motion/parts.md
+++ b/sdk/guides/craft/motion/parts.md
@@ -44,8 +44,8 @@ registerRoot(() => <Composition id="reviews-reel" component={Piece} width={1080}
## Footage with no voice: cue on the beats
-A screen recording or b-roll has no words to cue on, so it's cut on its music bed. The host cuts the shots on the bed's
-beats and gives `BEATS` (each beat's frame in the cut) and `SHOTS` (where each shot looks). Pass `<Ad beats={BEATS}>`,
+A screen recording or b-roll has no words to cue on, so it's cut on its music: the person's own track (the host's
+`bed`), never a pad made to fill the silence. The host cuts the shots on the track's beats and gives `BEATS` (each beat's frame in the cut) and `SHOTS` (where each shot looks). Pass `<Ad beats={BEATS}>`,
and cue each part by beat:
- `beat`: the beat it lands on, counted from 0. A part on a shot's first beat lands on its cut.
@@ -100,4 +100,4 @@ line has one to three.
- **Captions are always on.** They move under a card, hide under a hook, a strike or the ask, and go big at the top when the band is empty. Leave some beats empty so the face and the captions carry them.
- **The thesis gets Phrases.** The thesis is the first line where the speaker says what the brief's `believe:` line means (the believe line finds it; its own wording never goes on screen): the line the piece is about, often the turn after the numbers, and often said as "not this, but that" ("so the fix isn't / another *discount* / it's a *fast reply*"). It reads phrase by phrase: one `<Phrases>` over it, a phrase per breath, the word that carries each phrase in the accent. Captions alone show it three words at a time, lit word by word, which reads as a caption, not a statement.
- **About one part every three to five seconds.** A beat with nothing to show stays empty.
-- The sound is done for you. Each part brings its own hit, and `<Bed>` plus `<Mix lufs={-14} />` finish it. Don't add more foley.
+- The sound is done for you. Each part brings its own hit, and `<Mix lufs={-14} />` finishes it, with `<Bed>` when the person gave a track (their own track, or none: never a pad made to fill it). Don't add more foley.
diff --git a/sdk/guides/craft/motion/sound.md b/sdk/guides/craft/motion/sound.md
index 4dbe98d7..2a6fd6fb 100644
--- a/sdk/guides/craft/motion/sound.md
+++ b/sdk/guides/craft/motion/sound.md
@@ -49,9 +49,11 @@
| foley hits, whooshes, pops | -16 to -22 dB | -1 to -6 dB |
These are starting points; listen and decide.
-- `raea sao "PROMPT" --seconds 1.2 -o media/sfx/hit.wav` makes a sound now, to check it before it goes in; the edit's
- `sao("PROMPT", { seconds: 1.2 })` then plays that one rather than making another. `--seed 2` makes another take of
- the same prompt; play that file by its path (`staticFile("sfx/hit-2.wav")`), since `sao()` has no seed.
+- `raea sao "PROMPT" --seconds 1.2 --dir EDIT_DIR -o EDIT_DIR/media/sfx/hit.wav` makes a sound now, to check it
+ before it goes in, and keeps it in the edit's asset store (`--dir` is the edit's folder; without it, the folder you
+ run it from), so the edit's `sao("PROMPT", { seconds: 1.2 })` then plays that one rather than making another.
+ `--seed 2` makes another take of the same prompt; play that file by its path (`staticFile("sfx/hit-2.wav")`), since
+ `sao()` has no seed.
## Why
@@ -132,8 +134,11 @@ Tone.getTransport().bpm.value = (4 * 4 * 60 * 30) / END_CARD; // about 114 bpm
Tone.buses.music.duck(Tone.buses.voice, { amount: -12 });
Tone.buses.music.volume.value = -21;
Tone.buses.music.volume.rampTo(-12, 0.33, END_CARD / 30);
+// `raea sounds get salamander/piano` printed its roots a minor third apart (D#2 is the file Ds2.mp3); these cover
+// F2 to G5, what the cue plays
+const ROOTS = ["D#2", "F#2", "A2", "C3", "D#3", "F#3", "A3", "C4", "D#4", "F#4", "A4", "C5", "D#5", "F#5"];
const piano = new Tone.Sampler({
- urls: { C3: staticFile("sounds/salamander-piano/C3.mp3"), C4: staticFile("sounds/salamander-piano/C4.mp3"), C5: staticFile("sounds/salamander-piano/C5.mp3") },
+ urls: Object.fromEntries(ROOTS.map((n) => [n, staticFile(`sounds/salamander-piano/${n.replace("#", "s")}.mp3`)])),
release: 1,
}).connect(new Tone.Reverb({ decay: 1.4, wet: 0.2 }).connect(Tone.buses.music));
const CHORDS = [["A2", "E3", "C4"], ["F2", "C3", "A3"], ["C3", "G3", "E4"], ["G2", "D3", "B3"]];
diff --git a/sdk/guides/craft/motion/sources.md b/sdk/guides/craft/motion/sources.md
index e4934b96..0ccfae13 100644
--- a/sdk/guides/craft/motion/sources.md
+++ b/sdk/guides/craft/motion/sources.md
@@ -14,9 +14,10 @@
| a melody or harmony to arrange from the public domain | Mutopia, OpenScore |
- Use what raea's licence rule takes: CC0 and public domain, CC-BY (credited), MIT and Apache, and free licences that
- allow a commercial film (Sonniss's, Pixabay's). Never a non-commercial (NC), no-derivatives (ND), Sampling+,
- "personal use" or share-alike (SA) source: share-alike terms can reach the film made with it. A pack's licence is
- per pack and sometimes per sound; read its readme and keep it beside the files.
+ allow a commercial film (Sonniss's, Pixabay's, Mixkit's for its effects). Never a non-commercial (NC),
+ no-derivatives (ND), Sampling+, "personal use", share-alike (SA) or GPL source: share-alike and GPL terms can reach
+ the film or game made with it. A pack's licence is per pack and sometimes per sound; read its readme and keep it
+ beside the files.
- Credit each CC-BY source where the piece is shown (its description or end credits). The line is in the
`LICENCE.txt` that `raea sounds get` writes, or in the pack's readme.
- Keep a pack fetched by hand in one folder on the Mac, outside any project (`~/Music/raea-sounds/PACK/` with its
@@ -38,9 +39,9 @@ raea setup-audio # installs what's missing: TokenSynth, then SAO
raea setup-audio sao # one of them
```
-- **What it fetches.** Each model has a script (`tools/sao/setup.sh` and `tools/tokensynth/setup.sh` in a checkout,
- `share/raea/tools/` beside an installed raea) that installs into `~/.cache/raea-sao` and `~/.cache/raea-tokensynth`
- (RAEA_SAO and RAEA_TOKENSYNTH move them):
+- **What it fetches.** Each model has a script (`TOOLS/sao/setup.sh` and `TOOLS/tokensynth/setup.sh`; TOOLS is
+ `tools/` in a raea checkout, `share/raea/tools/` beside an installed raea) that installs into `~/.cache/raea-sao`
+ and `~/.cache/raea-tokensynth` (RAEA_SAO and RAEA_TOKENSYNTH move them):
- SAO, about 2 GB: Stable Audio Open Small's Core ML conversion (the DiT, the VAE decoder and the number embedder)
from a Hugging Face mirror at a pinned revision, each file checked against its SHA-256; t5-base's tokenizer; a
small Python environment; and raea's own fp32 T5 encoder, converted once in a throwaway environment whose torch
@@ -48,17 +49,32 @@ raea setup-audio sao # one of them
- TokenSynth, about 6 GB: its code from GitHub, a Python environment with torch (about 1.1 GB), the model and its
unconditional twin (713 MB each), DAC (307 MB) and CLAP (2.35 GB) from Hugging Face, the text encoders CLAP
fetches, then a converted fp16 runtime and Core ML models.
-- **What it needs.** A network connection, `uv` (Astral's Python manager) on the PATH, and `git` for TokenSynth.
- Neither script installs them. Install uv first (`curl -LsSf https://astral.sh/uv/install.sh | sh`, or Homebrew).
+- **What it needs.** A network connection, `uv` (Astral's Python manager) and, for TokenSynth, `git`, which the
+ scripts take from the PATH. On a Mac without them, `TOOLS/ensure.sh` gets raea's pinned builds (uv 0.12.24 and git
+ 2.56.0, under `~/.cache/raea-tools`, each download checked against its SHA-256) and prints the program's path. Put
+ both on the PATH for the setup:
+
+ ```sh
+ T=$(dirname "$(realpath "$(command -v raea)")")/../share/raea/tools # or tools/ in a raea checkout
+ PATH="$(dirname "$(bash "$T/ensure.sh" uv)"):$(dirname "$(bash "$T/ensure.sh" git)"):$PATH" raea setup-audio
+ ```
+
- **The licences.** TokenSynth's code and weights are MIT. Stable Audio Open Small is under Stability AI's Community
- License, which isn't an open licence: it's free to use, commercially too, for a person or organisation with under
- USD 1 million in annual revenue (above that, Stability's enterprise licence), Stability asks commercial users to
- register (stability.ai/license), and what it makes belongs to the person. Setup doesn't show this licence, so say
- it to the person before the first SAO sound goes into a commercial piece of theirs.
+ License (stability.ai/community-license-agreement), which isn't an open licence. As between the person and
+ Stability, the person owns the sounds it makes, as far as the law allows; the sounds may not be used to create or
+ improve another generative AI model, and Stability's acceptable use policy applies to them. The licence's other
+ duties fall first on raea, which hands the model on: a copy of the agreement and a notice file beside the model,
+ "Powered by Stability AI" where raea documents it, and registering raea's own commercial use. raea hasn't settled
+ those yet, nor what is left for the person (docs/sound.feature SN2), so don't tell the person what the licence asks
+ of them: before the first SAO sound goes into a commercial piece of theirs, say the model is under that licence,
+ give them the link and let them decide, or take that sound from a recorded pack instead.
- **When it fails.** The error names the script and the folder; run that script with `sh` to see its own output.
- `exit status: 127` is uv or git missing. `75` is another setup running in the same folder: wait for it, or remove
- the folder's `.setup-lock` once nothing is running. RAEA_OFFLINE refuses the download, and RAEA_AUDIO_AUTOSETUP=0
- turns the self-install off, so a render names the command instead. Running setup-audio again picks up where a
+ `exit status: 127` is uv not found. On a Mac without the Command Line Tools, `/usr/bin/git` is only a stub: it
+ opens an install dialog, and the setup stops with status 1 and `xcrun: error: invalid active developer path`. Use
+ the git `ensure.sh` installs (above). `75` is another setup running in the same folder: wait for it, or remove the
+ folder's `.setup-lock` once nothing is running. RAEA_OFFLINE refuses the download. RAEA_AUDIO_AUTOSETUP=0 turns
+ the self-install off, so a render names the command instead; it also stops `raea setup-audio` and `ensure.sh`, so
+ with it set, run the model's script yourself (`sh TOOLS/sao/setup.sh`). Running setup-audio again picks up where a
broken install stopped: finished files are kept.
- A render that meets a model not yet installed waits while it installs (minutes, once). Run setup-audio before the
first render, not inside one.
@@ -74,43 +90,69 @@ that plays them.
|---|---|---|
| `salamander` | CC-BY 3.0 (credit) | a grand piano, sampled every minor third |
| `fluid` | CC-BY 3.0 (credit) | the 128 General MIDI instruments of the FluidR3 font, every note A0 to C8; no drum kit |
-| `tonejs-instruments` | public domain and CC-BY, per instrument (its `LICENCE.txt` says) | 20: cello, violin, contrabass, French horn, trumpet, trombone, tuba, saxophone, flute, clarinet, bassoon, harp, guitars, organ, harmonium, piano, xylophone |
+| `tonejs-instruments` | CC-BY 3.0 (credit) | 20, recorded from VSCO 2, the University of Iowa, Karoryfer and Freesound: cello, violin, contrabass, French horn, trumpet, trombone, tuba, saxophone, flute, clarinet, bassoon, harp, three guitars (acoustic, electric, nylon), electric bass, organ, harmonium, piano, xylophone |
| `vcsl` | CC0 | 104 from the Versilian Community Sample Library: pianos, harpsichords, harps, organs, recorders, marimba, vibraphone, glockenspiel, kalimbas; bass drums, snares, toms, hi-hat, cymbals, claps, shakers, congas, timpani; a siren, a ratchet, an anvil and other effects |
The ids are exact: `raea sounds kick` lists `vcsl/bass-drum-1`, and `vcsl/bass-drum` isn't one. A pitched
-instrument comes as one take a note, at its middle dynamic; a drum or a hit as its first 12 takes (`--all` for
-every one). VCSL names a hit's dynamic and round robin in the file (`_v2` soft to `_v7` hard, `_rr1`, `_rr2`), so a
-part can pick a softer take for a softer note.
+instrument comes as one take a note, at its middle dynamic: with no `--notes`, roots at least a minor third apart from
+C1 to C7, the ones a Sampler needs, named as notes with sharps written `s` (`Ds3.mp3` is D#3). A drum or a hit comes
+as its first 12 takes (`--all` for every one). VCSL names a hit's dynamic and round robin in the file (a higher `_vN`
+is a harder hit, `_rr1`, `_rr2` the round robins), so a part can pick a softer take for a softer note.
## Packs to fetch by hand
-Each of these is a download from its own page into `~/Music/raea-sounds/PACK/`, then the files a piece uses copied
-into its `media/`.
+Each goes into its own folder in `~/Music/raea-sounds/`, with its licence file beside it; the files a piece uses are
+then copied into its `media/`. These have a stable address, so one command fetches each (`git` is the one
+`TOOLS/ensure.sh git` prints on a Mac without the Command Line Tools):
+
+```sh
+P=~/Music/raea-sounds
+# VSCO 2 CE, the orchestra with its SFZ maps: 3.2 GB, CC0 (LICENSE inside)
+git clone --depth 1 --branch SFZ https://github.com/sgossner/VSCO-2-CE "$P/vsco2-ce"
+# VCSL, every dynamic and round robin, with SFZ maps: 6.2 GB, CC0 (the sfz branch has no LICENSE, so it's fetched beside)
+git clone --depth 1 --branch sfz https://github.com/sgossner/VCSL "$P/vcsl" && curl -fsSL -o "$P/vcsl/LICENSE" https://raw.githubusercontent.com/sgossner/VCSL/master/LICENSE
+# Salamander Grand Piano V3, 16 velocities: 0.75 GB, CC-BY 3.0 (LICENSE inside)
+git clone --depth 1 https://github.com/sfzinstruments/SalamanderGrandPiano "$P/salamander-v3"
+# Groove MIDI, the MIDI only: 3.1 MB, CC-BY 4.0, checked against the SHA-256 its page gives
+mkdir -p "$P/groove" && curl -fL -o "$P/groove/groove-midionly.zip" https://storage.googleapis.com/magentadata/datasets/groove/groove-v1.0.0-midionly.zip \
+ && echo "651cbc524ffb891be1a3e46d89dc82a1cecb09a57c748c7b45b844c4841dcc1e $P/groove/groove-midionly.zip" | shasum -a 256 -c \
+ && unzip -q "$P/groove/groove-midionly.zip" -d "$P/groove" \
+ && echo "Groove MIDI Dataset (Google Magenta), CC-BY 4.0: magenta.tensorflow.org/datasets/groove" > "$P/groove/LICENCE.txt"
+# MuseScore General, a General MIDI bank with drum kits: 40 MB as SF3, MIT, with its licence and notices
+mkdir -p "$P/musescore-general" && curl -fL --output-dir "$P/musescore-general" \
+ -O https://ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/MuseScore_General.sf3 \
+ -O https://ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/MuseScore_General_License.md
+```
+
+The rest are picked a pack or a sound at a time on their own pages. `raea sounds get` reaching all of them is filed
+as docs/sound.feature SN4.
| source | licence | where | what it has |
|---|---|---|---|
-| VSCO 2 Community Edition | CC0 | github.com/sgossner/VSCO-2-CE (releases) | an orchestra: solo and section strings with articulations, woodwinds, brass, percussion, keys; WAV with SFZ maps, about 3 GB |
-| VCSL, the whole library | CC0 | github.com/sgossner/VCSL | every dynamic and round robin of what `raea sounds` gives one take of, with SFZ maps |
+| VSCO 2 Community Edition | CC0 | github.com/sgossner/VSCO-2-CE (its `SFZ` branch has the maps) | an orchestra: solo and section strings with articulations, woodwinds, brass, percussion, keys; WAV with SFZ maps |
+| VCSL, the whole library | CC0 | github.com/sgossner/VCSL (its `sfz` branch has the maps) | every dynamic and round robin of what `raea sounds` gives one take of |
| Salamander Grand Piano V3 | CC-BY 3.0 | github.com/sfzinstruments/SalamanderGrandPiano | the same piano at 16 velocities, 48 kHz, SFZ |
| sfzinstruments' lists | per pack, on the list | sfzinstruments.github.io (pianos, strings, drums) | take the CC0, public domain and CC-BY ones: Karoryfer's free packs (Big Rusty, Swirly and Unruly drums, Frankensnare, Meatbass, Bigcat Cello; mostly CC0, older ones CC-BY 3.0: read each readme), SM Drums (public domain), Splendid Grand Piano (public domain), DrumGizmo's DRS and Muldjord kits and Naked Drums (CC-BY 4.0) |
| University of Iowa Musical Instrument Samples | "may be downloaded and used for any projects, without restrictions" | theremin.music.uiowa.edu/mis.html | single notes of orchestral instruments at several dynamics, recorded dry: give them a room's reverb |
-| FreePats | per bank: CC0, CC-BY, or GPL with an exception for music made with it | freepats.zenvoid.org | General MIDI families, world instruments, percussion; SFZ and SF2 |
-| MuseScore General | MIT (keep its notice) | ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/ | a General MIDI bank with drum kits, SF2 (206 MB) or SF3, for playing a MIDI file as it is |
+| FreePats | per bank: CC0, CC-BY or GPL; take the CC0 and CC-BY banks only | freepats.zenvoid.org | General MIDI families, world instruments, percussion; SFZ and SF2 |
+| MuseScore General | MIT (keep its notices) | ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/ | a General MIDI bank with drum kits, SF2 (216 MB) or SF3 (40 MB), for playing a MIDI file as it is |
| Kenney's audio packs | CC0 | kenney.nl/assets/category:Audio | Impact Sounds, Interface Sounds, UI Audio, Sci-fi Sounds, RPG Audio, Casino Audio, Digital Audio, Music Jingles, voice-over packs; mostly Ogg |
| OpenGameArt | per asset: take CC0, CC-BY and OGA-BY | opengameart.org | game effects and loops, such as "512 Sound Effects (8-bit style)" (CC0) |
| Freesound | per sound: take CC0 and CC-BY only | freesound.org (a free account to download) | field recordings, foley and effects of every kind |
| Sonniss #GameAudioGDC bundles | royalty-free for commercial use, no credit; never passed on as sounds (a library, a pack, a template) and never used to train a model | sonniss.com/gameaudiogdc | over 200 GB of professional foley, impacts, ambiences and field recordings, a bundle a year |
| Pixabay sound effects | Pixabay's Content License: free, commercial use, no credit; never sold or shared on their own | pixabay.com/sound-effects | effects and ambiences |
-| Groove MIDI Dataset | CC-BY 4.0 (credit Google Magenta) | magenta.tensorflow.org/datasets/groove | 1,150 MIDI performances by 10 drummers: 13.6 hours of beats and fills in 18 styles, 3 MB |
+| Mixkit sound effects | Mixkit's Sound Effects Free License: free, commercial use (games and broadcast too), no credit; never passed on on their own (as stock, in a tool or a template) and never registered with a rights service such as Content ID | mixkit.co/free-sound-effects | effects, whooshes, interface sounds, ambiences |
+| Groove MIDI Dataset | CC-BY 4.0 (credit Google Magenta) | magenta.tensorflow.org/datasets/groove | 1,150 MIDI performances by 10 drummers: 13.6 hours of beats and fills in 18 styles |
| Mutopia Project | per piece: public domain or CC-BY (skip the BY-SA ones) | mutopiaproject.org | 2,100 classical pieces as MIDI and LilyPond |
| OpenScore Lieder | CC0 | github.com/OpenScore/Lieder | 1,350 art songs as MuseScore scores (MuseScore exports MIDI) |
Not these, whatever they sound like: Sonatina Symphonic Orchestra and the Virtual Playing Orchestra (Sampling+ and
mixed terms: no use in an ad), the Philharmonia's samples (terms unclear), Spitfire LABS (no samples to take), the
-MusyngKite and FatBoy fonts beside FluidR3 (no licence), Tone.js's own drum kits (CC BY-NC-SA), the BBC's sound
-effects (personal and research use), Zapsplat and Mixkit (their own terms), Salamander Drumkit and other CC-BY-SA
-kits, and Lakh MIDI (copyrighted songs). Freesound's API is free only for non-commercial use, so raea doesn't search
-Freesound for the person: they download its sounds themselves.
+MusyngKite and FatBoy fonts beside FluidR3 (CC BY-SA 3.0: share-alike), FreePats' GPL banks (copyleft), Tone.js's
+own drum kits (CC BY-NC-SA), the BBC's sound effects (personal and research use), Zapsplat (its own terms), Mixkit's
+stock music (not in games or broadcasts, and no remixing), Salamander Drumkit and other CC-BY-SA kits, and Lakh MIDI
+(copyrighted songs). Freesound's API is free only for non-commercial use, so raea doesn't search Freesound for the
+person: they download its sounds themselves.
## Loading a pack in a composition
@@ -129,30 +171,63 @@ Freesound for the person: they download its sounds themselves.
const cello = (note: string, dur: string, t: number, vel: number) => (vel < 0.6 ? soft : loud).triggerAttackRelease(note, dur, t, vel);
```
-- **A MIDI file** (a Groove MIDI performance, a Mutopia piece): a composition can't read a `.mid` yet. Turn it into
- a JSON of notes, then play the notes on Samplers and Players:
+- **A MIDI file** (a Groove MIDI performance, a Mutopia piece): raea/music reads one (`parseMidi`, in
+ sdk/audio/src/midi.ts), and the raea app imports a `.mid` into a listen item's Part, but a composition can't import
+ a `.mid` yet (docs/sound.feature SN6). Turn it into JSON in raea/music's `MidiFile` shape (`tracks[].notes[]` with
+ `midi`, `time` and `duration` in seconds, and `velocity` 0 to 1), each note from its note-on to its note-off, one
+ track per channel; a composition imports that, and its code stays the same when a `.mid` can be imported:
```sh
- uv run --with mido python3 -I -c '
+ uv run -q --no-project --with mido python3 -I - media/grooves/funk-92.mid media/grooves/funk-92.json <<'PY'
import json, sys, mido
- t, notes = 0.0, []
- for m in mido.MidiFile(sys.argv[1]):
- t += m.time
- if m.type == "note_on" and m.velocity:
- notes.append({"time": round(t, 4), "midi": m.note, "vel": round(m.velocity / 127, 3)})
- json.dump(notes, open(sys.argv[2], "w"))
- ' media/grooves/funk-92.mid media/grooves/funk-92.json
+ f = mido.MidiFile(sys.argv[1])
+ tempo, ticks, secs, held, tracks, tempos, sigs = 500000, 0, 0.0, {}, {}, [], []
+ def end(ch, note, at, t, v): # one note, from its note-on to now, as raea/music's MidiNote
+ tracks.setdefault(ch, []).append({"midi": note, "time": round(at, 4), "duration": round(secs - at, 4), "velocity": round(v / 127, 3), "ticks": t, "durationTicks": ticks - t})
+ for m in mido.merge_tracks(f.tracks):
+ ticks += m.time
+ secs += mido.tick2second(m.time, f.ticks_per_beat, tempo)
+ if m.type == "set_tempo":
+ tempo = m.tempo
+ tempos.append({"ticks": ticks, "bpm": round(mido.tempo2bpm(m.tempo), 3)})
+ elif m.type == "time_signature":
+ sigs.append({"ticks": ticks, "timeSignature": [m.numerator, m.denominator]})
+ elif m.type == "note_on" and m.velocity:
+ held.setdefault((m.channel, m.note), []).append((secs, ticks, m.velocity))
+ elif m.type in ("note_on", "note_off") and held.get((m.channel, m.note)):
+ end(m.channel, m.note, *held[(m.channel, m.note)].pop(0))
+ for (ch, note), left in held.items(): # still sounding when the file ends
+ for n in left:
+ end(ch, note, *n)
+ out = [{"name": f"channel {ch + 1}", "channel": ch, "notes": sorted(ns, key=lambda n: n["time"])} for ch, ns in sorted(tracks.items())]
+ json.dump({"header": {"ppq": f.ticks_per_beat, "tempos": tempos, "timeSignatures": sigs, "name": ""}, "tracks": out, "duration": round(secs, 4)}, open(sys.argv[2], "w"))
+ PY
```
+ A drum track plays on a kit of Players by note number. Groove MIDI was recorded on a Roland kit, whose map differs
+ from General MIDI's: its hi-hat edge hits are 22 (closed) and 26 (open), notes General MIDI doesn't have, so a
+ General MIDI map drops many of its hi-hats:
+
```tsx
- import groove from "./media/grooves/funk-92.json"; // [{ time, midi, vel }]: seconds, at the drummer's 92 bpm
- // General MIDI drum notes: 36 kick, 38 and 40 snare, 42 and 44 closed hi-hat, 46 open (the dataset lists the rest)
- const KIT: Record<number, string> = { 36: "kick", 38: "snare", 40: "snare", 42: "hat", 44: "hat", 46: "open" };
+ import groove from "./media/grooves/funk-92.json"; // seconds, at the drummer's 92 bpm
+ // Roland's drum map (the dataset's page lists the toms and cymbals): 36 kick; 37, 38 and 40 snare (cross-stick,
+ // head, rim); 42, 22 and 44 closed hi-hat (bow, edge, pedal); 46 and 26 open hi-hat (bow, edge)
+ const KIT: Record<number, string> = { 36: "kick", 37: "snare", 38: "snare", 40: "snare", 42: "hat", 22: "hat", 44: "hat", 46: "open", 26: "open" };
+ const kit = new Tone.Players({
+ kick: staticFile("sounds/vcsl-bass-drum-1/BDrumNew_hit_v5_rr1_Sum.wav"),
+ snare: staticFile("sounds/vcsl-snare-drum-modern-1/Snare2_HitSN_v5_rr1_Mid.wav"),
+ hat: staticFile("sounds/vcsl-hi-hat-cymbal/HiHat_HitC_v3_rr1_Mid.wav"),
+ ghost: staticFile("sounds/vcsl-hi-hat-cymbal/HiHat_HitC_v1_rr1_Mid.wav"),
+ open: staticFile("sounds/vcsl-hi-hat-cymbal/HiHat_HitO_rr1_Mid.wav"),
+ }).connect(Tone.buses.music);
const stretch = 92 / Tone.getTransport().bpm.value; // the drummer's tempo onto the cue's
- new Tone.Part((t, n) => kit.player(KIT[n.midi]).start(t), groove.filter((n) => n.midi in KIT).map((n) => ({ ...n, time: n.time * stretch }))).start("4m");
+ const hits = groove.tracks.flatMap((track) => track.notes).filter((n) => n.midi in KIT);
+ // a soft closed hat plays the soft take
+ new Tone.Part((t, n) => kit.player(KIT[n.midi] === "hat" && n.velocity < 0.45 ? "ghost" : KIT[n.midi]).start(t), hits.map((n) => ({ ...n, time: n.time * stretch }))).start("4m");
```
- A pitched track's notes go to a Sampler as `Tone.Frequency(n.midi, "midi").toNote()`.
+ A pitched track (a Mutopia piece) plays on a Sampler, one Part a track, each note at its own length:
+ `piano.triggerAttackRelease(Tone.Frequency(n.midi, "midi").toNote(), n.duration * stretch, t, n.velocity)`.
- **A SoundFont** (`.sf2`, `.sf3`): raea can't play one. To hear a MIDI file the person hands over as it is, render
- it with FluidSynth (`brew install fluid-synth`, then `fluidsynth -ni -F song.wav -r 48000 MuseScore_General.sf2
+ it with FluidSynth (`brew install fluid-synth`, then `fluidsynth -ni -F song.wav -r 48000 MuseScore_General.sf3
song.mid`) and play the WAV as `<Audio bus="music">`; to write parts, use the sampled libraries instead.