I have some measurements that are piecewise constant over a certain variable. For example, in the following image, the vertical axis represents the measurement data and the variable is on the horizontal axis. The orange curve is what my measurements look like. Although not shown in the plot, the measurements are not necessarily monotonously increasing with the variable values. But they are definitely piecewise constant.
I would like to fit a smooth curve over these piecewise constant data such that it goes through the midpoints of all 'pieces'. The desirable curve is shown in blue. I should be able to obtain a closed-form expression of this curve. 
What are some good ways to obtain such a curve? Some of my colleagues suggested using spline fit, convolving with a spline or linear interpolation. Why using a spline is a good idea here?
I am not aware of the relative advantages of these and other methods. My objective is to obtain a function that should be able to predict the measurement for any given value of the variable.
~ryan