don't use the resampler if the optimization says so

This commit is contained in:
Jakob Ketterl 2019-10-13 18:25:32 +02:00
parent eda556ef03
commit f45857f79b

View File

@ -266,23 +266,28 @@ class ServiceHandler(object):
with self.lock: with self.lock:
self.services = [] self.services = []
for group in self.optimizeResampling(dials, sr): groups = self.optimizeResampling(dials, sr)
frequencies = sorted([f["frequency"] for f in group]) if groups is None:
min = frequencies[0] for dial in dials:
max = frequencies[-1] self.services.append(self.setupService(dial["mode"], dial["frequency"], self.source))
cf = (min + max) / 2 else:
bw = max - min for group in groups:
logger.debug("group center frequency: {0}, bandwidth: {1}".format(cf, bw)) frequencies = sorted([f["frequency"] for f in group])
resampler_props = PropertyManager() min = frequencies[0]
resampler_props["center_freq"] = cf max = frequencies[-1]
# TODO the + 24000 is a temporary fix since the resampling optimizer does not account for required bandwidths cf = (min + max) / 2
resampler_props["samp_rate"] = bw + 24000 bw = max - min
resampler = Resampler(resampler_props, self.getAvailablePort(), self.source) logger.debug("group center frequency: {0}, bandwidth: {1}".format(cf, bw))
resampler.start() resampler_props = PropertyManager()
self.services.append(resampler) resampler_props["center_freq"] = cf
# TODO the + 24000 is a temporary fix since the resampling optimizer does not account for required bandwidths
resampler_props["samp_rate"] = bw + 24000
resampler = Resampler(resampler_props, self.getAvailablePort(), self.source)
resampler.start()
self.services.append(resampler)
for dial in group: for dial in group:
self.services.append(self.setupService(dial["mode"], dial["frequency"], resampler)) self.services.append(self.setupService(dial["mode"], dial["frequency"], resampler))
def optimizeResampling(self, freqs, bandwidth): def optimizeResampling(self, freqs, bandwidth):
freqs = sorted(freqs, key=lambda f: f["frequency"]) freqs = sorted(freqs, key=lambda f: f["frequency"])
@ -320,7 +325,10 @@ class ServiceHandler(object):
for r in results: for r in results:
logger.debug("splits: {0}, total: {1}".format(r["num_splits"], r["total_bandwidth"])) logger.debug("splits: {0}, total: {1}".format(r["num_splits"], r["total_bandwidth"]))
return results[0]["groups"] best = results[0]
if best["num_splits"] is None:
return None
return best["groups"]
def setupService(self, mode, frequency, source): def setupService(self, mode, frequency, source):
logger.debug("setting up service {0} on frequency {1}".format(mode, frequency)) logger.debug("setting up service {0} on frequency {1}".format(mode, frequency))