pzelasko/cylimiter

Allow pickling

Closed this issue · 1 comments

Is it possible to allow pickling of the Limiter class?

Yes, just added it and released v0.2 to PyPI, check out the following test:

def test_limiter_pickle_works():
limiter_default = Limiter()
limiter = Limiter(attack=0.555, delay=1000, threshold=0.2, release=0.01)
data = pickle.dumps(limiter)
limiter_unpickled = pickle.loads(data)
audio = get_audio()
audio_lim = limiter.limit(audio)
assert audio != audio_lim
audio_lim_unpickled = limiter_unpickled.limit(audio)
assert audio != audio_lim_unpickled
audio_lim_default = limiter_default.limit(audio)
assert audio_lim != audio_lim_default
assert audio_lim_unpickled != audio_lim_default
assert audio_lim == audio_lim_unpickled