I have the following code to send as audio RTP packet some DTMF digits:
int count=0
for(int j = 0; j < samples; j++)
{
waves = 0;
// dtmf tone 1
waves += sin( ((PI * 2.0f / 8000) * 697.0f) * count );
waves += sin( ((PI * 2.0f / 8000) * 1209.0f) * count);
waves *= 8191.0f; //amplitude
++count;
values[j] = (SInt16)waves;
}
I'm generating the digits programatically. This code basically adds up 2 sinewaves and applies scaling. This will produce 16bit PCM data which can then be encoded. The sample rate is 8K to transmit as RTP packet.
Have I done this correctly?
There are more efficient ways to program it, and it really shouldn't be hard-coded (volume, frequencies, length, etc), but that's roughly correct. I'd use M_PI instead of PI.
Note: count == j, waves = 0 is useless (change first += to =), etc.