send: set gain (to prevent saturation)

This commit is contained in:
Roman Zeyde
2015-02-17 17:26:22 +02:00
parent fdf6e7e882
commit e0718596e2
2 changed files with 5 additions and 4 deletions

View File

@@ -8,8 +8,8 @@ from . import framing, common, stream, detect, sampling
log = logging.getLogger(__name__)
def send(config, src, dst):
sender = _send.Sender(dst, config=config)
def send(config, src, dst, gain=1.0):
sender = _send.Sender(dst, config=config, gain=gain)
Fs = config.Fs
# pre-padding audio with silence (priming the audio sending queue)

View File

@@ -10,7 +10,8 @@ log = logging.getLogger(__name__)
class Sender(object):
def __init__(self, fd, config):
def __init__(self, fd, config, gain=1.0):
self.gain = gain
self.offset = 0
self.fd = fd
self.modem = dsp.MODEM(config.symbols)
@@ -22,7 +23,7 @@ class Sender(object):
self.equalizer = equalizer.Equalizer(config)
def write(self, sym):
sym = np.array(sym)
sym = np.array(sym) * self.gain
data = common.dumps(sym)
self.fd.write(data)
self.offset += len(sym)