Add TTS vocal (140 BPM, dark smoky British female) as an audio track

vocal/make_vocal.py renders the line with Piper, pitched down and processed,
on a 140 BPM grid. build_track.py embeds it in the DAWproject as an unwarped
audio track (bars 129 and 185); --no-vocal opts out. README updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
valknarandClaude Sonnet 5.5 committed 2026-11-25 12:31:51 +01:00
1 parent fa33c7fd68
commit 2d1be6ffb0
6 files changed
+252 -10

No files matched your search

+25 -7
View File
@@ -9,7 +9,7 @@ A long, heavy, progressive **Schranz / industrial techno** track: a fat 808 kick
| Tempo | **150 BPM**, 4/4 | | Tempo | **150 BPM**, 4/4 |
| Key | **F minor** | | Key | **F minor** |
| Length | **320 bars = 8:32** (one bar = 1.6 s) | | Length | **320 bars = 8:32** (one bar = 1.6 s) |
| Tracks | 9 note tracks plus a master | | Tracks | 9 note tracks, 1 vocal audio track and a master |
| Notes | 16,838 in total | | Notes | 16,838 in total |
| Generator | `build_track.py`, Python 3 standard library only, deterministic | | Generator | `build_track.py`, Python 3 standard library only, deterministic |
@@ -26,12 +26,13 @@ This README documents the song structure, every pattern, the harmony, the file f
5. [Tracks and patterns](#tracks-and-patterns) 5. [Tracks and patterns](#tracks-and-patterns)
6. [Intensity map](#intensity-map) 6. [Intensity map](#intensity-map)
7. [Filter automation and sidechain](#filter-automation-and-sidechain) 7. [Filter automation and sidechain](#filter-automation-and-sidechain)
8. [Sound design guide](#sound-design-guide) 8. [Vocal](#vocal)
9. [File format details](#file-format-details) 9. [Sound design guide](#sound-design-guide)
10. [How the script is organised](#how-the-script-is-organised) 10. [File format details](#file-format-details)
11. [Customising the track](#customising-the-track) 11. [How the script is organised](#how-the-script-is-organised)
12. [Validation](#validation) 12. [Customising the track](#customising-the-track)
13. [Known limitations](#known-limitations) 13. [Validation](#validation)
14. [Known limitations](#known-limitations)
--- ---
@@ -42,6 +43,10 @@ exit-progressive-emulation/
├── README.md ← this file ├── README.md ← this file
├── build_track.py ← generator (stdlib only) ├── build_track.py ← generator (stdlib only)
├── exit-progressive-emulation.dawproject ← Bitwig/DAWproject file ├── exit-progressive-emulation.dawproject ← Bitwig/DAWproject file
├── vocal/
│ ├── make_vocal.py ← TTS generator (Piper + smoky processing, 140 BPM grid)
│ ├── when_you_change_140bpm.wav ← wet vocal (delay + reverb), 8 bars
│ └── when_you_change_140bpm_dry.wav ← dry processed vocal
└── midi/ └── midi/
├── full_arrangement.mid ← all 9 tracks, one file ├── full_arrangement.mid ← all 9 tracks, one file
├── 01_kick_808.mid ├── 01_kick_808.mid
@@ -69,6 +74,7 @@ exit-progressive-emulation/
python3 build_track.py # bare note tracks python3 build_track.py # bare note tracks
python3 build_track.py --devices # adds an instrument-device hint to each track python3 build_track.py --devices # adds an instrument-device hint to each track
python3 build_track.py --no-automation # notes only: no filter device, no automation python3 build_track.py --no-automation # notes only: no filter device, no automation
python3 build_track.py --no-vocal # leave out the vocal audio track
``` ```
The run prints the length and the note count per track. The seeds are fixed, so output is identical on every run. The run prints the length and the note count per track. The seeds are fixed, so output is identical on every run.
@@ -284,6 +290,18 @@ To upgrade to a real sidechain in Bitwig: delete the `auto_duck` lanes, put a **
--- ---
## Vocal
A dark, smoky British female voice speaks *"When you change the way you look at things, the things you look at change."* It is generated locally by `vocal/make_vocal.py` (Piper "Cori" voice, pitched down 2.5 semitones, saturated and low-passed, with a dotted-8th ping-pong delay and a dark plate reverb).
- The vocal is written on a **140 BPM** grid: phrase 1 starts on the bar 1 downbeat, phrase 2 exactly on bar 3, and the file is 8 bars (13.714 s) long.
- In the DAWproject it is an **audio track "Vocal"** (volume 0.75) with two clips, at **bar 129** (opening of the Breakdown) and **bar 185** (the final riser into Drop 2). Edit `VOCAL_BARS` in `build_track.py` to move them.
- The clips are **unwarped** (the clip content is in seconds), so the voice keeps its original speed and its own 140 BPM feel against the track's 150 BPM, instead of being stretched. The delay repeats are therefore *not* locked to the 150 BPM grid.
- The audio file is embedded in the `.dawproject` under `audio/`.
- Use `when_you_change_140bpm_dry.wav` if you would rather add your own effects in Bitwig.
---
## Sound design guide ## Sound design guide
The files contain notes and arrangement, not sounds. These are suggestions for turning them into the intended character: heavy, industrial, dark. The files contain notes and arrangement, not sounds. These are suggestions for turning them into the intended character: heavy, industrial, dark.
+41 -3
View File
@@ -7,14 +7,16 @@ Generates (stdlib only, deterministic):
midi/full_arrangement.mid all tracks, one SMF type 1 file midi/full_arrangement.mid all tracks, one SMF type 1 file
midi/NN_<track>.mid one full-length MIDI file per track midi/NN_<track>.mid one full-length MIDI file per track
Usage: python3 build_track.py [--devices] [--no-automation] Usage: python3 build_track.py [--devices] [--no-automation] [--no-vocal]
--devices add instrument-device hints to each track --devices add instrument-device hints to each track
--no-automation leave out the filter automation and kick-ducking (bare note tracks) --no-automation leave out the filter automation and kick-ducking (bare note tracks)
--no-vocal leave out the TTS vocal audio track
""" """
import os import os
import random import random
import struct import struct
import sys import sys
import wave
import zipfile import zipfile
from xml.sax.saxutils import quoteattr from xml.sax.saxutils import quoteattr
@@ -25,6 +27,13 @@ PPQ = 960
TOTAL_BARS = 320 TOTAL_BARS = 320
CHUNK = 8 # bars per arrangement clip CHUNK = 8 # bars per arrangement clip
# Vocal (TTS) audio clip, rendered at 140 BPM by vocal/make_vocal.py. It is placed UNWARPED
# (original speed, clip content in seconds) so it keeps its own 140 BPM feel against the 150 BPM track.
VOCAL_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "vocal", "when_you_change_140bpm.wav")
VOCAL_BARS = [128, 184] # 0-based start bars: Breakdown opening, and the final riser into Drop 2
VOCAL_COLOR = "#c77dff"
VOCAL_VOLUME = 0.75
SECTIONS = [ # name, start bar, length SECTIONS = [ # name, start bar, length
("Intro", 0, 32), ("Intro", 0, 32),
("Build 1", 32, 32), ("Build 1", 32, 32),
@@ -629,8 +638,12 @@ def chunk_clips(notes):
return out return out
def build_dawproject(path, tracks, devices, automation=True): def build_dawproject(path, tracks, devices, automation=True, vocal=True):
q = quoteattr q = quoteattr
vocal = vocal and os.path.exists(VOCAL_FILE)
if vocal:
with wave.open(VOCAL_FILE) as w:
v_sr, v_ch, v_secs = w.getframerate(), w.getnchannels(), w.getnframes() / w.getframerate()
kick = next(t[1] for t in tracks if t[0] == "Kick 808") kick = next(t[1] for t in tracks if t[0] == "Kick 808")
curves = filter_curves() if automation else {} curves = filter_curves() if automation else {}
n_points = 0 n_points = 0
@@ -665,6 +678,13 @@ def build_dawproject(path, tracks, devices, automation=True):
x.append(' <Volume unit="linear" value="%s" id="vol%d"/>' % (fmt(vol), i)) x.append(' <Volume unit="linear" value="%s" id="vol%d"/>' % (fmt(vol), i))
x.append(' </Channel>') x.append(' </Channel>')
x.append(' </Track>') x.append(' </Track>')
if vocal:
x.append(' <Track contentType="audio" loaded="true" id="t_vocal" name="Vocal" color=%s>' % q(VOCAL_COLOR))
x.append(' <Channel role="regular" audioChannels="%d" destination="c_master" id="c_vocal">' % v_ch)
x.append(' <Pan unit="normalized" value="0.5" id="pan_vocal"/>')
x.append(' <Volume unit="linear" value="%s" id="vol_vocal"/>' % fmt(VOCAL_VOLUME))
x.append(' </Channel>')
x.append(' </Track>')
x.append(' <Track contentType="audio notes" loaded="true" id="t_master" name="Master">') x.append(' <Track contentType="audio notes" loaded="true" id="t_master" name="Master">')
x.append(' <Channel role="master" audioChannels="2" id="c_master">') x.append(' <Channel role="master" audioChannels="2" id="c_master">')
x.append(' <Volume unit="linear" value="0.8" id="vol_master"/>') x.append(' <Volume unit="linear" value="0.8" id="vol_master"/>')
@@ -703,6 +723,19 @@ def build_dawproject(path, tracks, devices, automation=True):
x.append(' </Points>') x.append(' </Points>')
n_points += len(dp) n_points += len(dp)
x.append(' </Lanes>') x.append(' </Lanes>')
if vocal:
x.append(' <Lanes track="t_vocal" id="lanes_vocal">')
x.append(' <Clips id="clips_vocal">')
for k, bar in enumerate(VOCAL_BARS):
x.append(' <Clip time="%s" duration="%s" contentTimeUnit="seconds" playStart="0" name=%s color=%s>'
% (fmt(bar * 4.0), fmt(v_secs * BPM / 60.0), q("When you change... %d" % (k + 1)), q(VOCAL_COLOR)))
x.append(' <Audio timeUnit="seconds" duration="%s" channels="%d" sampleRate="%d" id="vocal_audio%d">'
% (fmt(v_secs), v_ch, v_sr, k))
x.append(' <File path="audio/%s" external="false"/>' % os.path.basename(VOCAL_FILE))
x.append(' </Audio>')
x.append(' </Clip>')
x.append(' </Clips>')
x.append(' </Lanes>')
x.append(' </Lanes>') x.append(' </Lanes>')
x.append(' <Markers id="markers">') x.append(' <Markers id="markers">')
for name, start, _ in SECTIONS: for name, start, _ in SECTIONS:
@@ -717,6 +750,8 @@ def build_dawproject(path, tracks, devices, automation=True):
with zipfile.ZipFile(path, "w", zipfile.ZIP_DEFLATED) as z: with zipfile.ZipFile(path, "w", zipfile.ZIP_DEFLATED) as z:
z.writestr("metadata.xml", meta_xml) z.writestr("metadata.xml", meta_xml)
z.writestr("project.xml", "\n".join(x) + "\n") z.writestr("project.xml", "\n".join(x) + "\n")
if vocal:
z.write(VOCAL_FILE, "audio/" + os.path.basename(VOCAL_FILE))
return n_points return n_points
@@ -729,12 +764,15 @@ def main():
slug = name.lower().replace(" ", "_") slug = name.lower().replace(" ", "_")
write_midi(os.path.join(HERE, "midi", "%02d_%s.mid" % (i, slug)), [(name, ch, notes)]) write_midi(os.path.join(HERE, "midi", "%02d_%s.mid" % (i, slug)), [(name, ch, notes)])
out = os.path.join(HERE, "exit-progressive-emulation.dawproject") out = os.path.join(HERE, "exit-progressive-emulation.dawproject")
n_auto = build_dawproject(out, tracks, devices, automation="--no-automation" not in sys.argv) n_auto = build_dawproject(out, tracks, devices, automation="--no-automation" not in sys.argv,
vocal="--no-vocal" not in sys.argv)
secs = TOTAL_BARS * 4 * 60 / BPM secs = TOTAL_BARS * 4 * 60 / BPM
print("%s: %d bars @ %d BPM = %d:%02d" % (TITLE, TOTAL_BARS, BPM, secs // 60, secs % 60)) print("%s: %d bars @ %d BPM = %d:%02d" % (TITLE, TOTAL_BARS, BPM, secs // 60, secs % 60))
for name, notes, *_ in tracks: for name, notes, *_ in tracks:
print(" %-12s %5d notes" % (name, len(notes))) print(" %-12s %5d notes" % (name, len(notes)))
print("automation breakpoints: %d" % n_auto) print("automation breakpoints: %d" % n_auto)
print("vocal track: %s" % ("yes (bars %s)" % ", ".join(str(b + 1) for b in VOCAL_BARS)
if "--no-vocal" not in sys.argv and os.path.exists(VOCAL_FILE) else "no"))
print("wrote", out) print("wrote", out)
@@ -0,0 +1,186 @@
#!/usr/bin/env python3
"""
Dark, smoky British female TTS vocal, locked to a tempo grid (default 140 BPM).
"When you change the way you look at things, the things you look at change."
Pipeline: Piper (local ONNX TTS, en_GB "cori" high-quality British female voice)
-> rubberband: time-fit each phrase to the bar grid + pitch down (deeper, darker)
-> smoky chain: high-pass, low warmth, tape saturation, dark roll-off, compression
-> tempo-synced ping-pong delay (dotted 8th) + dark plate reverb
Requires: python3 with numpy, scipy, soundfile, piper-tts; the `rubberband` CLI.
Voice files en_GB-cori-high.onnx + .onnx.json from
https://huggingface.co/rhasspy/piper-voices/tree/main/en/en_GB/cori/high
Usage: python3 make_vocal.py --voice /path/to/en_GB-cori-high.onnx [--bpm 140] [--pitch -2.5]
Writes: when_you_change_<bpm>bpm.wav (wet, 8 bars) and ..._dry.wav (no delay/reverb)
"""
import argparse
import os
import subprocess
import sys
import tempfile
import numpy as np
import soundfile as sf
from scipy import signal
from scipy.signal import fftconvolve
HERE = os.path.dirname(os.path.abspath(__file__))
SR = 48000
PHRASES = [
# text, start bar (0-based), max bars it may occupy
("When you change the way you look at things,", 0, 2),
("the things you look at change.", 2, 2),
]
BARS_TOTAL = 8
def synth(voice, text, length_scale, noise_scale=0.55, noise_w=0.7):
"""Piper TTS via its CLI -> (float samples, sample rate). Lower noise = calmer, more even delivery."""
with tempfile.TemporaryDirectory() as d:
out = os.path.join(d, "t.wav")
subprocess.run([sys.executable, "-m", "piper", "-m", voice, "-f", out,
"--length-scale", str(length_scale), "--noise-scale", str(noise_scale),
"--noise-w-scale", str(noise_w)],
input=text.encode(), check=True, capture_output=True)
x, sr = sf.read(out)
return x.astype(np.float64), sr
def trim(x, thresh=0.01):
idx = np.where(np.abs(x) > thresh * np.max(np.abs(x)))[0]
return x[idx[0]:idx[-1] + 1]
def rubberband(x, sr, ratio, semitones):
"""Time-stretch to `ratio` x the length and pitch-shift (formants move with pitch)."""
with tempfile.TemporaryDirectory() as d:
a, b = os.path.join(d, "in.wav"), os.path.join(d, "out.wav")
sf.write(a, x, sr, subtype="FLOAT")
subprocess.run(["rubberband", "-q", "-t", "%.6f" % ratio, "-p", "%.3f" % semitones, a, b], check=True)
y, sr2 = sf.read(b)
return y
def lp(x, hz, order=2):
return signal.sosfilt(signal.butter(order, hz, "low", fs=SR, output="sos"), x)
def hp(x, hz, order=2):
return signal.sosfilt(signal.butter(order, hz, "high", fs=SR, output="sos"), x)
def compress(x, thresh_db=-22.0, ratio=3.0, attack=0.005, release=0.12):
a, r = np.exp(-1 / (attack * SR)), np.exp(-1 / (release * SR))
env = np.zeros_like(x)
e = 0.0
ax = np.abs(x)
for i in range(len(x)):
e = a * e + (1 - a) * ax[i] if ax[i] > e else r * e + (1 - r) * ax[i]
env[i] = e
db = 20 * np.log10(np.maximum(env, 1e-6))
over = np.maximum(db - thresh_db, 0)
gain = 10 ** (-(over * (1 - 1 / ratio)) / 20)
return x * gain
def smoky(x):
x = hp(x, 85)
x = x + 0.5 * lp(x, 230) # chesty low warmth
x = x + 0.35 * (np.tanh(2.2 * x) / np.tanh(2.2) - x) # tape-ish saturation (35 % blend)
x = lp(x, 6200, 4) # dark roll-off: no air, no sizzle
x = compress(x)
return x
def plate(x, rt60=3.2, predelay=0.03, seed=7):
"""Dark stereo plate: decaying noise, progressively low-passed."""
rng = np.random.default_rng(seed)
n = int(rt60 * 1.1 * SR)
t = np.arange(n) / SR
outs = []
for _ in range(2):
noise = rng.standard_normal(n)
ir = np.zeros(n)
for lo, hi, w in ((0.0, 0.4, 3800), (0.4, 1.2, 2400), (1.2, 99, 1500)):
m = (t >= lo) & (t < hi)
ir += lp(noise, w) * m
ir *= np.exp(-6.91 * t / rt60)
ir = np.concatenate([np.zeros(int(predelay * SR)), ir])
outs.append(fftconvolve(x, ir / np.sqrt(np.sum(ir ** 2))))
n = max(len(o) for o in outs)
return np.stack([np.pad(o, (0, n - len(o))) for o in outs], axis=1)
def pingpong(x, beat, feedback=0.38, taps=6):
"""Dotted-8th (0.75 beat) ping-pong delay, each repeat darker."""
step = int(round(0.75 * beat * SR))
out = np.zeros((len(x) + step * taps + 1, 2))
sig = x.copy()
for k in range(1, taps + 1):
sig = lp(sig, 2400) * feedback
out[k * step:k * step + len(sig), k % 2] += sig
return out
def mix_in(buf, x, at):
n = min(len(x), len(buf) - at)
buf[at:at + n] += x[:n]
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--voice", required=True, help="Piper voice .onnx (the .onnx.json must sit next to it)")
ap.add_argument("--bpm", type=float, default=140.0)
ap.add_argument("--pitch", type=float, default=-2.5, help="semitones (negative = deeper)")
ap.add_argument("--length-scale", type=float, default=1.25, help="Piper pacing (>1 = slower, more deliberate)")
ap.add_argument("--out", default=HERE)
args = ap.parse_args()
beat = 60.0 / args.bpm
bar = 4 * beat
total = int(BARS_TOTAL * bar * SR)
dry = np.zeros(total + SR * 4)
for text, start_bar, max_bars in PHRASES:
target = max_bars * bar - 1.5 * beat # leave a breath before the next phrase
ls = args.length_scale
for _ in range(2): # let Piper itself pace the phrase (better prosody than post-stretching)
x, sr = synth(args.voice, text, ls)
x = signal.resample_poly(trim(x), SR, sr)
natural = len(x) / SR
ls *= min(1.9, max(0.8, target / natural)) ** 0.9
x, sr = synth(args.voice, text, ls)
x = signal.resample_poly(trim(x), SR, sr)
natural = len(x) / SR
ratio = min(1.35, max(0.8, target / natural)) # keep the delivery natural
y = rubberband(x, SR, ratio, args.pitch)
y = smoky(y)
mix_in(dry, y, int(round(start_bar * bar * SR)))
print("%-46s natural %.2fs -> x%.2f = %.2fs (bar %d, grid slot %.2fs)"
% (text[:46], natural, ratio, len(y) / SR, start_bar + 1, max_bars * bar))
dry = dry[:total + SR * 4]
delay = pingpong(dry, beat)
verb = plate(dry)
n = max(len(dry), len(delay), len(verb))
wet = np.zeros((n, 2))
wet[:len(dry)] += dry[:, None] * 0.9
wet[:len(delay)] += delay * 0.28
wet[:len(verb)] += verb * 0.55
wet = wet[:int(BARS_TOTAL * bar * SR)]
# fade the last 1.5 beats so the tail ends cleanly on the grid
fade = int(1.5 * beat * SR)
wet[-fade:] *= np.linspace(1, 0, fade)[:, None]
dry2 = np.repeat(dry[:len(wet), None], 2, axis=1)
for name, sig in (("when_you_change_%dbpm.wav" % args.bpm, wet), ("when_you_change_%dbpm_dry.wav" % args.bpm, dry2)):
sig = sig / np.max(np.abs(sig)) * 10 ** (-1 / 20) # peak -1 dBFS
sf.write(os.path.join(args.out, name), sig, SR, subtype="PCM_24")
print("wrote", os.path.join(args.out, name), "%.3fs" % (len(sig) / SR))
if __name__ == "__main__":
main()