v0.67.1: the air horn is one continuous tone
The old recording was a two-note phrase that wobbled 9% in pitch, so no loop of it could hold a tone. A steady CC0 can (guitarguy1985, 359-361 Hz for 7 s) replaces it: held, it plays on and laps a long crossfade; a click is at least half a second; letting go bends the pitch down as it fades.
This commit is contained in:
+1
-35
@@ -44,41 +44,7 @@ def _envelope(mono, seconds=0.015):
|
||||
return np.sqrt(np.convolve(mono * mono, np.ones(win) / win, mode="same"))
|
||||
|
||||
|
||||
class TestHorn:
|
||||
def test_a_click_is_a_short_blast_that_trails_off(self, recording):
|
||||
x, _ = _play(recording, [("press", 0.01), ("release", 0.0)])
|
||||
assert 0.3 < len(x) / RATE < 0.45
|
||||
env = _envelope(x)
|
||||
assert env[-int(0.02 * RATE):].max() < 0.05 * env.max() # fades to nothing
|
||||
# …gradually: the last 120 ms fall, they don't drop off a cliff
|
||||
tail = env[-int(0.12 * RATE):]
|
||||
assert tail[0] > 4 * tail[-1]
|
||||
|
||||
def test_a_hold_sustains_without_clicks_or_a_beat(self, recording):
|
||||
x, _ = _play(recording, [("press", 3.0), ("release", 0.0)])
|
||||
source = recording.astype(np.float32).mean(axis=1) / 32768
|
||||
own_step = np.abs(np.diff(source[:int(0.6 * RATE)])).max()
|
||||
assert np.abs(np.diff(x)).max() <= own_step + 1e-3 # no seam clicks
|
||||
held = _envelope(x)[int(0.6 * RATE):int(2.6 * RATE)]
|
||||
assert held.min() / held.max() > 0.7 # steady, no pulse
|
||||
assert len(x) / RATE < 3.0 + 0.45 # stops on release
|
||||
|
||||
def test_taps_stay_separate_then_a_hold_carries(self, recording):
|
||||
x, horn = _play(recording, [("press", 0.06), ("release", 0.12)] * 6
|
||||
+ [("press", 2.5), ("release", 0.0)])
|
||||
held = _envelope(x)[int(1.6 * RATE):int(3.2 * RATE)]
|
||||
assert held.min() / held.max() > 0.7
|
||||
assert not horn._voices
|
||||
|
||||
def test_a_retrigger_cuts_the_old_blast_quickly(self, recording):
|
||||
horn = Horn(recording)
|
||||
horn.press()
|
||||
horn.render(4410)
|
||||
horn.press()
|
||||
states = [v["state"] for v in horn._voices]
|
||||
assert states == ["cut", "held"]
|
||||
horn.render(int(0.03 * RATE))
|
||||
assert [v["state"] for v in horn._voices] == ["held"]
|
||||
# The horn's tests moved to test_round98 with its new recording.
|
||||
|
||||
|
||||
class TestLoops:
|
||||
|
||||
Reference in New Issue
Block a user