From: Antonio Ospite <ao2@ao2.it>
Date: Sun, 27 Nov 2016 15:08:31 +0000 (+0100)
Subject: create_test_videofont.py: set the sample length in seconds
X-Git-Url: https://git.ao2.it/vidi-player.git/commitdiff_plain/e935970f46bea9196f5076179b7d53396babaef2?hp=4ed04d98bb6205b3d96ab924991a1adc7a9465f3

create_test_videofont.py: set the sample length in seconds

The duration of a sample in a video font should be at least as long as
the longest corresponding note in the midi file.
---

diff --git a/create_test_videofont.py b/create_test_videofont.py
index d113875..fb0699f 100755
--- a/create_test_videofont.py
+++ b/create_test_videofont.py
@@ -4,14 +4,18 @@ import sys
 import os
 import vidi
 
+SAMPLE_LENGTH_SECONDS = 4
+
+# 48000 samples per seconds, at 1024 samples per buffer
+NUM_AUDIO_BUFFERS = round(SAMPLE_LENGTH_SECONDS * 48000 / 1024)
 
 LIVE_PIPELINE_TEMPLATE = """
   videotestsrc num-buffers=1 pattern=black ! \
           textoverlay valignment=center halignment=center font-desc="Sans, 72" text="{0}" ! \
           autovideosink \
-  audiotestsrc num-buffers=100 freq={1:f} ! \
+  audiotestsrc num-buffers=%d freq={1:f} ! audio/x-raw,rate=48000 ! \
           autoaudiosink
-"""
+""" % NUM_AUDIO_BUFFERS
 
 #FONT_DESC = "Andale Mono, 72"
 FONT_DESC = "Mono, 72"
@@ -21,9 +25,9 @@ FILE_PIPELINE_TEMPLATE = """
   videotestsrc num-buffers=1 pattern=black ! \
           textoverlay valignment=center halignment=center font-desc="%s" text="{0}" ! \
           queue ! schroenc rate-control=3 ! mux.
-  audiotestsrc num-buffers=100 freq={1:f} ! \
+  audiotestsrc num-buffers=%d freq={1:f} ! audio/x-raw,rate=48000 ! \
           queue ! audioconvert ! vorbisenc quality=0.5 ! queue ! mux.
-""" % FONT_DESC
+""" % (FONT_DESC, NUM_AUDIO_BUFFERS)
 
 
 def create_test_videofont(pipeline_template, notes_range, destination_dir=None):