Fruit Fly
README.md
flySound
The sound a fly makes. build hangs three spatial sources under the fly: a
looping wingbeat bed whose loudness follows how hard the wing motor neurons
are driving the wings, a wet tick for a mouthful, and a dry thump for a hop.
local FlySound = require("~.flySound")
local sound = FlySound.build(public.entity)
sound:setFlight(dt, motor.flight)
sound:feed()
sound:jump()
Every clip is pcm and was synthesised from arithmetic in
fruitFly.wingbeat, fruitFly.feed and fruitFly.jump, so the rig needs no
network and no generation service. The wingbeat is a 220 Hz fundamental with
three harmonics over exactly 44 periods, which is what makes it loop without a
click; clipRef:loopSeam().seamless reads true on it.
Mix ceilings: wingbeat 0.5, tick 0.6, thump 0.6. The fly is heard out to 14
world units. volumes() reports what each source is set to right now, which
is the reading to check the bed against motor.flight.
A source with no clip is left out rather than played silent, so a world that has not got the clips yet runs with the rest of the fly intact.