Browse Source

aggiunge coda con i toni noti

boyska 2 years ago
parent
commit
3e7de5ceb0
2 changed files with 14 additions and 2 deletions
  1. 1 1
      barker/create-audios.sh
  2. 13 1
      barker/make-barker-audios.py

+ 1 - 1
barker/create-audios.sh

@@ -9,7 +9,7 @@ do
     mkdir -p "$basedir"
     base="$basedir/barker"
     dest="$base.wav"
-    python3 make-barker-audios.py --barker-seq $length "$dest"
+    python3 make-barker-audios.py --pipupa --barker-seq $length "$dest"
     for shiftMS in 100 1000 2000
     do
         shiftS="$(echo "scale=2; $shiftMS / 1000" | bc)"

+ 13 - 1
barker/make-barker-audios.py

@@ -23,6 +23,7 @@ def get_parser():
         "--barker-freq-2", default=500, type=int, help='Known as "-1" in barker code'
     )
     p.add_argument("--duration", default=100, type=int)
+    p.add_argument("--pipupa", action="store_true", default=False)
 
     p.add_argument(
         "--log-level",
@@ -51,6 +52,10 @@ def compress(seq):
     return out
 
 
+PIPUPA_SEQ = [0, 300, 1000, 2000, 0]
+PIPUPA_TONE_DURATION = 500  # milliseconds
+
+
 def main():
     args = get_parser().parse_args()
     basicConfig(level=args.log_level)
@@ -60,8 +65,15 @@ def main():
     symbol_map = {1: str(args.barker_freq_1), -1: str(args.barker_freq_2)}
     for howmany, symbol in barker_seq_duration:
         freq = symbol_map[symbol]
-        part = ["synth", "%.2f" % (howmany * args.duration / 1000.0), "sin", freq, ":"]
+        part = ["synth", "%.2f" % (howmany * args.duration / 1000.0),
+                "sin", freq, ":"]
         synth.extend(part)
+    if args.pipupa:
+        for freq in PIPUPA_SEQ:
+            part = ["synth", "%.2f" % (howmany * PIPUPA_TONE_DURATION / 1000.0),
+                    "sin", str(freq), ":"]
+            synth.extend(part)
+
     synth.pop()  # remove trailing colon
     cmd = ["sox", "-n", args.fname] + synth
     subprocess.check_call(cmd)