mirror of
https://github.com/romanz/amodem.git
synced 2026-04-01 00:36:50 +08:00
send: set gain (to prevent saturation)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user