A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date. Images, audio, models and binaries go through Git LFS (.gitattributes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
120 lines
4.1 KiB
Python
120 lines
4.1 KiB
Python
"""GRASS CUTTER sounds → Assets/Audio (same file names the code already plays).
|
|
|
|
Mowing comes from the ElevenLabs candidates (eleven_batch_grass.sh); the rest is re-used from the old library or
|
|
synthesised here (meadow wind + crickets, rustling thumps into grass, clippings pouring, a crisp snip).
|
|
"""
|
|
import os
|
|
|
|
import numpy as np
|
|
|
|
import master as M
|
|
from finalize import seg
|
|
from master import SR
|
|
|
|
AUDIO = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "Assets", "Audio")
|
|
rng = np.random.default_rng(420)
|
|
|
|
|
|
def m(name):
|
|
return M.mono(M.raw(name))
|
|
|
|
|
|
def lib(name):
|
|
return M.mono(M.load(os.path.join(AUDIO, name + ".wav")))
|
|
|
|
|
|
def noise(sec):
|
|
return rng.standard_normal(int(sec * SR))
|
|
|
|
|
|
def band(x, lo, hi):
|
|
return M.lowpass(M.highpass(x, lo), hi)
|
|
|
|
|
|
def env(n, attack, decay):
|
|
t = np.arange(n) / SR
|
|
return np.minimum(1.0, t / max(1e-4, attack)) * np.exp(-t / decay)
|
|
|
|
|
|
def rustle(sec, density=60.0, lo=1800, hi=7000):
|
|
"""Papery grass rustle: band-passed noise chopped into many tiny grains."""
|
|
x = band(noise(sec), lo, hi)
|
|
g = np.zeros_like(x)
|
|
n = int(sec * density)
|
|
for _ in range(n):
|
|
p = rng.integers(0, len(x) - 800)
|
|
L = rng.integers(200, 800)
|
|
g[p:p + L] += np.hanning(L) * rng.uniform(0.3, 1.0)
|
|
return x * (0.25 + g)
|
|
|
|
|
|
def thud(sec, f0=70.0, decay=0.08):
|
|
t = np.arange(int(sec * SR)) / SR
|
|
f = f0 * (1 + 0.6 * np.exp(-t / 0.02))
|
|
return np.sin(2 * np.pi * np.cumsum(f) / SR) * np.exp(-t / decay)
|
|
|
|
|
|
def resample(x, factor):
|
|
idx = np.arange(0, len(x) - 1, factor)
|
|
return np.interp(idx, np.arange(len(x)), x)
|
|
|
|
|
|
def grass_hit(big):
|
|
sec = 1.1 if big else 0.55
|
|
r = rustle(sec, density=140 if big else 90, lo=1200 if big else 1800) * env(int(sec * SR), 0.004, 0.22 if big else 0.1)
|
|
th = thud(sec, 55 if big else 85, 0.14 if big else 0.06) * (0.9 if big else 0.55)
|
|
return M.fade(r * 0.8 + th, 1, 60)
|
|
|
|
|
|
def meadow(sec=14.0):
|
|
# wind: slow swells of low band noise
|
|
w = band(noise(sec), 120, 900)
|
|
t = np.arange(len(w)) / SR
|
|
swell = 0.55 + 0.45 * np.sin(2 * np.pi * t / 6.3) * np.sin(2 * np.pi * t / 2.9 + 1.0)
|
|
out = w * swell * 0.5 + rustle(sec, 25, 2500, 8000) * swell * 0.18
|
|
# crickets: bursts of three fast chirps at ~4.4 kHz
|
|
for _ in range(int(sec * 1.3)):
|
|
p = rng.uniform(0.1, sec - 0.5)
|
|
f = rng.uniform(4100, 4800)
|
|
amp = rng.uniform(0.05, 0.14)
|
|
for k in range(3):
|
|
s = int((p + k * 0.045) * SR)
|
|
L = int(0.028 * SR)
|
|
tt = np.arange(L) / SR
|
|
out[s:s + L] += np.sin(2 * np.pi * f * tt) * np.hanning(L) * amp
|
|
return out
|
|
|
|
|
|
def snip():
|
|
sec = 0.25
|
|
r = rustle(sec, 200, 3000, 9000) * env(int(sec * SR), 0.001, 0.035)
|
|
click = band(noise(sec), 2500, 9000) * env(int(sec * SR), 0.0005, 0.006)
|
|
return M.fade(r + click * 1.5, 0, 30)
|
|
|
|
|
|
def main():
|
|
# mowing tools
|
|
cut = M.highpass(m("gc_cut_loop_0.wav"), 60)
|
|
M.write("suck_loop", M.loop_xfade(seg(cut, 0.6, 4.4), 0.35), -8)
|
|
M.write("suck_start", M.clean(m("gc_cut_start_0.wav"), start_db=-30, tail_db=-46, max_len=0.9, fout_ms=120), -6)
|
|
M.write("suck_stop", M.clean(m("gc_cut_stop_0.wav"), start_db=-30, tail_db=-46, max_len=0.9, fout_ms=150), -7)
|
|
# engines: the old road-roller engine, a bit faster, is a fine ride-on mower; the sweeper brush is an edge mower
|
|
M.write("mower_engine_loop", M.loop_xfade(resample(lib("roller_engine_loop"), 1.12), 0.3), -10)
|
|
M.write("pump_loop", M.loop_xfade(lib("sweeper_loop"), 0.3), -11)
|
|
M.write("drone_water_loop", lib("drone_loop"), -12)
|
|
# meadow ambience replaces the waves
|
|
M.write("waves_loop", M.loop_xfade(meadow(14.0), 1.5), -16)
|
|
# thumps into grass (cargo, players, tiles)
|
|
M.write("splash_small", grass_hit(False), -6)
|
|
M.write("splash_big", grass_hit(True), -3)
|
|
# clippings pouring into the hopper
|
|
M.write("pour_loop", M.loop_xfade(rustle(2.5, 120, 1200, 6500), 0.3), -12)
|
|
M.write("gulp", snip(), -8)
|
|
# balers squash
|
|
M.write("filler_fill", lib("press_squash"), -6)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
print("grass sounds written")
|