re-implement format conversion with pycsdr
This commit is contained in:
parent
81925986a6
commit
acc70b6449
@ -1,5 +1,9 @@
|
||||
from abc import ABCMeta
|
||||
from owrx.source import SdrSource, SdrDeviceDescription
|
||||
from csdr.chain import Chain
|
||||
from typing import Optional
|
||||
from pycsdr.modules import Buffer
|
||||
from pycsdr.types import Format
|
||||
|
||||
import logging
|
||||
|
||||
@ -38,16 +42,30 @@ class DirectSource(SdrSource, metaclass=ABCMeta):
|
||||
]
|
||||
|
||||
def getCommand(self):
|
||||
return super().getCommand() + self.getFormatConversion() + self.getNmuxCommand()
|
||||
return super().getCommand() + self.getNmuxCommand()
|
||||
|
||||
# override this in subclasses, if necessary
|
||||
def getFormatConversion(self):
|
||||
return []
|
||||
def getFormatConversion(self) -> Optional[Chain]:
|
||||
return None
|
||||
|
||||
# override this in subclasses, if necessary
|
||||
def sleepOnRestart(self):
|
||||
pass
|
||||
|
||||
def getBuffer(self):
|
||||
if self.buffer is None:
|
||||
source = self._getTcpSource()
|
||||
buffer = Buffer(source.getOutputFormat())
|
||||
source.setWriter(buffer)
|
||||
conversion = self.getFormatConversion()
|
||||
if conversion is not None:
|
||||
conversion.setReader(buffer.getReader())
|
||||
# this one must be COMPLEX_FLOAT
|
||||
buffer = Buffer(Format.COMPLEX_FLOAT)
|
||||
conversion.setWriter(buffer)
|
||||
self.buffer = buffer
|
||||
return self.buffer
|
||||
|
||||
|
||||
class DirectSourceDeviceDescription(SdrDeviceDescription):
|
||||
pass
|
||||
|
@ -1,6 +1,9 @@
|
||||
from owrx.command import Option
|
||||
from owrx.source.direct import DirectSource, DirectSourceDeviceDescription
|
||||
from subprocess import Popen
|
||||
from csdr.chain import Chain
|
||||
from pycsdr.modules import Convert, Gain
|
||||
from pycsdr.types import Format
|
||||
|
||||
import logging
|
||||
|
||||
@ -20,8 +23,8 @@ class FifiSdrSource(DirectSource):
|
||||
def getEventNames(self):
|
||||
return super().getEventNames() + ["device"]
|
||||
|
||||
def getFormatConversion(self):
|
||||
return ["csdr convert_s16_f", "csdr gain_ff 5"]
|
||||
def getFormatConversion(self) -> Chain:
|
||||
return Chain([Convert(Format.COMPLEX_SHORT, Format.COMPLEX_FLOAT), Gain(Format.COMPLEX_FLOAT, 5.0)])
|
||||
|
||||
def sendRockProgFrequency(self, frequency):
|
||||
process = Popen(["rockprog", "--vco", "-w", "--freq={}".format(frequency / 1e6)])
|
||||
|
Loading…
Reference in New Issue
Block a user