Skip to content

howseen-ai/claude-motion-design / skill/motion-design

motion-design

Verified

scripts/analyze_song.py

View on GitHub
"""Estimate BPM (onset autocorrelation) and print a 1-second energy profile (full + low band) for each file."""
import subprocess, sys
import numpy as np, imageio_ffmpeg
FF, SR = imageio_ffmpeg.get_ffmpeg_exe(), 22050
for f in sys.argv[1:]:
    x = np.frombuffer(subprocess.run([FF, "-v", "quiet", "-i", f, "-ac", "1", "-ar", str(SR), "-f", "f32le", "-"], capture_output=True).stdout, np.float32)
    hop = 256; fr = len(x) // hop
    env = np.array([np.sqrt((x[i * hop:(i + 1) * hop] ** 2).mean()) for i in range(fr)])
    on = np.maximum(0, np.diff(np.log(env + 1e-6))); on -= on.mean()
    ac = np.correlate(on[:6000], on[:6000], "full")[5999:]
    fps = SR / hop; lags = np.arange(len(ac)) / fps
    best = max(((60 / l, ac[i]) for i, l in enumerate(lags) if 0.33 < l < 1.0), key=lambda z: z[1])
    print(f"\n== {f.split('/')[-1]}  dur {len(x) / SR:.1f}s  BPM~{best[0]:.1f}")
    lp = np.convolve(x, np.ones(60) / 60, "same")
    row = []
    for s in range(0, int(len(x) / SR)):
        seg = x[s * SR:(s + 1) * SR]; ls = lp[s * SR:(s + 1) * SR]
        row.append(f"{s:3d}:{10 * np.log10((seg ** 2).mean() + 1e-12):5.1f}/{10 * np.log10((ls ** 2).mean() + 1e-12):5.1f}")
    for i in range(0, min(len(row), 48), 6): print("  " + "  ".join(row[i:i + 6]))
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall