Replace deprecated audioop with NumPy and add silent join sounds

- Replace audioop module (removed in Python 3.13) with NumPy
  - Implement _apply_volume() method using NumPy for volume adjustment
  - Update RMS calculation in ducking_sound_received() to use NumPy
  - Add numpy to requirements.txt
- Add silent flag to CachedItemWrapper for join sounds
  - Join sounds now play without channel announcements
  - Regular playlist items still respect announce_current_music config
- Update CLAUDE.md to document changes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Storm Dragon
2025-12-08 21:46:19 -05:00
parent d45d666b4e
commit 70919b0769
3 changed files with 44 additions and 17 deletions

View File

@@ -139,11 +139,12 @@ class MusicCache(dict):
class CachedItemWrapper:
def __init__(self, lib, id, type, user):
def __init__(self, lib, id, type, user, silent=False):
self.lib = lib
self.id = id
self.user = user
self.type = type
self.silent = silent # If True, don't announce when playing (for join sounds)
self.log = logging.getLogger("bot")
self.version = 0
@@ -216,10 +217,10 @@ class CachedItemWrapper:
# Remember!!! Get wrapper functions will automatically add items into the cache!
def get_cached_wrapper(item, user):
def get_cached_wrapper(item, user, silent=False):
if item:
var.cache[item.id] = item
return CachedItemWrapper(var.cache, item.id, item.type, user)
return CachedItemWrapper(var.cache, item.id, item.type, user, silent=silent)
return None
def get_cached_wrappers(items, user):
@@ -234,12 +235,13 @@ def get_cached_wrapper_from_scrap(**kwargs):
item = var.cache.get_item(**kwargs)
if 'user' not in kwargs:
raise KeyError("Which user added this song?")
return CachedItemWrapper(var.cache, item.id, kwargs['type'], kwargs['user'])
silent = kwargs.get('silent', False)
return CachedItemWrapper(var.cache, item.id, kwargs['type'], kwargs['user'], silent=silent)
def get_cached_wrapper_from_dict(dict_from_db, user):
def get_cached_wrapper_from_dict(dict_from_db, user, silent=False):
if dict_from_db:
item = dict_to_item(dict_from_db)
return get_cached_wrapper(item, user)
return get_cached_wrapper(item, user, silent=silent)
return None
def get_cached_wrappers_from_dicts(dicts_from_db, user):
@@ -250,10 +252,10 @@ def get_cached_wrappers_from_dicts(dicts_from_db, user):
return items
def get_cached_wrapper_by_id(id, user):
def get_cached_wrapper_by_id(id, user, silent=False):
item = var.cache.get_item_by_id(id)
if item:
return CachedItemWrapper(var.cache, item.id, item.type, user)
return CachedItemWrapper(var.cache, item.id, item.type, user, silent=silent)
def get_cached_wrappers_by_tags(tags, user):
items = var.cache.get_items_by_tags(tags)