mirror of
https://github.com/romanz/amodem.git
synced 2026-02-24 16:18:12 +08:00
calib: automatic microphone gain calibration
$ amodem-cli send -vv -c 'pactl set-sink-volume @DEFAULT_SINK@' will set speaker level to 100%. $ amodem-cli recv -vv -c 'pactl set-source-volume @DEFAULT_SOURCE@' will use "binary search", to find the best microphone gain.
This commit is contained in:
15
amodem-cli
15
amodem-cli
@@ -106,14 +106,14 @@ def main():
|
||||
'-o', '--output', help='output file (use "-" for stdout).'
|
||||
' if not specified, `aplay` tool will be used.')
|
||||
sender.add_argument(
|
||||
'-c', '--calibrate', default=False, action='store_true')
|
||||
'-c', '--calibrate', nargs='?', default=False)
|
||||
|
||||
sender.set_defaults(
|
||||
main=lambda config, args: send.main(
|
||||
config, src=wrap(Compressor, args.src, args.zip), dst=args.dst
|
||||
),
|
||||
calib=lambda config, args: calib.send(
|
||||
config, dst=args.dst
|
||||
config=config, dst=args.dst, volume_cmd=args.calibrate
|
||||
),
|
||||
input_type=FileType('rb'),
|
||||
output_type=FileType('wb', interface)
|
||||
@@ -128,7 +128,7 @@ def main():
|
||||
receiver.add_argument(
|
||||
'-o', '--output', help='output file (use "-" for stdout).')
|
||||
receiver.add_argument(
|
||||
'-c', '--calibrate', default=False, action='store_true')
|
||||
'-c', '--calibrate', nargs='?', default=False)
|
||||
receiver.add_argument(
|
||||
'-d', '--dump', type=FileType('wb'),
|
||||
help='Filename to save recorded audio')
|
||||
@@ -141,7 +141,8 @@ def main():
|
||||
pylab=args.pylab, dump_audio=args.dump
|
||||
),
|
||||
calib=lambda config, args: calib.recv(
|
||||
config, src=args.src, verbose=args.verbose
|
||||
config=config, src=args.src, verbose=args.verbose,
|
||||
volume_cmd=args.calibrate
|
||||
),
|
||||
input_type=FileType('rb', interface),
|
||||
output_type=FileType('wb')
|
||||
@@ -181,10 +182,10 @@ def main():
|
||||
|
||||
args.src = args.input_type(args.input)
|
||||
args.dst = args.output_type(args.output)
|
||||
if args.calibrate:
|
||||
args.calib(config=config, args=args)
|
||||
else:
|
||||
if args.calibrate is False:
|
||||
return args.main(config=config, args=args)
|
||||
else:
|
||||
args.calib(config=config, args=args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user