The duration list is treated with Accumulate to get the absolute positions from the durations, and then a list of start and end points for the corresponding absolute intervals is created using Partition with an offset of 1 so that the end point of one interval is the start of the next. Then, Piecewise defines the whole thing as a function.

To plot the function with its vertical jumps displayed as lines, I set ExclusionsStyle -> Automatic.

See the magnificent expression behind it - so you don't have to type it by hand ;) -

PiecewiseExpand[f[x, aper]]

In the above formula you can see discrete values 2 and -2 coming from the fact that UnitBox is defined as 1 at both of its boundaries. So the perfect definition of your function would really be with Clip added:

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.