Mercurial > hg > webaudioevaluationtool
diff scripts/timeline_view_movement.py @ 1075:056a8454500e
Bug fixes in scripts: display plays in last timeline segment of each fragment (post last move); call sub-processes of generate_report.py in same folder (pass on argument); indentation in LaTeX file.
author | Brecht De Man <BrechtDeMan@users.noreply.github.com> |
---|---|
date | Wed, 16 Sep 2015 13:31:40 +0100 |
parents | f1201566b54b |
children | adbaff4bf3f0 235594325b84 |
line wrap: on
line diff
--- a/scripts/timeline_view_movement.py Tue Sep 15 10:20:50 2015 +0100 +++ b/scripts/timeline_view_movement.py Wed Sep 16 13:31:40 2015 +0100 @@ -137,7 +137,7 @@ # assume not playing at start currently_playing = False # keep track of whether fragment is playing during move event - + # draw all segments except final one for event in move_events: # mark this plot as not empty @@ -198,7 +198,6 @@ ) # vertical line from previous to current position - #TODO red if currently playing, orig color if not plt.plot([new_time, new_time], # x-values [previous_position, new_position], # y-values # color depends on playing during move event or not: @@ -210,14 +209,69 @@ previous_position = new_position previous_time = new_time - # draw final segment + + + # draw final horizontal segment (or only segment if audioelement not moved) # horizontal line from previous time to end of audioholder - plt.plot([previous_time, audioholder_time-time_offset], # x-values + + # get play/stop events since last move until current move event + stop_times = [] + start_times = [] + # is there a play and/or stop event between previous_time and new_time? + for time in start_times_global: + if time>previous_time and time<audioholder_time-time_offset: + start_times.append(time) + for time in stop_times_global: + if time>previous_time and time<audioholder_time-time_offset: + stop_times.append(time) + # if no play/stop events between move events, find out whether playing + + segment_start = previous_time # first segment starts at previous move event + + # draw segments (horizontal line) + while len(start_times)+len(stop_times)>0: # while still play/stop events left + # mark this plot as not empty + plot_empty = False + if len(stop_times)<1: # upcoming event is 'play' + # draw non-playing segment from segment_start to 'play' + currently_playing = False + segment_stop = start_times.pop(0) # remove and return first item + elif len(start_times)<1: # upcoming event is 'stop' + # draw playing segment (red) from segment_start to 'stop' + currently_playing = True + segment_stop = stop_times.pop(0) # remove and return first item + elif start_times[0]<stop_times[0]: # upcoming event is 'play' + # draw non-playing segment from segment_start to 'play' + currently_playing = False + segment_stop = start_times.pop(0) # remove and return first item + else: # stop_times[0]<start_times[0]: upcoming event is 'stop' + # draw playing segment (red) from segment_start to 'stop' + currently_playing = True + segment_stop = stop_times.pop(0) # remove and return first item + + # draw segment + plt.plot([segment_start, segment_stop], # x-values + [previous_position, previous_position], # y-values + color='r' if currently_playing else colormap[increment%len(colormap)], + linewidth=3 + ) + segment_start = segment_stop # move on to next segment + currently_playing = not currently_playing # toggle to draw final segment correctly + + # draw final segment (horizontal line) from last 'segment_start' to current move event time + plt.plot([segment_start, audioholder_time-time_offset], # x-values [previous_position, previous_position], # y-values - color=colormap[increment%len(colormap)], + # color depends on playing during move event or not: + color='r' if currently_playing else colormap[increment%len(colormap)], linewidth=3 ) +# plt.plot([previous_time, audioholder_time-time_offset], # x-values +# [previous_position, previous_position], # y-values +# color=colormap[increment%len(colormap)], +# linewidth=3 +# ) + # display fragment name at end plt.text(audioholder_time-time_offset,previous_position,\ audio_id,color=colormap[increment%len(colormap)]) #,rotation=45