re-structure client audio conversion
This commit is contained in:
parent
c3d393252b
commit
be6f533437
@ -1,16 +1,18 @@
|
|||||||
from csdr.chain import Chain
|
from csdr.chain import Chain
|
||||||
from pycsdr.modules import AudioResampler, Convert, AdpcmEncoder
|
from pycsdr.modules import AudioResampler, Convert, AdpcmEncoder, Limit
|
||||||
from pycsdr.types import Format
|
from pycsdr.types import Format
|
||||||
|
|
||||||
|
|
||||||
class ClientAudioChain(Chain):
|
class ClientAudioChain(Chain):
|
||||||
def __init__(self, format: Format, inputRate: int, clientRate: int, compression: str):
|
def __init__(self, format: Format, inputRate: int, clientRate: int, compression: str):
|
||||||
workers = []
|
workers = []
|
||||||
if format != Format.FLOAT:
|
|
||||||
workers += [Convert(format, Format.FLOAT)]
|
|
||||||
if inputRate != clientRate:
|
if inputRate != clientRate:
|
||||||
workers += [AudioResampler(inputRate, clientRate)]
|
# we only have an audio resampler for float ATM so if we need to resample, we need to convert
|
||||||
workers += [Convert(Format.FLOAT, Format.SHORT)]
|
if format != Format.FLOAT:
|
||||||
|
workers += [Convert(format, Format.FLOAT)]
|
||||||
|
workers += [AudioResampler(inputRate, clientRate), Limit(), Convert(Format.FLOAT, Format.SHORT)]
|
||||||
|
elif format != Format.SHORT:
|
||||||
|
workers += [Convert(format, Format.SHORT)]
|
||||||
if compression == "adpcm":
|
if compression == "adpcm":
|
||||||
workers += [AdpcmEncoder(sync=True)]
|
workers += [AdpcmEncoder(sync=True)]
|
||||||
super().__init__(*workers)
|
super().__init__(*workers)
|
||||||
|
Loading…
Reference in New Issue
Block a user