Remove unused audio event

This commit is contained in:
Correl Roush 2020-09-04 21:42:43 -04:00
parent bb3b822cf6
commit 4125544c97
3 changed files with 0 additions and 17 deletions

View file

@ -55,7 +55,6 @@ class Application:
pcms.append(pcm_out) pcms.append(pcm_out)
listener = Listener( listener = Listener(
pcms, pcms,
events,
audio_config.get("device", "default"), audio_config.get("device", "default"),
framerate=audio_config.get("framerate", 44100), framerate=audio_config.get("framerate", 44100),
channels=audio_config.get("channels", 2), channels=audio_config.get("channels", 2),

View file

@ -7,7 +7,6 @@ from typing import Deque, List, Tuple, Union
import alsaaudio # type: ignore import alsaaudio # type: ignore
from turntable.events import Audio
from turntable.models import PCM from turntable.models import PCM
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -17,7 +16,6 @@ class Listener(Process):
def __init__( def __init__(
self, self,
pcm_in: "List[Queue[PCM]]", pcm_in: "List[Queue[PCM]]",
events: Queue,
device: str, device: str,
sample_length: int = 30, sample_length: int = 30,
framerate: int = 44100, framerate: int = 44100,
@ -27,7 +25,6 @@ class Listener(Process):
super().__init__() super().__init__()
logger.info(f"Initializing Listener using '{device}'") logger.info(f"Initializing Listener using '{device}'")
self.pcm_in = pcm_in self.pcm_in = pcm_in
self.events = events
self.framerate = framerate self.framerate = framerate
self.channels = channels self.channels = channels
self.capture = alsaaudio.PCM( self.capture = alsaaudio.PCM(
@ -56,18 +53,12 @@ class Listener(Process):
def run(self) -> None: def run(self) -> None:
logger.debug("Starting Listener") logger.debug("Starting Listener")
framecount = 0
event_limit = self.framerate
while True: while True:
length, data = self.capture.read() length, data = self.capture.read()
if length > 0: if length > 0:
pcm = PCM(self.framerate, self.channels, data) pcm = PCM(self.framerate, self.channels, data)
for queue in self.pcm_in: for queue in self.pcm_in:
queue.put(pcm) queue.put(pcm)
framecount += length
if framecount >= event_limit:
framecount = 0
self.events.put(Audio(pcm))
else: else:
logger.warning( logger.warning(
"Sampler error (length={}, bytes={})".format(length, len(data)) "Sampler error (length={}, bytes={})".format(length, len(data))

View file

@ -1,7 +1,5 @@
from dataclasses import dataclass from dataclasses import dataclass
from turntable.models import PCM
class Event: class Event:
@property @property
@ -23,8 +21,3 @@ class StoppedPlaying(Event):
@dataclass @dataclass
class NewMetadata(Event): class NewMetadata(Event):
title: str title: str
@dataclass
class Audio(Event):
pcm: PCM