Skip to content

Commit

Permalink
fix clearing from qsys
Browse files Browse the repository at this point in the history
  • Loading branch information
3ll3d00d committed Oct 7, 2023
1 parent 6c153ce commit 836a565
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions ezbeq/qsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import re
import socket
from typing import Optional, List
from typing import Optional, List, Union

from ezbeq.apis.ws import WsServer
from ezbeq.catalogue import CatalogueEntry, CatalogueProvider
Expand Down Expand Up @@ -82,7 +82,7 @@ def update(self, params: dict) -> bool:
any_update = True
return any_update

def __send(self, to_load: List['PEQ'], entry: CatalogueEntry):
def __send(self, to_load: List['PEQ'], entry: Union[CatalogueEntry, str]):
logger.info(f"Sending {len(to_load)} filters")
while len(to_load) < 10:
to_load.append(PEQ(100, 1, 0, 'PeakingEQ'))
Expand All @@ -109,7 +109,7 @@ def __recvall(sock: socket, buf_size: int = 4096) -> str:
return data.decode('utf-8').strip(TERMINATOR)
return ''

def __send_to_socket(self, peqs: List['PEQ'], entry: CatalogueEntry):
def __send_to_socket(self, peqs: List['PEQ'], entry: Union[CatalogueEntry, str]):
logger.info(f"Sending {peqs} to {self.__ip}:{self.__port}")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(self.__timeout_srcs)
Expand All @@ -126,7 +126,7 @@ def __send_to_socket(self, peqs: List['PEQ'], entry: CatalogueEntry):
for k, v in mappings.items():
if v == 'filters':
val = json.dumps([coeff for p in peqs for coeff in p.coeffs])
else:
elif isinstance(entry, CatalogueEntry):
m = re.match(r'(.*)\[(\d+)\]', v)
if m:
val = getattr(entry, m.group(1))
Expand All @@ -145,6 +145,8 @@ def __send_to_socket(self, peqs: List['PEQ'], entry: CatalogueEntry):
val = ', '.join(val)
else:
val = str(val)
else:
val = ''
text_controls.append({'Name': k, 'Value': val})
self.__send_component(component_name, text_controls, sock)
finally:
Expand Down Expand Up @@ -190,10 +192,10 @@ def load_filter(self, slot: str, entry: CatalogueEntry, mv_adjust: float = 0.0)
to_load = [PEQ(f['freq'], f['q'], f['gain'], f['type']) for f in entry.filters]
self._hydrate_cache_broadcast(lambda: self.__do_it(to_load, entry))

def __do_it(self, to_load: List['PEQ'], entry: CatalogueEntry):
def __do_it(self, to_load: List['PEQ'], entry: Union[CatalogueEntry, str]):
try:
self.__send(to_load, entry)
self._current_state.slot.last = entry.formatted_title
self._current_state.slot.last = entry.formatted_title if isinstance(entry, CatalogueEntry) else entry
except Exception as e:
self._current_state.slot.last = 'ERROR'
raise e
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ezbeq"
version = "2.0.0a27"
version = "2.0.0a28"
description = "A webapp which can send beqcatalogue filters to a DSP device"
authors = ["3ll3d00d <mattkhan+ezbeq@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit 836a565

Please sign in to comment.