changeset 51:ebf92ed7d680 tip master

Added -fd (--full-duration) argument.
author Emmanouil Theofanis Chourdakis <e.t.chourdakis@qmul.ac.uk>
date Sun, 30 Sep 2018 13:21:49 +0100
parents 275d04483bf7
children
files python/simscene.py
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/python/simscene.py	Sun Sep 30 12:43:14 2018 +0100
+++ b/python/simscene.py	Sun Sep 30 13:21:49 2018 +0100
@@ -353,6 +353,11 @@
         annot_format = kwargs['annot_format']
     else:
         annot_format = 'sed_eval'
+
+    if 'full_duration' in kwargs:
+        full_duration = True
+    else:
+        full_duration = False
     
     # Stores the starting and ending times of every track for visualization
     # purposes
@@ -608,6 +613,11 @@
             # If 0, then start next sample after this one (set it to the duration of the sample)
             if mean_time_between_instances == 0:
                 mean_time_between_instances = len(wav)/float(SR)
+
+            # If we are using -fd (full_duration) for each event then mean_time_between_instances denotes time AFTER
+            # the end of the previous event.
+            if full_duration and mean_time_between_instances > 0:
+                mean_time_between_instances += len(wav)/float(SR)
                 
             # Store the successive starting and ending times of the events (given e.g. the model)
             # in the following lists.
@@ -900,7 +910,14 @@
         choices=['generate', 'abstract', 'replicate']
     )
     time_mode = 'generate'
-    
+
+    argparser.add_argument(
+        '-fd', '--full-duration',
+        action='store_true',
+        help="If enabled, times specified in the recipe refer to after the previous file finishes."
+    )
+    full_duration = False
+
     argparser.add_argument(
         '-R', '--ebr-mode',
         type=str,
@@ -993,6 +1010,8 @@
     if args.output_path:
         output_path = args.output_path
         logging.debug("Saving to `{}'".format(output_path))
+    if args.full_duration:
+        full_duration = True
     if args.scene_duration:
         if not (args.score_backgrounds or args.score_events):
             print("You must provide one of -e or -b")
@@ -1046,7 +1065,8 @@
                          figure_verbosity=figure_verbosity,
                          end_cut=end_cut,
                          image_format=image_format,
-                         append_to_filename=append_to_filename)
+                         append_to_filename=append_to_filename,
+                         full_duration=full_duration)
             else:
                 for n in range(generate_n):
                     if tag:
@@ -1065,4 +1085,5 @@
                              figure_verbosity=min(figure_verbosity, 1),
                              end_cut=end_cut,
                              image_format=image_format,
-                             append_to_filename=append_to_filename)
+                             append_to_filename=append_to_filename,
+                             full_duration=full_duration)