first steps at rewiring the dsp stuff

This commit is contained in:
Jakob Ketterl
2021-08-23 14:25:28 +02:00
parent 0f1feb9d47
commit 5032f4b66d
13 changed files with 465 additions and 194 deletions

View File

@@ -6,6 +6,8 @@ from pycsdr.types import Format
class ClientAudioChain(Chain):
def __init__(self, format: Format, inputRate: int, clientRate: int, compression: str):
workers = []
self.inputRate = inputRate
self.clientRate = clientRate
if inputRate != clientRate:
# we only have an audio resampler for float ATM so if we need to resample, we need to convert
if format != Format.FLOAT:
@@ -15,4 +17,24 @@ class ClientAudioChain(Chain):
workers += [Convert(format, Format.SHORT)]
if compression == "adpcm":
workers += [AdpcmEncoder(sync=True)]
super().__init__(*workers)
super().__init__(workers)
def setFormat(self, format: Format) -> None:
pass
def setInputRate(self, inputRate: int) -> None:
if inputRate == self.inputRate:
return
def setClientRate(self, clientRate: int) -> None:
if clientRate == self.clientRate:
return
def setAudioCompression(self, compression: str) -> None:
index = self.indexOf(lambda x: isinstance(x, AdpcmEncoder))
if compression == "adpcm":
if index < 0:
self.append(AdpcmEncoder(sync=True))
else:
if index >= 0:
self.remove(index)