@@ -141,12 +141,26 @@ def addSequence(self, list, name, relTime, relTo, duration):
141141
142142 def addParallel (self , list , name , relTime , relTo , duration ):
143143 # Adds the given list of intervals to the MetaInterval to be
144- # played simultaneously.
144+ # played simultaneously; all will start at the same time .
145145 self .pushLevel (name , relTime , relTo )
146146 for ival in list :
147147 self .addInterval (ival , 0.0 , TRACK_START )
148148 self .popLevel (duration )
149149
150+ def addParallelEndTogether (self , list , name , relTime , relTo , duration ):
151+ # Adds the given list of intervals to the MetaInterval to be
152+ # played simultaneously; all will end at the same time, but
153+ # the longest interval will be started first to achieve this.
154+
155+ maxDuration = 0
156+ for ival in list :
157+ maxDuration = max (maxDuration , ival .getDuration ())
158+
159+ self .pushLevel (name , relTime , relTo )
160+ for ival in list :
161+ self .addInterval (ival , maxDuration - ival .getDuration (), TRACK_START )
162+ self .popLevel (duration )
163+
150164 def addTrack (self , list , name , relTime , relTo , duration ):
151165 # Adds a "track list". This is a list of tuples of the form:
152166 #
@@ -422,6 +436,11 @@ def applyIvals(self, meta, relTime, relTo):
422436 meta .addParallel (self .ivals , self .getName (),
423437 relTime , relTo , self .phonyDuration )
424438
439+ class ParallelEndTogether (MetaInterval ):
440+ def applyIvals (self , meta , relTime , relTo ):
441+ meta .addParallelEndTogether (self .ivals , self .getName (),
442+ relTime , relTo , self .phonyDuration )
443+
425444class Track (MetaInterval ):
426445 def applyIvals (self , meta , relTime , relTo ):
427446 meta .addTrack (self .ivals , self .getName (),
0 commit comments