This project is a Node.js-based tool that allows for experimental audio generation, by time-stretches collections of tracks to the same duration (taking the longest as basis), and layers them together.
Inspired by Every Recording of Gymnopédie 1.
- Download top N search results from YouTube
- Use self-selected audio files as input
- Time-stretch audio files to match the longest duration
- Layer multiple audio files into a single output
- Node.js
- ffmpeg
- yt-dlp
- Rubberband (MacOS ARM version included in
./lib/rubberband/)
YouTube frequently breaks older yt-dlp builds. If downloads fail with messages like "Signature extraction failed", HTTP 403, or "Only images are available", update yt-dlp (macOS: brew upgrade yt-dlp).
If YouTube is rate-limiting or blocking your IP, you may need cookies. This tool supports:
YTDLP_COOKIES_FROM_BROWSER=chrome(orfirefox, etc.)YTDLP_COOKIES=/path/to/cookies.txt
- Clone this repository
- Install dependencies:
pnpm i - Ensure ffmpeg and yt-dlp are installed and accessible in your PATH
Run the main script with the following command:
node main.js [options] "search query"
--downloador-d: Download songs from YT first (default: false)--numberor-n: Number of songs to download (default: 5)--excludeor-e: Comma-separated list of keywords to exclude from search (e.gguitar,drums)
node main.js -d -n 3 -e "guitar,🎸" "Clair de Lune"
Manually populate the output/[search_query]/songs/ directory with audio files, and run node main.js "search query". This skips the download step.
This repo includes a tiny local UI (Vite + React + Tailwind + shadcn/ui).
- Dev:
pnpm devthen openhttp://localhost:5173 - Prod build:
pnpm buildthenpnpm start(serves UI + API onhttp://localhost:5174)
The processed files will be saved in the output/ directory, organized by search query:
output/
└── [search_query]/
├── `songs/`
├── `stretched_songs/`
└── `layered_[sanitized_search_query].wav`
main.js: Main entry point, orchestrates the processsongdl.js: Handles downloading cover versions from YouTubetimestretch.js: Time-stretches audio files to match the longest durationlayerer.js: Layers the time-stretched audio files into a single output
This tool does not promise a consonant result. To improve output quality, you can try the following:
- check the downloaded songs for artifacts at the beginning and end of the file (e.g applause, vocals, etc.). remove these songs.
- check the length of the downloaded songs. remove outliers (e.g much shorter or longer)
Once you have a good set of songs, you can run the tool without the --download option to skip the download step.