Now we can pan audio left and right, we need to find a way to modulate the gSlider value over time. To achieve this we are going to find the value of a Sin wave at different points, then multiply these values with the channel data. To start, we will modulate the value between 0-1 every second.

To modulate the levels the correct amount we need to do a bit of maths.

Every cycle of Sin = 2 * pi radians.

The sample rate of the DAW means that a certain number of samples happen every second, therefore

2pi radians / sample rate = Radians per Sample

For every sample, we can find Sin (Radians per Sample) then add another ‘Radians per Sample’ length to find a value for the next sample. These values can be multiplied to each channel of audio instead of the gSlider variable.