I'm trying to control the amplitude of samples in a waveform with a potentiometer. Essentially I want to have it on or off depending on where the potentiometer is. With one pass from 0-127 from the potentiometer, I can add 1 to the waveform, and from 127-0 I can subtract 1 so the waveform is empty. The problem is I can't figure out how to record the history of data coming from the potentiometer, and relay that to ether add or subtract to the waveform. I attached an example of my problem.