feat: add Robot (ring modulation) and Dźwięk z tostera (8-bit bitcrusher) player audio effects

This commit is contained in:
mmacierzanka committed 2026-09-11 02:13:21 +02:00
1 parent 39403b8238
commit 51418a2d88
7 files changed
+137

No files matched your search

+19
View File
@@ -8,6 +8,8 @@ from zyrarbot.audio.effects import (
DistortionEffect,
FourthDensityEffect,
MuffledEffect,
RobotEffect,
ToasterEffect,
TremoloEffect,
create_default_effects,
)
@@ -47,6 +49,23 @@ class TestAudioEffects(unittest.TestCase):
out = fx.process(pcm)
self.assertEqual(len(out), len(pcm))
def test_robot_modulates_ring(self):
fx = RobotEffect(freq_hz=65.0, mix=0.85)
pcm = (struct.pack("<hh", 10000, 10000)) * 960
out = fx.process(pcm)
self.assertEqual(len(out), len(pcm))
self.assertNotEqual(out, pcm)
def test_toaster_bitcrush_pcm(self):
fx = ToasterEffect(bit_depth=5, downsample=6)
pcm = struct.pack("<hh", 12345, -23456)
out = fx.process(pcm)
l, r = struct.unpack("<hh", out)
# Low 11 bits are zeroed due to 5-bit quantization
self.assertEqual(l & 0x07FF, 0)
self.assertEqual(r & 0x07FF, 0)
def test_pipeline_chains_multiple_effects_and_applies_volume(self):
pipeline = AudioEffectsPipeline(create_default_effects())
pcm = (struct.pack("<hh", 1000, -1000)) * 960