2021-07-25 17:31:56 +00:00
|
|
|
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):
|
2021-07-25 17:31:56 +00:00
|
|
|
workers = []
|
2021-07-29 22:06:21 +00:00
|
|
|
if format != Format.FLOAT:
|
|
|
|
workers += [Convert(format, Format.FLOAT)]
|
2021-07-25 17:31:56 +00:00
|
|
|
if inputRate != clientRate:
|
|
|
|
workers += [AudioResampler(inputRate, clientRate)]
|
|
|
|
workers += [Convert(Format.FLOAT, Format.SHORT)]
|
|
|
|
if compression == "adpcm":
|
2021-07-25 18:06:14 +00:00
|
|
|
workers += [AdpcmEncoder(sync=True)]
|
2021-07-25 17:31:56 +00:00
|
|
|
super().__init__(*workers)
|