From: tw on
I have project in c# ctcss i put ton into signal send using sound card
to anather pc where I test tone and if its the same as in decoder
options, remove tone and send signal to speakers, But i have problem
with it because its dosen't remove tone.
generator:
private byte[] generator(int samplerate, float frequency, int length,
float gain)
{
byte[] ton = new byte[length];

float A = (float)(frequency * 2 * PI / samplerate);

for (int i = 0; i < length; i++)
{
ton[i] = ((byte)(127*Math.Cos(A*i)+128));


}
for (int i = 0; i < length; i++) ton[i] = (byte)(ton[i] *
(byte)gain);
return ton;
}
put tone into signal:
private byte[] nakladanie(byte[] bufer)
{
byte[] ton = new byte[bufer.Length];
tony = generator(8000, freq, bufer.Length, 1);
if (n_ton)
{
for (int i = 0; i < bufer.Length; i++)
{
ton[i] = (byte)(bufer[i] + tony[i]);
}
return ton;
}
else {
return bufer;
}
}
and remove:
private byte[] zdejmowanie(byte[] bufer)
{
byte[] ton = new byte[bufer.Length];
tony = generator(8000, freq, bufer.Length, 1);
if (n_ton)
{
for (int i = 0; i < bufer.Length; i++)
{
ton[i] = (byte)(bufer[i] - tony[i]);
}
return ton;
}
else {
return bufer;
}
}
What shall I change it?