The exact prompts and code we have on file for each AI-assisted image, code-drawn image and animated short. Where a prompt wasn't saved, we say so.
Animated shorts #1 and #2 (version 3, 75 seconds)
Tools: Grok Bot video generation (short animated clips made from the owner's art as start frames: blueprint, original logo, family, Panera, ski-mask cook, Meet Red Panda, banner, coin, roadmap and NFT characters), then Python/ffmpeg scripts for scene timing, captions, headers, transitions and the 75-second edit (render3.py with render.py), plus an original 128 BPM music bed synthesized in code (club.py; the script states nothing is sampled or transcribed) and a level-shaping mastering pass (master.py). Scene and caption scripts are v3_1.json (Short #1) and v3_2.json (Short #2); music section maps are m3_1.json and m3_2.json. Source folder: /workspace/redpanda-videos/src. Earlier cuts (v1, v2: 38 seconds, scripts v1.json, v2.json, assemble.py, music.py, trap_instrumental.py) were replaced by version 3 and are kept only as superseded files.
v3_1.json · 18 lines · SHA-256 9961fd7ad9e562f93bb4b575492fd6a93ad0cc60fe0c7368df82d88a2237a08d
{"drops":[[16,88],[116,148]],
"scenes":[
{"puppet":"blueprint","beats":8,"head":"CLASSIFIED FILE","caps":[[0,1,"It all began with a blueprint..."]]},
{"clip":"v1_blueprint.mp4","beats":8,"head":"SPECIES FUSION","caps":[[0,1,"A giant-panda suit built to hide a secret."]]},
{"clip":"c1_brand_walk.mp4","beats":12,"head":"PAN KITCHEN","flash":0.9,"caps":[[0,0.5,"Enter Pan Kitchen..."],[0.5,1,"The chef with the duct-taped pan."]]},
{"clip":"c1_original_drum.mp4","beats":12,"head":"ALWAYS COOKING","caps":[[0,0.5,"Zero lore. Locked-in stare."],[0.5,1,"Drumming that pan 24/7."]]},
{"clip":"c1_family_dance.mp4","beats":16,"head":"THE PAN FAMILY","caps":[[0,0.5,"Then came the family..."],[0.5,1,"Pan Chicken, Pan Kitchen & Panera."]]},
{"clip":"c1_panchicken.mp4","beats":12,"head":"PAN CHICKEN","caps":[[0,1,"Pan Chicken: frying-pan hat, spatula ready."]]},
{"clip":"v1_panera.mp4","beats":8,"head":"PANERA","caps":[[0,1,"Panera: on her way from China..."]]},
{"clip":"c1_panera_pop.mp4","beats":12,"head":"PANERA","caps":[[0,1,"...bubble gum and all!"]]},
{"clip":"v1_skicook.mp4","beats":8,"head":"THE DISGUISE","caps":[[0,1,"But behind the mask was a secret."]]},
{"clip":"c1_skicook_hot.mp4","beats":8,"head":"TOO HOT...","caps":[[0,1,"Then the kitchen got TOO hot..."]]},
{"clip":"c1_maskoff_morph.mp4","beats":12,"head":"THE MASK COMES OFF","caps":[[0,0.5,"The skillet melted the mask..."],[0.5,1,"Russet ears. Cinnamon fur."]]},
{"puppet":"reveal","beats":12,"head":"MEET RED PANDA","flash":1.0,"caps":[[0,0.5,"The cat's out of the bag!"],[0.5,1,"He was a Red Panda all along."]]},
{"clip":"v1_chef.mp4","beats":8,"head":"RED PANDA","caps":[[0,1,"Same kitchen. Same pan."]]},
{"clip":"c1_chef_cook.mp4","beats":12,"head":"STILL COOKING","caps":[[0,1,"New fire-red coat. The heat is on."]]},
{"end":true,"beats":12,"l1":"Animated series coming to YouTube","l2":"Follow the story"}
]}
v3_2.json · 206 lines · SHA-256 401b342b4e0e06e9c3cf47223a6cd9261c83e36a437682abd5751b27419a7a7c
{
"drops": [
[
16,
68
],
[
108,
148
]
],
"scenes": [
{
"clip": "v2_coin.mp4",
"beats": 8,
"head": "$FOXXP",
"flash": 0.8,
"caps": [
[
0,
1,
"Red Panda has his own coin..."
]
]
},
{
"clip": "c2_coin_spin.mp4",
"beats": 8,
"head": "$FOXXP IS LIVE",
"caps": [
[
0,
1,
"$FOXXP is now live on Solana."
]
]
},
{
"clip": "v2_astro.mp4",
"beats": 8,
"head": "BUILT ON SOLANA",
"flash": 0.9,
"caps": [
[
0,
1,
"Launched on Solana."
]
]
},
{
"clip": "c2_astro_wave.mp4",
"beats": 12,
"head": "FIND $FOXXP",
"caps": [
[
0,
1,
"Find $FOXXP on Jupiter and DexScreener."
]
]
},
{
"clip": "c2_jupiter.mp4",
"beats": 8,
"head": "VERIFY THE CA",
"caps": [
[
0,
1,
"Always verify the official CA on our website."
]
],
"push": 0.035
},
{
"clip": "v2_roadmap.mp4",
"beats": 12,
"head": "THE ROADMAP",
"caps": [
[
0,
1,
"Phase 1: Preheat. Phase 2: Sizzle."
]
]
},
{
"clip": "c2_roadmap_walk.mp4",
"beats": 12,
"head": "THE ROADMAP",
"caps": [
[
0,
1,
"Phase 3: Meteoric. Phase 4: Infinite Aura."
]
]
},
{
"clip": "v2_skimask.mp4",
"beats": 8,
"head": "AIRDROP: DEC 1",
"caps": [
[
0,
1,
"The $FOXXP community airdrop begins December 1."
]
],
"push": 0.035
},
{
"clip": "c2_skimask_point.mp4",
"beats": 12,
"head": "REGISTER NOW",
"caps": [
[
0,
1,
"Register your Solana wallet on our website."
]
]
},
{
"clip": "v2_banner.mp4",
"beats": 8,
"head": "ANIMATED SERIES",
"caps": [
[
0,
1,
"We're launching a YouTube channel."
]
]
},
{
"clip": "c2_banner_push.mp4",
"beats": 12,
"head": "ON YOUTUBE SOON",
"caps": [
[
0,
1,
"The full Red Panda story, animated."
]
]
},
{
"clip": "c2_pirate_salute.mp4",
"beats": 12,
"head": "COMMUNITY REWARDS",
"flash": 1.0,
"caps": [
[
0,
1,
"Rewards for the community that built this."
]
]
},
{
"puppet": "nft",
"beats": 8,
"head": "THE RED PANDA CREW",
"caps": [
[
0,
1,
"NFT drops, giveaways & community events."
]
]
},
{
"clip": "c2_charity.mp4",
"beats": 8,
"head": "GIVING BACK",
"caps": [
[
0,
1,
"Save the Pandas: we give back too."
]
],
"push": 0.035
},
{
"clip": "c2_chef_to_samurai.mp4",
"beats": 12,
"head": "JOIN THE CLAN",
"caps": [
[
0,
1,
"The suit is off. The heat is on."
]
]
},
{
"end": true,
"beats": 12,
"l1": "$FOXXP on Solana \u2022 Airdrop Dec 1",
"l2": "Not financial advice. Always DYOR."
}
]
}
m3_1.json · 1 lines · SHA-256 a6fa2654385c5b6be5c646cce0dd4e76c1569e14a4ede5d967dc711b2ed09b86
{"dur": 75.0, "sections": [[0, 12, "intro"], [12, 16, "build"], [16, 48, "drop"], [48, 88, "groove"], [88, 100, "break"], [100, 116, "build"], [116, 148, "drop"], [148, 160, "outro"]], "impacts": []}
m3_2.json · 1 lines · SHA-256 195cc0af8ff947e8193cb409b397795043f8ab143930dc97e9cbb4e308d11860
{"dur": 75.0, "sections": [[0, 12, "intro"], [12, 16, "build"], [16, 68, "drop"], [68, 88, "break"], [88, 108, "build"], [108, 148, "drop"], [148, 160, "outro"]], "impacts": [0.02]}
render3.py · 207 lines · SHA-256 2e278f69e4df4a7472e0250ff64ab661a51ae1f4e6107a052d39f47b358ff0e0
import sys, json, math, random, os, subprocess
sys.path.insert(0, os.path.dirname(__file__))
import render as R
from render import W, H, FPS, ORANGE, GOLD, ease, read_clip, enc, header_img, text_layer, CAP, HEAD, FOOT
from PIL import Image, ImageDraw, ImageFilter
import numpy as np
BPM = 128.0
BEAT = 60.0 / BPM
WK = R.WK
def pulse_amt(tg, drops):
"""beat punch 0..1 if global time tg is in a drop section."""
for a, b in drops:
if a * BEAT <= tg < b * BEAT:
bi = int((tg + 1e-6) // BEAT); dt = tg - bi * BEAT
amp = 1.0 if bi % 4 in (0, 2) else 0.45
return amp * math.exp(-dt * 10)
return 0.0
def compose(fg, head, caps, t, tg, drops, flash=0.0, push=0.0):
if push:
z = 1 + push * t
nw, nh = int(fg.width * z), int(fg.height * z)
big = fg.resize((nw, nh), Image.BILINEAR); l = (nw - fg.width) // 2; tp = (nh - fg.height) // 2
fg = big.crop((l, tp, l + fg.width, tp + fg.height))
p = pulse_amt(tg, drops)
if p > 0.01:
s = 1 + 0.035 * p
nw, nh = int(fg.width * s), int(fg.height * s)
big = fg.resize((nw, nh), Image.BILINEAR)
l = (nw - fg.width) // 2; tp = (nh - fg.height) // 2
fg = big.crop((l, tp, l + fg.width, tp + fg.height))
if fg.height > 1180:
tp = (fg.height - 1180) // 2; fg = fg.crop((0, tp, fg.width, tp + 1180))
bw = W // 10; bh = H // 10
sm = fg.resize((max(1, int(fg.width * bh / fg.height)), bh))
if sm.width < bw: sm = fg.resize((bw, int(fg.height * bw / fg.width)))
l = (sm.width - bw) // 2; tp = (sm.height - bh) // 2
bg = sm.crop((l, tp, l + bw, tp + bh)).filter(ImageFilter.GaussianBlur(3)).resize((W, H), Image.BILINEAR)
bg = Image.blend(bg, Image.new('RGB', (W, H), (12, 4, 0)), 0.55 - 0.12 * p)
y = 900 - fg.height // 2
if fg.height < 900: y = 560
canvas = bg.copy()
d = ImageDraw.Draw(canvas)
edge = tuple(int(c + (255 - c) * p * 0.6) for c in ORANGE)
d.rectangle((0, y - 6, W, y + fg.height + 5), fill=edge)
canvas.paste(fg, (0, y))
canvas = canvas.convert('RGBA')
a = ease(min(1, t / 0.25))
hl = head
if a < 1:
hl = head.copy(); hl.putalpha(hl.getchannel('A').point(lambda v: int(v * a)))
canvas.alpha_composite(hl, (0, 0))
cap_top = y + fg.height + 30
for (c0, c1, img) in caps:
if c0 <= t < c1:
k = ease(min(1, (t - c0) / 0.15)); sc = 0.85 + 0.15 * k
ci = img if sc >= 1 else img.resize((int(img.width * sc), int(img.height * sc)))
ci = ci.copy(); ci.putalpha(ci.getchannel('A').point(lambda v: int(v * k)))
canvas.alpha_composite(ci, ((W - ci.width) // 2, cap_top + (img.height - ci.height) // 2))
canvas.alpha_composite(FOOT, (0, H - 120))
out = canvas.convert('RGB')
if flash > 0:
out = Image.blend(out, Image.new('RGB', (W, H), (255, 245, 230)), min(1, flash))
return out
# ---------------- puppet sources ----------------
def blueprint_pan(dur):
im = Image.open('/workspace/pankitchen-site/assets/img/species-fusion-blueprint.webp').convert('RGB')
S = 1080 / im.height; im = im.resize((int(im.width * S), 1080), Image.LANCZOS)
N = int(round(dur * FPS)); maxx = im.width - 1080
for i in range(N):
u = i / max(1, N - 1); e = u * u * (3 - 2 * u)
z = 1.12 - 0.12 * e
x = int(e * maxx)
win = im.crop((x, 0, x + 1080, 1080))
zw = int(1080 * z); win = win.resize((zw, zw), Image.BILINEAR)
o = (zw - 1080) // 2; win = win.crop((o, o, o + 1080, o + 1080)).convert('RGBA')
ov = Image.new('RGBA', (1080, 1080), (0, 0, 0, 0)); d = ImageDraw.Draw(ov)
sy = int((i * 18) % 1180) - 50
d.rectangle((0, sy, 1080, sy + 40), fill=(140, 220, 255, 55))
for k in range(0, 1080, 6): d.line((0, k, 1080, k), fill=(0, 20, 60, 18))
win.alpha_composite(ov)
yield win.convert('RGB')
def reveal_combo(dur):
# 0..1.4s generated motion (starts on the exact art), then puppet of exact art with shake/zoom/embers
gen = list(read_clip(WK + 'v1_reveal.mp4', 0, 1.4, W))
for f in gen: yield f
rest = dur - len(gen) / FPS
for f in R.still_frames('/workspace/pankitchen-site/assets/img/meet-red-panda.webp', rest, W, shake=True, zoom=(1.02, 1.14), flash=False):
yield f
def nft_dance(dur, t0g):
cuts = [Image.open(f'{WK}cut_rp{i}.png') for i in (1, 2, 3, 4, 5)]
cuts = [c.resize((440, 440), Image.LANCZOS) for c in cuts]
N = int(round(dur * FPS)); rnd = random.Random(5)
stars = [(rnd.randint(0, 1080), rnd.randint(0, 1080), rnd.randint(2, 5)) for _ in range(60)]
for i in range(N):
t = i / FPS; tg = t0g + t
ph = (tg / BEAT) % 1.0
bg = Image.new('RGB', (1080, 1080), (30, 8, 4)); d = ImageDraw.Draw(bg)
# moving stage lights
for k in range(4):
ang = math.sin(tg * 1.3 + k * 1.7) * 0.6
cx = 135 + k * 270; tx = cx + math.sin(ang) * 900
col = [(255, 90, 20), (255, 200, 40), (255, 60, 60), (255, 140, 0)][k]
light = Image.new('RGBA', (1080, 1080), (0, 0, 0, 0)); ld = ImageDraw.Draw(light)
ld.polygon([(cx, -20), (tx - 160, 1080), (tx + 160, 1080)], fill=col + (60,))
bg.paste(light, (0, 0), light)
for (sx, sy, r) in stars:
tw = 0.5 + 0.5 * math.sin(tg * 6 + sx)
d.ellipse((sx, sy, sx + r, sy + r), fill=(255, int(180 + 60 * tw), 80))
d.rectangle((0, 900, 1080, 1080), fill=(20, 6, 2))
bg = bg.convert('RGBA')
order = [0, 4, 1, 3, 2] # back row first then front center
pos = {0: (-30, 300), 4: (670, 300), 1: (150, 420), 3: (490, 420), 2: (320, 520)}
for idx in order:
c = cuts[idx]
bounce = abs(math.sin(math.pi * ((tg / BEAT) + idx * 0.5)))
sq = 1 - 0.06 * (1 - bounce)
ang = math.sin(2 * math.pi * (tg / (2 * BEAT)) + idx) * 6
cw, ch = int(440 * (1 + 0.03 * (1 - bounce))), int(440 * sq)
ci = c.resize((cw, ch), Image.BILINEAR).rotate(ang, resample=Image.BICUBIC, expand=True)
x, y = pos[idx]
y = y - int(38 * bounce) + (440 - ch)
sh = Image.new('RGBA', bg.size, (0, 0, 0, 0)); sd = ImageDraw.Draw(sh)
sd.ellipse((x + 90, pos[idx][1] + 420, x + 350, pos[idx][1] + 450), fill=(0, 0, 0, 110))
bg.alpha_composite(sh)
bg.alpha_composite(ci, (x - (ci.width - cw) // 2, y - (ci.height - ch) // 2))
yield bg.convert('RGB')
def endcard(out, dur, line1, line2, t0g, drops):
coin = Image.open('/workspace/redpanda-coin/redpanda-coin.png').convert('RGBA').resize((760, 760), Image.LANCZOS)
mask = Image.new('L', coin.size, 0); ImageDraw.Draw(mask).ellipse((4, 4, 756, 756), fill=255); coin.putalpha(mask)
ban = Image.open('/workspace/redpanda-x-profile/banner.png').convert('RGB')
bgb = ban.resize((int(ban.width * H / ban.height), H))
cuts = [Image.open(f'{WK}cut_rp{i}.png').resize((300, 300), Image.LANCZOS) for i in (1, 2, 3, 4, 5)]
e = enc(out); N = int(round((t0g + dur) * FPS)) - int(round(t0g * FPS))
t1, _ = text_layer('PAN KITCHEN', HEAD, 120, GOLD, 8); t2, _ = text_layer('RED PANDA PROTOCOL', HEAD, 84, (255, 255, 255), 7)
l1, _ = text_layer(line1, CAP, 50, (255, 255, 255), 5); l2, _ = text_layer(line2, CAP, 44, (255, 220, 170), 4)
url, _ = text_layer('pankitchen-redpanda.pages.dev', CAP, 54, (255, 255, 255), 6, maxw=1070)
hd, _ = text_layer('X: @PANKItCHeN_CHeN', CAP, 56, GOLD, 6, maxw=1070)
for i in range(N):
t = i / FPS; tg = t0g + t
off = int((bgb.width - W) / 2 + math.sin(t * 0.6) * 120)
bg = bgb.crop((off, 0, off + W, H)).filter(ImageFilter.GaussianBlur(14))
c = Image.blend(bg, Image.new('RGB', (W, H), (10, 3, 0)), 0.6).convert('RGBA')
p = pulse_amt(tg, drops)
s = 0.7 + 0.3 * ease(min(1, t / 0.5)) + 0.03 * p
rot = math.sin(t * 1.5) * 4
ci = coin.resize((int(760 * s), int(760 * s))).rotate(rot, resample=Image.BICUBIC)
glow = Image.new('RGBA', (W, H), (0, 0, 0, 0)); gd = ImageDraw.Draw(glow); r = int(400 * s)
gd.ellipse((W // 2 - r, 640 - r, W // 2 + r, 640 + r), fill=(255, 120, 20, 110 + int(60 * p))); glow = glow.filter(ImageFilter.GaussianBlur(40))
bob = int(math.sin(t * 2 * math.pi / (2 * BEAT)) * 18)
c.alpha_composite(glow); c.alpha_composite(ci, ((W - ci.width) // 2, 640 + bob - ci.height // 2))
# dancing NFT crew peeking at bottom
for k, cu in enumerate(cuts):
b = abs(math.sin(math.pi * (tg / BEAT + k * 0.5)))
yy = 1800 - int(36 * b) - int(160 * ease(min(1, max(0, (t - 0.3 - k * 0.08) / 0.4))))
c.alpha_composite(cu, (k * 216 - 40, yy))
def put(img, y, t0):
k = ease(max(0, min(1, (t - t0) / 0.3)))
if k <= 0: return
im = img.copy(); im.putalpha(im.getchannel('A').point(lambda v: int(v * k))); c.alpha_composite(im, (0, y + int(30 * (1 - k))))
put(t1, 90, 0.1); put(t2, 1030, 0.3); put(l1, 1150, 0.6); put(l2, 1255, 0.8); put(url, 1355, 1.0); put(hd, 1440, 1.2)
e.stdin.write(c.convert('RGB').tobytes())
e.stdin.close(); e.wait()
def scene(sc, out, t0g, drops):
dur = sc['beats'] * BEAT
head = header_img(sc['head'], None)
caps = []
for c in sc['caps']:
img, _ = text_layer(c[2], CAP, 62, (255, 255, 255), 6, maxw=990)
caps.append((c[0] * dur, c[1] * dur, img))
kind = sc.get('puppet')
if kind == 'blueprint': frames = blueprint_pan(dur)
elif kind == 'reveal': frames = reveal_combo(dur)
elif kind == 'nft': frames = nft_dance(dur, t0g)
else: frames = read_clip(WK + sc['clip'], sc.get('start', 0), dur + 0.2, W)
N = int(round((t0g + dur) * FPS)) - int(round(t0g * FPS))
e = enc(out); last = None; n = 0
for fg in frames:
if n >= N: break
t = n / FPS
fl = sc.get('flash', 0) * max(0, 1 - t / 0.35)
e.stdin.write(compose(fg, head, caps, t, t0g + t, drops, fl, sc.get('push', 0)).tobytes()); last = fg; n += 1
while n < N: # pad (should not happen)
t = n / FPS; e.stdin.write(compose(last, head, caps, t, t0g + t, drops).tobytes()); n += 1
e.stdin.close(); e.wait()
if __name__ == '__main__':
spec = json.load(open(sys.argv[1])); outdir = sys.argv[2]; os.makedirs(outdir, exist_ok=True)
BEAT = 60.0 / spec.get('bpm', 128.0); globals()['BEAT'] = BEAT
only = sys.argv[3:]
drops = spec['drops']; beat0 = 0
for i, sc in enumerate(spec['scenes']):
t0g = beat0 * BEAT
if not only or str(i) in only:
p = f'{outdir}/s{i:02d}.mp4'
if sc.get('end'): endcard(p, sc['beats'] * BEAT, sc['l1'], sc['l2'], t0g, drops)
else: scene(sc, p, t0g, drops)
print('done', i, sc.get('clip', sc.get('puppet', 'end')), f'start_beat={beat0}', flush=True)
beat0 += sc['beats']
print('total_beats', beat0, 'seconds', beat0 * BEAT)
render.py · 159 lines · SHA-256 e99b5e837b94835f43215172c0501834e3be93d682389d8a2fd063f6abf050ca
import subprocess, numpy as np, math, random, sys, json, os
from PIL import Image, ImageDraw, ImageFont, ImageFilter
W,H,FPS=1080,1920,30
F='/usr/share/fonts/truetype/sand-box/google/'
HEAD=F+'Luckiest Guy/LuckiestGuy-Regular.ttf'
CAP=F+'Poppins/Poppins-ExtraBold.ttf'
SMALL=F+'Poppins/Poppins-Bold.ttf'
WK='/workspace/redpanda-videos/work/'
ORANGE=(255,122,26); GOLD=(255,196,40)
def font(p,s): return ImageFont.truetype(p,s)
def wrap(d,text,f,maxw):
words=text.split(); lines=[]; cur=''
for w in words:
t=(cur+' '+w).strip()
if d.textlength(t,font=f)<=maxw: cur=t
else: lines.append(cur); cur=w
if cur: lines.append(cur)
return lines
def text_layer(text,fp,size,color,stroke,maxw=980,align_center_y=None,fill_bg=None,lh=1.15):
img=Image.new('RGBA',(W,700),(0,0,0,0)); d=ImageDraw.Draw(img); f=font(fp,size)
lines=wrap(d,text,f,maxw); y=10
boxes=[]
for ln in lines:
tw=d.textlength(ln,font=f); x=(W-tw)/2
d.text((x,y),ln,font=f,fill=color,stroke_width=stroke,stroke_fill=(0,0,0))
y+=int(size*lh)
return img.crop((0,0,W,y+20)), y+20
def header_img(text,sub):
img=Image.new('RGBA',(W,330),(0,0,0,0)); d=ImageDraw.Draw(img)
f=font(SMALL,34); s='PAN KITCHEN • RED PANDA PROTOCOL'
tw=d.textlength(s,font=f); d.rounded_rectangle(((W-tw)/2-26,40,(W+tw)/2+26,98),radius=29,fill=(0,0,0,170),outline=ORANGE,width=3)
d.text(((W-tw)/2,46),s,font=f,fill=(255,255,255))
size=112
while True:
fh=font(HEAD,size)
if d.textlength(text,font=fh)<=1000 or size<60: break
size-=4
tw=d.textlength(text,font=fh)
d.text(((W-tw)/2,135+(112-size)//2),text,font=fh,fill=GOLD,stroke_width=7,stroke_fill=(20,8,0))
return img
def footer_img():
img=Image.new('RGBA',(W,110),(0,0,0,0)); d=ImageDraw.Draw(img); f=font(SMALL,32)
s='@PANKItCHeN_CHeN • pankitchen-redpanda.pages.dev'
tw=d.textlength(s,font=f); d.text(((W-tw)/2,36),s,font=f,fill=(255,230,200),stroke_width=3,stroke_fill=(0,0,0))
return img
FOOT=footer_img()
def ease(t): return 1-(1-t)**3
def read_clip(path,start,dur,tw):
cmd=['ffmpeg','-v','error','-ss',str(start),'-t',str(dur),'-i',path,'-vf',f'fps={FPS},scale={tw}:-2:flags=lanczos','-f','rawvideo','-pix_fmt','rgb24','-']
pr=subprocess.Popen(cmd,stdout=subprocess.PIPE)
probe=subprocess.run(['ffprobe','-v','error','-select_streams','v:0','-show_entries','stream=width,height','-of','csv=p=0',path],capture_output=True,text=True).stdout.strip().split(',')
w,h=int(probe[0]),int(probe[1]); th=int(round(h*tw/w/2))*2
n=0
while True:
b=pr.stdout.read(tw*th*3)
if len(b)<tw*th*3: break
yield Image.frombytes('RGB',(tw,th),b); n+=1
def still_frames(path,dur,tw,shake=True,zoom=(1.0,1.12),flash=True):
base=Image.open(path).convert('RGB'); w,h=base.size; th=int(h*tw/w)
base=base.resize((tw,th),Image.LANCZOS); N=int(dur*FPS)
rnd=random.Random(3); parts=[[rnd.uniform(0,tw),rnd.uniform(0,th),rnd.uniform(2,7),rnd.uniform(2,6)] for _ in range(70)]
for i in range(N):
t=i/FPS; z=zoom[0]+(zoom[1]-zoom[0])*ease(min(1,t/dur))
if shake and t<1.4:
a=(1.4-t)/1.4*22; dx=int(math.sin(t*61)*a); dy=int(math.cos(t*47)*a)
else: dx=dy=0
zw,zh=int(tw*z),int(th*z); im=base.resize((zw,zh),Image.BILINEAR)
l=(zw-tw)//2+dx; tp=(zh-th)//2+dy; l=max(0,min(zw-tw,l)); tp=max(0,min(zh-th,tp))
fr=im.crop((l,tp,l+tw,tp+th)).convert('RGBA')
d=ImageDraw.Draw(fr)
for p in parts:
y=(p[1]-t*60*p[3])%th; x=p[0]+math.sin(t*2+p[1])*12
d.ellipse((x,y,x+p[2],y+p[2]),fill=(255,int(140+p[2]*12),40,200))
fr=fr.convert('RGB')
if flash and t<0.45:
a=1-t/0.45; fr=Image.blend(fr,Image.new('RGB',fr.size,(255,245,230)),a*0.95)
yield fr
def compose(fg,head,caps,t,ti):
# background: blurred fill
bw=W//10; bh=H//10
sm=fg.resize((max(1,int(fg.width*bh/fg.height)),bh))
if sm.width<bw: sm=fg.resize((bw,int(fg.height*bw/fg.width)))
l=(sm.width-bw)//2; tp=(sm.height-bh)//2
bg=sm.crop((l,tp,l+bw,tp+bh)).filter(ImageFilter.GaussianBlur(3)).resize((W,H),Image.BILINEAR)
bg=Image.blend(bg,Image.new('RGB',(W,H),(12,4,0)),0.55)
cy=360+540; y=cy-fg.height//2
if fg.height<900: y=560
canvas=bg.copy()
d=ImageDraw.Draw(canvas); d.rectangle((0,y-6,W,y+fg.height+5),fill=ORANGE)
canvas.paste(fg,(0,y))
canvas=canvas.convert('RGBA')
# header slide in
a=ease(min(1,ti/0.35)); hy=int(-60*(1-a))
hl=head.copy();
if a<1: hl.putalpha(hl.getchannel('A').point(lambda v:int(v*a)))
canvas.alpha_composite(hl,(0,max(0,hy)) if hy>=0 else (0,0))
cap_top=y+fg.height+30
for (c0,c1,img) in caps:
if c0<=t<c1:
k=ease(min(1,(t-c0)/0.18));
sc=0.85+0.15*k
ci=img
if sc<1: ci=img.resize((int(img.width*sc),int(img.height*sc)))
ci=ci.copy(); ci.putalpha(ci.getchannel('A').point(lambda v:int(v*k)))
canvas.alpha_composite(ci,((W-ci.width)//2,cap_top+(img.height-ci.height)//2))
canvas.alpha_composite(FOOT,(0,H-120))
return canvas.convert('RGB')
def enc(out):
return subprocess.Popen(['ffmpeg','-v','error','-y','-f','rawvideo','-pix_fmt','rgb24','-s',f'{W}x{H}','-r',str(FPS),'-i','-','-c:v','libx264','-preset','medium','-crf','18','-pix_fmt','yuv420p',out],stdin=subprocess.PIPE)
def scene(sc,out):
head=header_img(sc['head'],None)
caps=[]
for c in sc['caps']:
img,_=text_layer(c[2],CAP,62,(255,255,255),6,maxw=990)
caps.append((c[0],c[1],img))
e=enc(out)
if sc.get('still'):
frames=still_frames(sc['still'],sc['dur'],W,**sc.get('opts',{}))
else:
frames=read_clip(WK+sc['clip'],sc.get('start',0),sc['dur'],W)
n=0
for i,fg in enumerate(frames):
t=i/FPS
e.stdin.write(compose(fg,head,caps,t,t).tobytes()); n+=1
e.stdin.close(); e.wait(); return n/FPS
def endcard(out,dur,line1,line2):
coin=Image.open('/workspace/redpanda-coin/redpanda-coin.png').convert('RGBA').resize((760,760),Image.LANCZOS)
mask=Image.new('L',coin.size,0); ImageDraw.Draw(mask).ellipse((4,4,756,756),fill=255); coin.putalpha(mask)
ban=Image.open('/workspace/redpanda-x-profile/banner.png').convert('RGB')
bg=ban.resize((int(ban.width*H/ban.height),H)); l=(bg.width-W)//2; bg=bg.crop((l,0,l+W,H)).filter(ImageFilter.GaussianBlur(14))
bg=Image.blend(bg,Image.new('RGB',(W,H),(10,3,0)),0.6)
e=enc(out); N=int(dur*FPS)
t1,_=text_layer('PAN KITCHEN',HEAD,120,GOLD,8); t2,_=text_layer('RED PANDA PROTOCOL',HEAD,84,(255,255,255),7)
l1,_=text_layer(line1,CAP,50,(255,255,255),5); l2,_=text_layer(line2,CAP,44,(255,220,170),4)
url,_=text_layer('pankitchen-redpanda.pages.dev',CAP,58,(255,255,255),6)
hd,_=text_layer('X: @PANKItCHeN_CHeN',CAP,58,GOLD,6)
for i in range(N):
t=i/FPS; c=bg.copy().convert('RGBA')
s=0.7+0.3*ease(min(1,t/0.6))+0.02*math.sin(t*4)
ci=coin.resize((int(760*s),int(760*s)))
glow=Image.new('RGBA',(W,H),(0,0,0,0)); gd=ImageDraw.Draw(glow); r=int(400*s)
gd.ellipse((W//2-r,640-r,W//2+r,640+r),fill=(255,120,20,120)); glow=glow.filter(ImageFilter.GaussianBlur(40))
c.alpha_composite(glow); c.alpha_composite(ci,((W-ci.width)//2,640-ci.height//2))
def put(img,y,t0):
k=ease(max(0,min(1,(t-t0)/0.3)))
if k<=0: return
im=img.copy(); im.putalpha(im.getchannel('A').point(lambda v:int(v*k))); c.alpha_composite(im,(0,y+int(30*(1-k))))
put(t1,90,0.1); put(t2,1060,0.3); put(l1,1200,0.6); put(l2,1340,0.8); put(url,1500,1.0); put(hd,1660,1.2)
e.stdin.write(c.convert('RGB').tobytes())
e.stdin.close(); e.wait()
if __name__=='__main__':
spec=json.load(open(sys.argv[1])); outdir=sys.argv[2]; os.makedirs(outdir,exist_ok=True)
only=sys.argv[3:]
for i,sc in enumerate(spec['scenes']):
if only and str(i) not in only: continue
p=f'{outdir}/s{i:02d}.mp4'
if sc.get('end'): endcard(p,sc['dur'],sc['l1'],sc['l2'])
else: scene(sc,p)
print('done',p,flush=True)
club.py · 230 lines · SHA-256 afbe1a7a74b77e2f0f9dadd9cdb59f0c696960e04c7ec051dbbb9c8c67f302d9
#!/usr/bin/env python3
"""ORIGINAL 128 BPM club banger, fully synthesized. Four-on-the-floor + club-trap hybrid.
Original F-minor progression (i - VII - VI - v) and an original lead motif. Nothing sampled or transcribed."""
import numpy as np, wave, sys, json, math
SR = 44100; BPM = 128.0; BEAT = 60 / BPM
rng = np.random.default_rng(128)
def midi(m): return 440.0 * 2 ** ((m - 69) / 12)
def fftf(x, kind, c, order=2):
n = len(x)
if n == 0: return x
nf = 1 << (n - 1).bit_length(); S = np.fft.rfft(x, nf); f = np.maximum(np.fft.rfftfreq(nf, 1 / SR), 1e-6)
if kind == 'lp': h = 1 / np.sqrt(1 + (f / c) ** (2 * order))
elif kind == 'hp': h = 1 / np.sqrt(1 + (c / f) ** (2 * order))
else: h = (1 / np.sqrt(1 + (c[0] / f) ** (2 * order))) * (1 / np.sqrt(1 + (f / c[1]) ** (2 * order)))
return np.fft.irfft(S * h, nf)[:n]
def tv_lp(x, cut_curve, frame=2048):
"""time-varying lowpass via overlap-add STFT, cut_curve per-sample (Hz)."""
n = len(x); hop = frame // 2; win = np.hanning(frame); out = np.zeros(n + frame); norm = np.zeros(n + frame)
xp = np.concatenate([x, np.zeros(frame)]); f = np.maximum(np.fft.rfftfreq(frame, 1 / SR), 1e-6)
for i in range(0, n, hop):
seg = xp[i:i + frame] * win; c = cut_curve[min(i + hop, n - 1)]
h = 1 / np.sqrt(1 + (f / c) ** 4)
out[i:i + frame] += np.fft.irfft(np.fft.rfft(seg) * h, frame) * win; norm[i:i + frame] += win ** 2
return out[:n] / np.maximum(norm[:n], 1e-3)
class Mix:
def __init__(s, dur): s.N = int(dur * SR); s.bus = {k: np.zeros((s.N, 2)) for k in ['drums', 'bass', 'synth', 'lead', 'fx']}
def add(s, bus, sig, t, g=1.0, pan=0.0):
i = int(round(t * SR))
if i >= s.N: return
sig = np.asarray(sig) * g
if sig.ndim == 1:
l = math.sqrt(0.5 * (1 - pan)) * math.sqrt(2); r = math.sqrt(0.5 * (1 + pan)) * math.sqrt(2)
sig = np.stack([sig * l, sig * r], 1)
if i < 0: sig = sig[-i:]; i = 0
j = min(s.N, i + len(sig)); s.bus[bus][i:j] += sig[:j - i]
# ---------- instruments ----------
def kick():
n = int(0.42 * SR); t = np.arange(n) / SR
f = 48 * (1 + 5.5 * np.exp(-t * 38)); body = np.sin(2 * np.pi * np.cumsum(f) / SR)
amp = (1 - np.exp(-t * 600)) * np.exp(-t * 7.5)
click = fftf(rng.standard_normal(n), 'bp', (1500, 9000)) * np.exp(-t * 120) * 0.35
k = np.tanh(body * amp * 1.6) * 0.9 + click
return k
def clap():
n = int(0.4 * SR); t = np.arange(n) / SR; base = fftf(rng.standard_normal(n), 'bp', (900, 8000)); s = np.zeros(n)
for d, g in [(0, 1), (0.011, 0.8), (0.022, 0.6), (0.034, 1.0)]:
k = int(d * SR); s[k:] += base[:n - k] * g * np.exp(-np.arange(n - k) / SR * (40 if d < 0.03 else 13))
snr = (np.sin(2 * np.pi * 200 * t) * np.exp(-t * 25)) * 0.4
return s * 0.8 + snr
def hat(op=False, vel=1.0):
n = int((0.25 if op else 0.05) * SR); t = np.arange(n) / SR
s = fftf(rng.standard_normal(n), 'hp', 7500); s = fftf(s, 'lp', 15000)
return s * np.exp(-t * (14 if op else 80)) * vel
def snare_roll_hit():
n = int(0.15 * SR); t = np.arange(n) / SR
return (fftf(rng.standard_normal(n), 'bp', (700, 7000)) + 0.5 * np.sin(2 * np.pi * 220 * t)) * np.exp(-t * 30)
def supersaw(freqs, dur, voices=5, det=0.16):
n = int(dur * SR); t = np.arange(n) / SR; out = np.zeros((n, 2))
for f in freqs:
for v in range(voices):
d = (v - (voices - 1) / 2) / ((voices - 1) / 2) * det
ff = f * 2 ** (d / 12); ph = rng.uniform(0, 1)
saw = 2 * ((ff * t + ph) % 1.0) - 1
pan = (v - (voices - 1) / 2) / ((voices - 1) / 2) * 0.8
out[:, 0] += saw * math.sqrt(0.5 * (1 - pan)); out[:, 1] += saw * math.sqrt(0.5 * (1 + pan))
return out / (len(freqs) * voices) * 2.2
def pluck(f, dur, bright=4000):
n = int((dur + 0.25) * SR); t = np.arange(n) / SR
s = sum((2 * ((f * k * t) % 1) - 1) * 0 + np.sin(2 * np.pi * f * k * t) / k ** 1.1 * np.exp(-t * (3 + k * 1.6)) for k in range(1, 10))
s += 0.5 * (2 * ((f * 1.005 * t) % 1.0) - 1) * np.exp(-t * 6)
e = np.minimum(1, t * 300) * np.exp(-t * 3.2)
return fftf(s * e, 'lp', bright)
def bass808(f, dur, glide_to=None):
n = int(dur * SR); t = np.arange(n) / SR
ff = np.full(n, f)
if glide_to:
g = int(min(0.12, dur * 0.5) * SR); ff[n - g:] = np.linspace(f, glide_to, g)
ff = ff * (1 + 0.8 * np.exp(-t * 40))
ph = 2 * np.pi * np.cumsum(ff) / SR
s = np.sin(ph) + 0.25 * np.sin(2 * ph)
s = np.tanh(s * 2.4) * 0.8 # distorted 808 grit
s = 0.6 * fftf(s, 'lp', 900) + 0.6 * fftf(np.sin(ph), 'lp', 110)
e = np.minimum(1, t * 400) * np.minimum(1, (dur - t) * 80)
return s * e
def reese(f, dur):
n = int(dur * SR); t = np.arange(n) / SR
s = (2 * ((f * t) % 1) - 1) + (2 * ((f * 1.007 * t + 0.3) % 1) - 1)
s = fftf(s, 'lp', 600) * np.minimum(1, t * 200) * np.minimum(1, (dur - t) * 60)
return s * 0.5
def riser(dur):
n = int(dur * SR); t = np.arange(n) / SR; u = t / dur
noise = rng.standard_normal(n)
s = tv_lp(noise, 300 + 14000 * u ** 2.2) * u ** 1.6
tone = np.sin(2 * np.pi * np.cumsum(200 * 2 ** (u * 3)) / SR) * 0.15 * u ** 2
return s * 0.6 + tone
def impact():
n = int(1.6 * SR); t = np.arange(n) / SR
f = 38 + 80 * np.exp(-t * 7); boom = np.sin(2 * np.pi * np.cumsum(f) / SR) * np.exp(-t * 2.4)
noise = fftf(rng.standard_normal(n), 'bp', (150, 5000)) * np.exp(-t * 6) * 0.5
return np.tanh((boom + noise) * 1.3)
def downlifter(dur=1.5):
n = int(dur * SR); t = np.arange(n) / SR; u = t / dur
return tv_lp(rng.standard_normal(n), 12000 * (1 - u) ** 2 + 200) * (1 - u) ** 1.5 * 0.5
# ---------- harmony (original) ----------
# F minor: Fm - Eb - Db - Cm (i VII VI v), 2 bars each => 8 bar loop
CH = [[53, 56, 60], [51, 55, 58], [49, 53, 56], [48, 51, 55]]
ROOT = [29, 27, 25, 24] # F1 Eb1 Db1 C1
# original lead motif in F minor pentatonic-ish, per 2-bar chord (in 16ths: (step, midi, len16))
LEAD = [
[(0, 72, 2), (3, 75, 1), (4, 77, 2), (6, 75, 1), (8, 72, 3), (12, 70, 2), (14, 72, 2), (16, 75, 3), (20, 77, 2), (24, 79, 4), (28, 77, 2), (30, 75, 2)],
[(0, 75, 2), (3, 74, 1), (4, 70, 2), (8, 67, 2), (10, 70, 2), (12, 74, 4), (16, 75, 2), (19, 74, 1), (20, 70, 3), (24, 72, 6)],
[(0, 73, 2), (3, 72, 1), (4, 68, 2), (6, 72, 2), (8, 77, 4), (12, 75, 2), (14, 73, 2), (16, 72, 3), (20, 68, 2), (24, 65, 3), (28, 68, 2), (30, 72, 2)],
[(0, 70, 3), (4, 72, 2), (6, 70, 1), (8, 67, 3), (12, 63, 2), (14, 67, 2), (16, 70, 4), (20, 72, 2), (22, 74, 2), (24, 79, 8)],
]
def build(sections, dur, impacts):
M = Mix(dur); S16 = BEAT / 4
def sec_at(b):
for a, e, k in sections:
if a <= b < e: return k, a, e
return 'outro', 0, 1
nbeats = int(dur / BEAT) + 1
kick_times = []
for b in range(nbeats):
t = b * BEAT; kind, a, e = sec_at(b)
bar = b // 4; chord_i = (bar // 2) % 4; inbar = b % 4
# --- drums ---
if kind in ('drop', 'groove'):
M.add('drums', kick(), t, 1.0); kick_times.append(t)
if inbar in (1, 3): M.add('drums', clap(), t, 0.55, 0.05)
M.add('drums', hat(True, 0.5), t + BEAT / 2, 0.5, 0.25)
for s in range(4):
if s % 2 == 1 or kind == 'drop':
M.add('drums', hat(False, 0.5 + 0.3 * (s % 2)), t + s * S16, 0.35, -0.2)
# club-trap hybrid: triplet hat roll at end of every 4th bar
if bar % 4 == 3 and inbar == 3:
for j in range(6): M.add('drums', hat(False, 0.6), t + j * BEAT / 6, 0.32, 0.15)
elif kind == 'intro':
if b >= 4: M.add('drums', kick(), t, 0.75); kick_times.append(t)
for s in (1, 2, 3): M.add('drums', hat(False, 0.7), t + s * S16, 0.42, -0.2)
if inbar in (1, 3) and b >= 8: M.add('drums', clap(), t, 0.35)
elif kind == 'build':
# accelerating snare roll + kick on quarters for first half
prog = (b - a) / max(1, (e - a))
if prog < 0.5: M.add('drums', kick(), t, 0.8); kick_times.append(t)
div = 2 if prog < 0.25 else 4 if prog < 0.6 else 8
for j in range(div): M.add('drums', snare_roll_hit(), t + j * BEAT / div, 0.25 + 0.45 * prog, 0.0)
elif kind == 'break':
if inbar == 0 and bar % 2 == 0: M.add('drums', kick(), t, 0.6); kick_times.append(t)
M.add('drums', hat(False, 0.6), t + BEAT / 2, 0.38)
if inbar == 2: M.add('drums', clap(), t, 0.3)
elif kind == 'outro':
if b < e - 2: M.add('drums', kick(), t, 0.85); kick_times.append(t)
if inbar in (1, 3) and b < e - 2: M.add('drums', clap(), t, 0.45)
# --- bass ---
r = ROOT[chord_i]
if kind == 'drop':
# pumping offbeat 808 + glides at chord change
nxt = ROOT[((bar + 1) // 2) % 4]
glide = midi(nxt) if (bar % 2 == 1 and inbar == 3) else None
M.add('bass', bass808(midi(r + 12), BEAT * 0.48, glide_to=midi(nxt + 12) if glide else None), t + BEAT / 2, 0.85)
if inbar == 0: M.add('bass', bass808(midi(r), BEAT * 0.45), t, 0.6)
elif kind == 'groove':
M.add('bass', reese(midi(r + 12), BEAT * 0.45), t + BEAT / 2, 0.8)
if inbar in (0, 2): M.add('bass', bass808(midi(r), BEAT * 0.4), t, 0.55)
elif kind == 'outro' and b < e - 2:
M.add('bass', reese(midi(r + 12), BEAT * 0.45), t + BEAT / 2, 0.6)
# --- chords (per bar) ---
if inbar == 0:
fr = [midi(m) for m in CH[chord_i]] + [midi(CH[chord_i][0] + 12)]
if kind in ('drop', 'groove', 'outro'):
for q in range(4): # stabs on offbeats (sidechained further later)
M.add('synth', supersaw(fr, BEAT * 0.45), t + q * BEAT + BEAT / 2, 0.55 if kind == 'drop' else 0.45)
elif kind in ('intro', 'break', 'build'):
pad = supersaw(fr, 4 * BEAT, voices=7, det=0.22)
cut = 2600 if kind != 'build' else 4000
pad[:, 0] = fftf(pad[:, 0], 'lp', cut); pad[:, 1] = fftf(pad[:, 1], 'lp', cut)
env = np.minimum(1, np.arange(len(pad)) / (0.2 * SR))[:, None]
M.add('synth', pad * env, t, 1.15 if kind != 'build' else 0.9)
# --- lead ---
if kind == 'drop' and inbar == 0 and bar % 2 == 0:
for (st, m, ln) in LEAD[chord_i]:
M.add('lead', pluck(midi(m), ln * S16), t + st * S16, 0.32, 0.1)
M.add('lead', pluck(midi(m + 12), ln * S16, 6000), t + st * S16 + 0.003, 0.08, -0.3)
if kind == 'break' and inbar == 0 and bar % 2 == 0:
for (st, m, ln) in LEAD[chord_i][::2]:
M.add('lead', pluck(midi(m), ln * S16 * 2, 3500), t + st * S16, 0.45, 0.0)
# --- FX ---
for a, e, k in sections:
if k == 'build':
d = (e - a) * BEAT; M.add('fx', riser(d), a * BEAT, 0.55)
if k in ('drop',):
M.add('fx', impact(), a * BEAT, 0.8); M.add('fx', downlifter(), a * BEAT, 0.6)
if k == 'break':
M.add('fx', downlifter(2.0), a * BEAT, 0.5)
for t in impacts: M.add('fx', impact(), t, 0.7)
# --- sidechain pump from kicks ---
N = M.N; env = np.zeros(N); L = int(0.42 * SR); tt = np.arange(L) / SR
shape = np.clip(1 - tt / 0.30, 0, 1) ** 2
for kt in kick_times:
i = int(kt * SR); j = min(N, i + L)
if i < N: env[i:j] = np.maximum(env[i:j], shape[:j - i])
duck_heavy = (1 - 0.85 * env)[:, None]; duck_mid = (1 - 0.55 * env)[:, None]
M.bus['bass'] *= duck_heavy; M.bus['synth'] *= duck_heavy; M.bus['lead'] *= duck_mid
# bus processing
for k in ('synth', 'lead'):
for c in (0, 1): M.bus[k][:, c] = fftf(M.bus[k][:, c], 'hp', 180)
# simple stereo delay on lead
d = int(BEAT * 0.75 * SR); lead = M.bus['lead']; dl = np.zeros_like(lead)
dl[d:, 0] = lead[:-d, 1] * 0.35; dl[d:, 1] = lead[:-d, 0] * 0.35
M.bus['lead'] = lead + fftf(dl[:, 0], 'lp', 5000)[:, None] * np.array([1, 0]) + fftf(dl[:, 1], 'lp', 5000)[:, None] * np.array([0, 1])
g = {'drums': 0.9, 'bass': 0.85, 'synth': 0.5, 'lead': 0.75, 'fx': 0.6}
mix = sum(M.bus[k] * g[k] for k in g)
for c in (0, 1): mix[:, c] = fftf(mix[:, c], 'hp', 28)
mix = mix / (np.max(np.abs(mix)) + 1e-9) * 0.5
fo = int(1.2 * SR); mix[-fo:] *= np.linspace(1, 0, fo)[:, None]
return mix
if __name__ == '__main__':
spec = json.load(open(sys.argv[1])); out = sys.argv[2]
mix = build([tuple(s) for s in spec['sections']], spec['dur'], spec.get('impacts', []))
d = (np.clip(mix, -1, 1) * 32767).astype(np.int16)
w = wave.open(out, 'wb'); w.setnchannels(2); w.setsampwidth(2); w.setframerate(SR); w.writeframes(d.tobytes()); w.close()
print('wrote', out, 'peak', 20 * np.log10(np.max(np.abs(mix))))
master.py · 16 lines · SHA-256 841ee4ca1fe00c4015c87fe9d11708315765ba91d64059827432027d533fdb29
import wave, numpy as np, sys, json
B = 60 / float(__import__("os").environ.get("BPM", "128"))
inp, out, spec = sys.argv[1], sys.argv[2], json.load(open(sys.argv[3]))
w = wave.open(inp); sr = w.getframerate(); x = np.frombuffer(w.readframes(w.getnframes()), dtype=np.int16).reshape(-1, 2) / 32768
GAIN = json.loads(__import__('os').environ.get('GAINS', '{"intro": 6.0, "break": 8.5, "build": 4.5, "outro": 4.0, "groove": 2.5, "drop": 0.0}'))
g = np.zeros(len(x))
for a, e, k in spec['sections']:
i, j = int(a * B * sr), min(len(x), int(e * B * sr))
if k == 'build': # ramp up to the drop for extra lift
g[i:j] = np.linspace(GAIN['build'] - 2, GAIN['build'] + 1, j - i)
else:
g[i:j] = GAIN[k]
k = int(0.08 * sr); g = np.convolve(g, np.ones(k) / k, mode='same')
y = x * (10 ** (g / 20))[:, None]
y = y / np.max(np.abs(y)) * 0.5
d = (y * 32767).astype(np.int16); o = wave.open(out, 'wb'); o.setnchannels(2); o.setsampwidth(2); o.setframerate(sr); o.writeframes(d.tobytes()); o.close()
Proof of Panda blueprint (code-drawn)
The 6-page large-print blueprint is drawn by a Python script, make_blueprint.py, which reads specs.json (computed by specs.py) and writes one SVG per page; the 300 dpi PNGs and the PDF are rendered from the SVGs. The calculations use the U.S. Mint's published half-dollar and 1/2 oz American Gold Eagle specifications and an assumed 22K rose gold alloy density of 17.7 g/cm3 (see the plan PDF for sources and assumptions). Source folder: /workspace/proof-of-panda/blueprint. The scripts are reproduced below.
specs.py · 21 lines · SHA-256 4bd53b88b17711aacef09a3a238f828dc43c367d1578af54ab415efe464505f7
import math, json
TROY=31.1034768
FINE=0.5*TROY; K22=11/12; TOTAL=FINE/K22
RHO=17.7 # nominal, 22K rose gold (91.67 Au / ~8.3 Cu, small Ag) ; range 17.6-17.8
def area(d): return math.pi*(d/2)**2
def flat_t(m,rho,d): return m/rho*1000/area(d)
def profile(d,t_rim,rim_w,cov=0.40,mean_relief=0.12,rho=RHO):
V=TOTAL/rho*1000; ri=d/2-rim_w
Vrim=math.pi*((d/2)**2-ri**2)*t_rim; Ain=math.pi*ri**2
tf=(V-Vrim-2*Ain*cov*mean_relief)/Ain; rec=(t_rim-tf)/2
return dict(diameter=d,rim_width=rim_w,rim_thickness=t_rim,field_thickness=round(tf,2),recess_per_side=round(rec,2),
max_relief=round(min(rec-0.05,0.30),2),volume_mm3=round(V,1),
flat_t=round(flat_t(TOTAL,rho,d),2),flat_t_lo=round(flat_t(TOTAL,17.8,d),2),flat_t_hi=round(flat_t(TOTAL,17.6,d),2),
area=round(area(d),1))
s=dict(fine_g=round(FINE,3),total_g=round(TOTAL,3),rho=RHO)
s['A']=profile(30.61,1.60,1.00); s['B']=profile(27.00,2.15,1.10)
s['solid_30.61x2.15_g']=round(area(30.61)*2.15/1000*RHO,1); s['solid_30.61x2.15_fine_ozt']=round(s['solid_30.61x2.15_g']*K22/TROY,2)
s['pitch_A']=round(math.pi*30.61/150,3); s['pitch_B']=round(math.pi*27/132,3)
s['rho_calc_pure_Au_Cu']=round(1/(0.9167/19.32+0.0833/8.96),2)
s['spot']=3594.20; s['value']=round(0.5*3594.20,2)
print(json.dumps(s,indent=1)); json.dump(s,open('specs.json','w'),indent=1)
specs.json · 38 lines · SHA-256 bbb353e422fc3ce92d1bdb05bf0a0928c97833ac2c3224747e90862c5733a59c
{
"fine_g": 15.552,
"total_g": 16.966,
"rho": 17.7,
"A": {
"diameter": 30.61,
"rim_width": 1.0,
"rim_thickness": 1.6,
"field_thickness": 1.16,
"recess_per_side": 0.22,
"max_relief": 0.17,
"volume_mm3": 958.5,
"flat_t": 1.3,
"flat_t_lo": 1.3,
"flat_t_hi": 1.31,
"area": 735.9
},
"B": {
"diameter": 27.0,
"rim_width": 1.1,
"rim_thickness": 2.15,
"field_thickness": 1.49,
"recess_per_side": 0.33,
"max_relief": 0.28,
"volume_mm3": 958.5,
"flat_t": 1.67,
"flat_t_lo": 1.66,
"flat_t_hi": 1.68,
"area": 572.6
},
"solid_30.61x2.15_g": 28.0,
"solid_30.61x2.15_fine_ozt": 0.83,
"pitch_A": 0.641,
"pitch_B": 0.643,
"rho_calc_pure_Au_Cu": 17.62,
"spot": 3594.2,
"value": 1797.1
}
make_blueprint.py · 181 lines · SHA-256 ad4ac6a986b555f208d5b70e2f70ce4975b2f2c0556be7385bb883a760205842
import json, math, base64, cairosvg, subprocess
S=json.load(open('specs.json')); A=S['A']; B=S['B']
W,H=279.4,215.9
INK='#111111'; DIM='#0a3d91'; ACC='#a8421a'; GR='#c9c9c9'
FONT='Liberation Sans'
class Page:
def __init__(s,title,sub=None,n=1,total=6):
s.o=[]; s.n=n
s.a(f'<svg xmlns="http://www.w3.org/2000/svg" width="{W}mm" height="{H}mm" viewBox="0 0 {W} {H}">')
s.a(f'<rect width="{W}" height="{H}" fill="#ffffff"/>')
s.a(f'<rect x="6" y="6" width="{W-12}" height="{H-12}" fill="none" stroke="{INK}" stroke-width="0.8"/>')
s.t(12,20,title,8.5,'start',INK,'bold')
if sub: s.t(12,28,sub,5.2,'start','#444')
s.t(W-12,H-10,f'Page {n} of {total} · all dimensions in millimetres',4.6,'end','#444')
s.t(12,H-10,'Concept drawing for mint quotes · 22K rose gold round · Rev A',4.6,'start','#444')
def a(s,x): s.o.append(x)
def t(s,x,y,txt,size,anchor='start',fill=INK,weight='normal',family=FONT,extra=''):
txt=txt.replace('&','&').replace('<','<')
s.a(f'<text x="{x:.2f}" y="{y:.2f}" font-family="{family}" font-size="{size}" fill="{fill}" text-anchor="{anchor}" font-weight="{weight}" {extra}>{txt}</text>')
def line(s,x1,y1,x2,y2,c=INK,w=0.4,dash=None):
d=f' stroke-dasharray="{dash}"' if dash else ''
s.a(f'<line x1="{x1:.2f}" y1="{y1:.2f}" x2="{x2:.2f}" y2="{y2:.2f}" stroke="{c}" stroke-width="{w}"{d}/>')
def circ(s,cx,cy,r,c=INK,w=0.5,dash=None,fill='none'):
d=f' stroke-dasharray="{dash}"' if dash else ''
s.a(f'<circle cx="{cx:.2f}" cy="{cy:.2f}" r="{r:.2f}" stroke="{c}" stroke-width="{w}" fill="{fill}"{d}/>')
def arrowhead(s,x,y,ang,c=DIM,L=3.2):
for sg in (0.3,-0.3): s.line(x,y,x+L*math.cos(ang+sg),y+L*math.sin(ang+sg),c,0.5)
def dim(s,x1,y1,x2,y2,label,size=7,off=-2.5,c=DIM,anchor='middle'):
s.line(x1,y1,x2,y2,c,0.5)
ang=math.atan2(y2-y1,x2-x1); s.arrowhead(x1,y1,ang,c); s.arrowhead(x2,y2,ang+math.pi,c)
if label: s.t((x1+x2)/2,(y1+y2)/2+off,label,size,anchor,c,'bold')
def photo(s,cx,cy,r,f,cid,op=0.45):
b=base64.b64encode(open(f,'rb').read()).decode()
s.a(f'<clipPath id="{cid}"><circle cx="{cx}" cy="{cy}" r="{r}"/></clipPath>')
s.a(f'<image href="data:image/jpeg;base64,{b}" x="{cx-r}" y="{cy-r}" width="{2*r}" height="{2*r}" opacity="{op}" clip-path="url(#{cid})"/>')
def coin(s,cx,cy,P,k,f,cid):
R=P['diameter']/2*k; Ri=R-P['rim_width']*k
s.photo(cx,cy,R*0.985,f,cid)
s.circ(cx,cy,R,INK,0.9); s.circ(cx,cy,Ri,INK,0.5)
s.line(cx-R-8,cy,cx+R+8,cy,ACC,0.3,'6 2 1 2'); s.line(cx,cy-R-8,cx,cy+R+8,ACC,0.3,'6 2 1 2')
return R,Ri
def save(s,name):
s.a('</svg>'); open(name+'.svg','w').write('\n'.join(s.o))
pages=[]
# ---- Page 1: obverse + dimensions
p=Page('FRONT (OBVERSE) · DIAMETER','Option B (recommended). Front: Red Panda art in relief with hard-enamel color fill; letters P.O.P.',1)
cx,cy,k=92,112,4.9
R,Ri=p.coin(cx,cy,B,k,'_obv.jpg','c1')
p.dim(cx-R,cy+R+13,cx+R,cy+R+13,'Ø 27.00 ±0.05',8.5,-3)
p.line(cx-R,cy+R+14,cx-R,cy+R-6,DIM,0.3,'1 1'); p.line(cx+R,cy+R+14,cx+R,cy+R-6,DIM,0.3,'1 1')
# right panel callouts
px=192
p.t(px,60,'DIAMETER',5.2,'start','#444','bold'); p.t(px,72,'27.00 mm',10,'start',DIM,'bold'); p.t(px,80,'tolerance ±0.05',5.2)
p.t(px,102,'RIM WIDTH',5.2,'start','#444','bold'); p.t(px,114,'1.10 mm',10,'start',DIM,'bold')
p.line(cx+Ri*0.866,cy-Ri*0.5,px-3,111,ACC,0.4); p.circ(cx+Ri*0.866,cy-Ri*0.5,0.9,ACC,0.4,None,ACC)
p.t(px,134,'EDGE',5.2,'start','#444','bold'); p.t(px,146,'Reeded',10,'start',DIM,'bold'); p.t(px,154,'132 reeds',5.2)
p.t(px,170,'FRONT LETTERING',5.2,'start','#444','bold'); p.t(px,180,'P.O.P',9,'start',DIM,'bold'); p.t(px,194,'Print at 100% for true size',5.2,'start',ACC,'bold')
p.save('page1'); pages.append('page1')
# ---- Page 2: reverse + cross-section
p=Page('BACK (REVERSE) AND CROSS-SECTION','Option B. Back face: only "1/2 OZ" and "22KT GOLD", plain field.',2)
cx,cy,k=62,84,2.6
R,Ri=p.coin(cx,cy,B,k,'_rev.jpg','c2')
p.t(cx+R+9,cy-6,'A',8,'middle',ACC,'bold'); p.t(cx-R-9,cy-6,'A',8,'middle',ACC,'bold')
p.t(150,48,'Cross-section A–A is drawn below at 20:1.',5.2,'start','#444')
p.t(150,62,'Back lettering:',5.2,'start','#444','bold')
p.t(150,72,'1/2 OZ',9,'start',INK,'bold'); p.t(150,84,'22KT GOLD',9,'start',INK,'bold')
# cross-section (outer 8 mm of radius at 20:1)
k=20; Rr=13.5; L=8.0; x0=18; y0=176
X=lambda r:x0+(r-(Rr-L))*k; Y=lambda z:y0-z*k
tr=B['rim_thickness']; tf=B['field_thickness']; rw=B['rim_width']; rel=B['max_relief']
top=[(X(Rr-L),Y(tf/2+rel*0.6))]
for i in range(5):
r1=Rr-L+i*1.0+0.3; top+=[(X(r1),Y(tf/2+rel*0.5)),(X(r1+0.35),Y(tf/2+rel)),(X(r1+0.7),Y(tf/2+rel*0.5))]
top+=[(X(Rr-rw-0.4),Y(tf/2)),(X(Rr-rw),Y(tr/2)),(X(Rr-0.2),Y(tr/2)),(X(Rr),Y(tr/2-0.2))]
bot=[(X(Rr),Y(-tr/2+0.2)),(X(Rr-0.2),Y(-tr/2)),(X(Rr-rw),Y(-tr/2)),(X(Rr-rw-0.4),Y(-tf/2))]
for i in reversed(range(5)):
r1=Rr-L+i*1.0+0.3; bot+=[(X(r1+0.7),Y(-tf/2-rel*0.5)),(X(r1+0.35),Y(-tf/2-rel)),(X(r1),Y(-tf/2-rel*0.5))]
bot.append((X(Rr-L),Y(-tf/2-rel*0.6)))
pts=top+bot
p.a('<path d="M '+' L '.join(f'{a:.2f},{b:.2f}' for a,b in pts)+f' Z" fill="#e8b49a" stroke="{INK}" stroke-width="0.7"/>')
p.line(X(Rr-L)-4,y0,X(Rr)+6,y0,ACC,0.3,'6 2 1 2')
# dims
xe=X(Rr)+9; p.dim(xe,Y(tr/2),xe,Y(-tr/2),'',7); p.line(X(Rr)+0.5,Y(tr/2),xe+3,Y(tr/2),DIM,0.3); p.line(X(Rr)+0.5,Y(-tr/2),xe+3,Y(-tr/2),DIM,0.3)
p.t(xe+6,y0+3,'2.15',9,'start',DIM,'bold'); p.t(xe+6,y0+10,'rim thickness',5.2)
xf=X(Rr-L)+14; p.dim(xf,Y(tf/2),xf,Y(-tf/2),'',7)
p.t(xf+5,y0+3,'1.49',8,'start',DIM,'bold'); p.t(xf+5,y0+10,'field',5.2)
p.dim(X(Rr-rw),Y(tr/2)-8,X(Rr),Y(tr/2)-8,'',7); p.line(X(Rr-rw),Y(tr/2)-1,X(Rr-rw),Y(tr/2)-11,DIM,0.3); p.line(X(Rr),Y(tr/2)-1,X(Rr),Y(tr/2)-11,DIM,0.3)
p.t(X(Rr-rw/2),Y(tr/2)-13,'1.10 rim width',5.2,'end',DIM,'bold')
p.t(x0,Y(tr/2)-20,'Relief 0.28 max per side',5.2,'start',INK,'bold')
p.save('page2'); pages.append('page2')
# ---- Page 3: Option A
p=Page('OPTION A · HALF-DOLLAR DIAMETER','Same weight in a 30.61 mm round. Thin and easy to bend: not recommended.',3)
cx,cy,k=88,124,4.3
R,Ri=p.coin(cx,cy,A,k,'_obv.jpg','c3')
p.dim(cx-R,cy+R+12,cx+R,cy+R+12,'Ø 30.61 ±0.05',8.5,-3)
p.line(cx-R,cy+R+13,cx-R,cy+R-6,DIM,0.3,'1 1'); p.line(cx+R,cy+R+13,cx+R,cy+R-6,DIM,0.3,'1 1')
px=180
p.t(px,56,'DIAMETER',5.2,'start','#444','bold'); p.t(px,68,'30.61 mm',10,'start',DIM,'bold')
p.t(px,92,'RIM THICKNESS',5.2,'start','#444','bold'); p.t(px,104,'1.60 mm',10,'start',DIM,'bold')
p.t(px,128,'THICKNESS IF FLAT',5.2,'start','#444','bold'); p.t(px,140,'about 1.30 mm',10,'start',DIM,'bold'); p.t(px,148,'(17.7 g/cm³ alloy)',5.2)
p.t(px,168,'EDGE',5.2,'start','#444','bold'); p.t(px,180,'Reeded, 150 reeds',7.5,'start',DIM,'bold')
p.save('page3'); pages.append('page3')
# ---- Page 4: specs table
p=Page('SPECIFICATIONS','Option B is recommended. Option A shown for comparison.',4)
rows=[('','OPTION B','OPTION A'),
('Diameter','27.00 mm','30.61 mm'),
('Rim thickness','2.15 mm','1.60 mm'),
('Field thickness','1.49 mm','1.16 mm'),
('Max relief per side','0.28 mm','0.17 mm'),
('Edge','132 reeds','150 reeds'),
('Total weight','16.966 g','16.966 g'),
('Fine gold','15.552 g = 1/2 ozt','15.552 g = 1/2 ozt'),
('Metal','22K rose gold','22K rose gold'),
('Fineness','916.7 (91.67% Au)','916.7 (91.67% Au)'),
('Alloy (suggested)','Au 91.67, Cu ~8, Ag trace','same'),
('Density used','17.7 g/cm³ (17.6–17.8)','same'),
('Color','Hard enamel in recessed cells','same')]
x0,y0,rh=12,36,11.9; cw=[78,92,84]
for i,r in enumerate(rows):
y=y0+i*rh
if i==0: p.a(f'<rect x="{x0}" y="{y}" width="{sum(cw)}" height="{rh}" fill="#111"/>')
elif i%2==0: p.a(f'<rect x="{x0}" y="{y}" width="{sum(cw)}" height="{rh}" fill="#f1e3da"/>')
xx=x0+3
for j,c in enumerate(r):
col='#fff' if i==0 else (INK if j==0 else DIM)
p.t(xx,y+rh*0.68,c,5.4 if j==0 or i==0 else 5.6,'start',col,'bold' if (j>0 or i==0) else 'normal')
xx+=cw[j]
p.a(f'<rect x="{x0}" y="{y0}" width="{sum(cw)}" height="{rh*len(rows)}" fill="none" stroke="{INK}" stroke-width="0.7"/>')
p.save('page4'); pages.append('page4')
# ---- Page 5: calculation
p=Page('HOW THE NUMBERS WORK','Every figure on the previous pages comes from these steps.',5)
L=['Fine gold: 0.5 troy oz × 31.1035 g = 15.552 g',
'22K = 22 ÷ 24 = 91.67% gold (916.7 fine)',
'Total weight: 15.552 g ÷ 0.9167 = 16.966 g',
'Same weight as the U.S. 1/2 oz Gold Eagle (27.00 mm).',
'',
'Density of 22K rose gold: about 17.7 g/cm³ (assumed;',
'pure Au + Cu works out to 17.6; silver raises it a little).',
'Volume: 16.966 g ÷ 17.7 = 0.958 cm³ = 958 mm³',
'',
'Ø 27.00 mm: face 572.6 mm² → flat disk 1.67 mm thick.',
'Ø 30.61 mm: face 735.9 mm² → flat disk 1.30 mm thick.',
'A solid 30.61 × 2.15 mm disk would weigh about 28 g.',
'That is why a half-dollar-size 1/2 oz round must be thin.',
'Reference: U.S. half dollar 30.61 mm × 2.15 mm, 150 reeds',
'(U.S. Mint). Final blank weight is set by the mint.']
for i,l in enumerate(L): p.t(14,44+i*9.8,l,5.4,'start',INK,'bold' if i in (0,1,2) else 'normal')
p.save('page5'); pages.append('page5')
# ---- Page 6: production notes
p=Page('PRODUCTION NOTES','What to tell a mint.',6)
L=['1. Mints STRIKE coins: a weighed blank is pressed between steel',
' dies inside a reeded collar. Coins are not poured into molds.',
'2. Poured gold means cast bars: softer detail, no mirror fields.',
'3. Rose gold: ask each mint if it stocks 22K rose-gold blanks.',
' Many hold only 24K or 22K yellow blanks. A custom alloy',
' may add a melt charge and a larger minimum.',
'4. Proof finish: mirror fields and frosted relief.',
'5. Marks: fineness stamp plus the mint’s registered maker mark.',
'6. Do not copy any U.S. coin design. No face value.',
'7. Option B (27.00 × 2.15 mm) is the proven 1/2 oz format.',
'8. Color: hard (vitreous) enamel is fired into recessed cells on the',
' front, and optionally the back, in true colors: russet orange, white,',
' black, dark brown and green. Raised polished gold lines separate the',
' colors. Enamel adds negligible weight (well under 0.1 g); the gold',
' content (1/2 ozt) and total gold weight are unchanged. Ask the mint',
' about enamel colors, cost and minimums.',
'9. Not legal tender. The $PoP token is not backed by gold.']
for i,l in enumerate(L): p.t(14,42+i*8.9,l,5.4,'start',INK,'bold' if l[:2] in ('1.','3.','7.') else 'normal')
p.save('page6'); pages.append('page6')
for n in pages:
cairosvg.svg2pdf(url=n+'.svg',write_to=n+'.pdf')
cairosvg.svg2png(url=n+'.svg',write_to=f'pop-blueprint-{n}-300dpi.png',output_width=3300)
subprocess.run(['pdfunite']+[n+'.pdf' for n in pages]+['pop-blueprint.pdf'],check=True)
print('ok')