I was testing out this code I found for a little audio app in android and I'm a bit stuck on something.
short samples[] = new short[buffsize];
int amp = 32767;
double twopi = 2*Math.PI;
double fr = 262.f;
double ph = 0.0;
while(isRunning)
{
fr = 262 + 262*sliderval;
for(int i=0; i < buffsize; i++)
{
samples[i] = (short) (amp*Math.sin(ph));
ph += twopi*fr/sr;
}
audioTrack.write(samples, 0, buffsize);
}
I know that this loop works to synthesize the sound, but I don't know what the "ph" parameter is and how it fits into the math to generate the sine wave. Could someone please explain it to me if they know what it is?