Skip to content

Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.

music: Daylight, a lo-fi electronic example (D major I-vi-IV-V, 96 bpm): 30 s seamless loop + arranged form; refit can drop the stretch section

Alex Greenshpun210c71c830fc
diff --git a/skills/anidoodle/engine/src/canvas-core/music/index.ts b/skills/anidoodle/engine/src/canvas-core/music/index.ts
index f9bb6e4..688f30c 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/index.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/index.ts
@@ -12,9 +12,12 @@ export * from "./lofiElectronic";
export * as instruments from "./instruments";
import { nocturne, pianoPhrase8 } from "./pieces/nocturne";
import { launchLofi, launchLofi2, launchLofi3 } from "./pieces/launch";
+import { lofiDaylight, lofiDaylightLoop } from "./pieces/lofi";
+export { lofiDaylightSpec, lofiDaylightLoopSpec, DAYLIGHT_PROGRESSION } from "./pieces/lofi";
+export { launchLofi3Spec, LAUNCH_PROGRESSION } from "./pieces/launch";
import { musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic } from "./pieces/samplers";
import { marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm } from "./pieces/families";
import { ghostFixture } from "./pieces/fixtures";
-export { launchLofi, launchLofi2, launchLofi3, nocturne, pianoPhrase8, musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic, marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm, ghostFixture };
+export { lofiDaylight, lofiDaylightLoop, launchLofi, launchLofi2, launchLofi3, nocturne, pianoPhrase8, musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic, marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm, ghostFixture };
/** Named pieces a film (or the tool) can ask for. ghostFixture is a test fixture, never a score. */
-export const PIECES = { launchLofi, launchLofi2, launchLofi3, nocturne, pianoPhrase8, musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic, marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm, ghostFixture };
+export const PIECES = { lofiDaylight, lofiDaylightLoop, launchLofi, launchLofi2, launchLofi3, nocturne, pianoPhrase8, musicBoxJoy, minorPianoMelancholy, cinematicAwe, chiptunePlayful, lofiNostalgic, marimbaCurious, harpTender, guitarWistful, celestaWonder, bellsHopeful, driveElectronic, folkCalm, ghostFixture };
diff --git a/skills/anidoodle/engine/src/canvas-core/music/lofiElectronic.ts b/skills/anidoodle/engine/src/canvas-core/music/lofiElectronic.ts
index f028f8f..ec69557 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/lofiElectronic.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/lofiElectronic.ts
@@ -117,8 +117,8 @@ export const refitLofi = (spec: LofiSpec, seconds: number): LofiSpec => {
if (si < 0 || want <= 0) return spec;
const from = lofiLayout(secs)[si].from, b0 = secs[si].bars;
let best: { spec: LofiSpec; cost: number } | null = null;
- for (let k = -Math.floor((b0 - 1) / len); k <= 64; k++) {
- const bars = b0 + k * len; if (bars < 1) continue;
+ for (let k = -Math.floor(b0 / len); k <= 64; k++) {
+ const bars = b0 + k * len; // 0 = the section drops out for a short film
const land = typeof spec.land === "number" && spec.land >= from + b0 ? spec.land + k * len : spec.land;
const s2: LofiSpec = { ...spec, land, sections: secs.map((s, i) => (i === si ? { ...s, bars } : s)) };
const p = lofiElectronic({ ...s2 }), t = perform(p, spec.bpm, { expressive: true }).lastOnset, tempo = spec.bpm * (t / want);
diff --git a/skills/anidoodle/engine/src/canvas-core/music/pieces/lofi.ts b/skills/anidoodle/engine/src/canvas-core/music/pieces/lofi.ts
new file mode 100644
index 0000000..caf6ceb
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/music/pieces/lofi.ts
@@ -0,0 +1,32 @@
+// LO-FI ELECTRONIC EXAMPLES, written on the style API (lofiElectronic.ts). "Daylight": D major, 96
+// bpm, the I-vi-IV-V loop Dmaj9 Bm9 Gmaj9 A13 with rootless pads that move by step
+// (F#-A-C#-E, F#-A-C#-D, F#-A-B-D, G-B-C#-F#). The hook asks on the A13 (ends off the tonic) and the
+// loop answers on Dmaj9; its second pass lifts the G and A bars. No ePiano, no vinyl: clean.
+// lofiDaylightLoop 12 bars, 30 s, seamless: render with renderLoop (tools/music.mjs picks it).
+// lofiDaylight the arranged form: intro (IV V into home), hook, hook + sparkle, half-time,
+// breakdown, the drop landing on Dmaj9, outro. refit() stretches it for a film.
+import type { Piece } from "../plan";
+import { lofiElectronic, type LofiChord, type LofiSpec } from "../lofiElectronic";
+
+export const DAYLIGHT_PROGRESSION: LofiChord[] = [
+ { name: "Dmaj9", pad: "[F#3 A3 C#4 E4]", root: "D2", walk: "A1", hook: "r:.5 F#4:.5 A4:.5 D5:1 C#5:.5 A4:1", sparkle: "r:1 A5:.5 C#6:.5 E6:2" },
+ { name: "Bm9", pad: "[F#3 A3 C#4 D4]", root: "B1", walk: "F#1", hook: "r:.5 F#4:.5 B4:.5 C#5:.5 D5:1 B4:1", sparkle: "r:1 F#5:.5 A5:.5 C#6:2" },
+ { name: "Gmaj9", pad: "[F#3 A3 B3 D4]", root: "G1", walk: "D2", hook: ["r:.5 D5:.5 E5:.5 F#5:1 E5:.5 D5:1", "r:.5 D5:.5 E5:.5 F#5:.5 A5:1 F#5:1"], sparkle: "r:1 F#6:.5 D6:.5 B5:2" },
+ { name: "A13", pad: "[G3 B3 C#4 F#4]", root: "A1", walk: "E2", hook: ["C#5:1.5 B4:.5 A4:1 r:1", "E5:1.5 C#5:.5 E5:1 r:1"], sparkle: "C#6:1 B5:1 A5:2" },
+];
+// levels: set by measuring the stems against LOFI_STEM_TARGETS (node tools/music.mjs stems lofiDaylightLoop)
+const LEVELS = { pad: -3, lead: 6, sparkle: 8, sub: -6, kick: 0.5, snare: 8, ghost: 4, hat: 20 };
+
+export const lofiDaylightLoopSpec = (): LofiSpec => ({
+ title: "Daylight (loop)", seed: 96, bpm: 96, key: "D", progression: DAYLIGHT_PROGRESSION, loop: true, tail: 3.5, mood: "joy", levels: LEVELS,
+ sections: [{ kind: "hook", bars: 4 }, { kind: "hook", bars: 4, sparkle: true }, { kind: "half", bars: 2, sparkle: true }, { kind: "hook", bars: 2 }],
+});
+export const lofiDaylightSpec = (): LofiSpec => ({
+ title: "Daylight", seed: 96, bpm: 96, key: "D", progression: DAYLIGHT_PROGRESSION, home: 0, mood: "joy", levels: LEVELS,
+ sections: [
+ { kind: "intro", bars: 2 }, { kind: "hook", bars: 4 }, { kind: "hook", bars: 4, sparkle: true, stretch: true }, { kind: "half", bars: 2, sparkle: true },
+ { kind: "breakdown", bars: 2 }, { kind: "drop", bars: 1 }, { kind: "outro", bars: 2 },
+ ],
+});
+export const lofiDaylightLoop = (): Piece => lofiElectronic(lofiDaylightLoopSpec());
+export const lofiDaylight = (): Piece => lofiElectronic(lofiDaylightSpec());