Version 3.2.2: in-memory replacements fill their slots exactly (padded ones played as silence)
This commit is contained in:
@@ -25,6 +25,16 @@ def wem(seconds, freq, rate=24000, ch=1):
|
||||
return encoder.encode(x, sr, rate, ch)[0]
|
||||
|
||||
|
||||
def fitting_wem(ws, s, seconds, freq):
|
||||
"""A tone WEM that `ws` accepts for `s` (Workspace.fits: in-memory slots are filled exactly, which needs
|
||||
an even number of spare bytes): the tone is shortened a little until the size allows it."""
|
||||
for k in range(40):
|
||||
w = wem(seconds * (1 - 0.01 * k), freq)
|
||||
if ws.fits(s, w):
|
||||
return w
|
||||
raise AssertionError("no fitting WEM for %s" % s.key)
|
||||
|
||||
|
||||
def _a(x, n):
|
||||
return (x + n - 1) // n * n
|
||||
|
||||
|
||||
Reference in New Issue
Block a user