#This work is licensed under the
#Creative Commons Attribution-Share Alike 3.0 United States License.
#To view a copy of this license, visit
#http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to
#Creative Commons,
#171 Second Street, Suite 300,
#San Francisco, California, 94105, USA.

INPUT "mid and side channels of signed sample data",block_samples;
OUTPUT "left and right channels of signed sample data";
VAR block_samples "block samples";
VAR mid "mid";
VAR side "side";
VAR left "left";
VAR right "right";
for i <- 0 to block_samples {
    right[i] <- side[i] - floor(mid[i] / 2);
    left[i] <- mid[i] + right[i];
}
return left,right;
