openwebrx-clone/csdr/chain/clientaudio.py

17 lines
636 B
Python
Raw Normal View History

from csdr.chain import Chain
from pycsdr.modules import AudioResampler, Convert, AdpcmEncoder
from pycsdr.types import Format
class ClientAudioChain(Chain):
2021-07-29 22:06:21 +00:00
def __init__(self, format: Format, inputRate: int, clientRate: int, compression: str):
workers = []
2021-07-29 22:06:21 +00:00
if format != Format.FLOAT:
workers += [Convert(format, Format.FLOAT)]
if inputRate != clientRate:
workers += [AudioResampler(inputRate, clientRate)]
workers += [Convert(Format.FLOAT, Format.SHORT)]
if compression == "adpcm":
workers += [AdpcmEncoder(sync=True)]
super().__init__(*workers)