feat: implement volume boost functionality with signal-based multiplier and audio processing override
This commit is contained in:
13 files changed
+294
-8
No files matched your search
@@ -7,6 +7,7 @@ import tempfile
|
||||
import unittest
|
||||
|
||||
from tests.fakes import FakeTrack, build_player
|
||||
from zyrarbot.music.guild_music_state import VOLUME_BOOST_MULTIPLIER
|
||||
from zyrarbot.music.loop_mode import LoopMode
|
||||
from zyrarbot.storage.queue_repository import QueueRepository
|
||||
|
||||
@@ -235,6 +236,37 @@ class MusicPlayerQueueTest(unittest.IsolatedAsyncioTestCase):
|
||||
|
||||
self.assertEqual(track.volume, 0.25)
|
||||
|
||||
async def test_volume_boost_multiplies_effective_volume_by_multiplier(self):
|
||||
player, _ = build_player()
|
||||
player.set_volume(GUILD, 0.2)
|
||||
player.set_volume_boost(GUILD, True)
|
||||
|
||||
self.assertEqual(player.state(GUILD).volume, 0.2)
|
||||
self.assertAlmostEqual(
|
||||
player.state(GUILD).effective_volume, 0.2 * VOLUME_BOOST_MULTIPLIER
|
||||
)
|
||||
|
||||
track = FakeTrack("boosted")
|
||||
await player.enqueue(GUILD, track)
|
||||
self.assertAlmostEqual(track.volume, 0.2 * VOLUME_BOOST_MULTIPLIER)
|
||||
|
||||
player.set_volume(GUILD, 1.0)
|
||||
self.assertAlmostEqual(
|
||||
player.state(GUILD).effective_volume, 1.0 * VOLUME_BOOST_MULTIPLIER
|
||||
)
|
||||
|
||||
async def test_toggle_volume_boost(self):
|
||||
player, _ = build_player()
|
||||
self.assertFalse(player.state(GUILD).volume_boost)
|
||||
|
||||
res = player.toggle_volume_boost(GUILD)
|
||||
self.assertTrue(res)
|
||||
self.assertTrue(player.state(GUILD).volume_boost)
|
||||
|
||||
res2 = player.toggle_volume_boost(GUILD)
|
||||
self.assertFalse(res2)
|
||||
self.assertFalse(player.state(GUILD).volume_boost)
|
||||
|
||||
async def test_default_plays_are_applied_per_guild(self):
|
||||
player, _ = build_player()
|
||||
player._config.get_default_plays.side_effect = lambda guild_id: {1: 2, 2: 7}.get(
|
||||
|
||||
Reference in new issue
Block a user