"""Herring-gull-ish cry: a few nasal 'kyow' calls, each a buzzy harmonic tone whose pitch jumps up and slides down, through two formants, then a quick 'ha-ha-ha'. 44.1 kHz mono 16-bit. Run with local/hear-venv python. Claude Opus 5.5 (Tessel).""" import os, wave import numpy as np SR = 44100 rng = np.random.default_rng(3) def call(dur, f0s, f0e, peak=0.25, rough=0.25): n = int(SR * dur); t = np.arange(n) / SR; u = t / dur # pitch: quick rise to peak, then a slide down f = np.where(u < peak, f0s + (f0e * 1.25 - f0s) * (u / peak), f0e * 1.25 - (f0e * 0.5) * ((u - peak) / (1 - peak))) f = f * (1 + 0.012 * np.sin(2 * np.pi * 31 * t)) # slight wobble ph = 2 * np.pi * np.cumsum(f) / SR x = sum((1.0 / k ** 0.9) * np.sin(k * ph) for k in range(1, 14)) # bright, buzzy x *= 1 + rough * np.sin(2 * np.pi * 70 * t) # rasp env = np.minimum(1, u / 0.06) * np.minimum(1, (1 - u) / 0.25) ** 1.5 return x * env def formant(x, fc, bw): # simple 2-pole resonator r = np.exp(-np.pi * bw / SR); th = 2 * np.pi * fc / SR a1, a2 = -2 * r * np.cos(th), r * r y = np.zeros_like(x) for i in range(2, len(x)): y[i] = x[i] - a1 * y[i - 1] - a2 * y[i - 2] return y def gap(s): return np.zeros(int(SR * s)) parts = [call(0.42, 900, 1500, 0.2), gap(0.12), call(0.36, 950, 1450, 0.22), gap(0.10), call(0.30, 900, 1350, 0.25), gap(0.16)] for _ in range(4): parts += [call(0.11, 1100, 1200, 0.4, 0.4), gap(0.05)] x = np.concatenate(parts) y = formant(x, 1800, 500) * 0.6 + formant(x, 3200, 900) * 0.4 y += rng.standard_normal(len(y)) * 0.004 * np.abs(y).max() y /= np.abs(y).max(); y *= 0.85 out = os.path.join(os.path.dirname(os.path.abspath(__file__)), "cry.wav") with wave.open(out, "wb") as w: w.setnchannels(1); w.setsampwidth(2); w.setframerate(SR) w.writeframes((y * 32767).astype("