Exemple #1
0
        short[] BuildTonePayload(AudioFormat format, TimeSpan tsDuration)
        {
            int nSamples = format.CalculateNumberOfSamplesForDuration(tsDuration);

            short[] sPayload = new short[nSamples]; /// 320 samples for 20 ms packets

            if (w1 == w2)
            {
                double fAmplitude = Utils.SampleFromDb(short.MaxValue, m_fDecibels);
                for (int i = 0; i < nSamples; i++)
                {
                    double t = (i + nSequence) / 16000.0f;

                    sPayload[i] = (short)(fAmplitude * (Math.Sin(w1 * t)));
                }
            }
            else
            {
                double fAmplitude = Utils.SampleFromDbDualFrequency(short.MaxValue, m_fDecibels);

                for (int i = 0; i < nSamples; i++)
                {
                    double t = (i + nSequence) / 16000.0f;

                    sPayload[i] = (short)(fAmplitude * (Math.Sin(w1 * t) + Math.Sin(w2 * t)));
                }
            }

            nSequence += nSamples;
            return(sPayload);
        }
        public SimpleEchoCanceller(AudioFormat format, TimeSpan tsDurationSave)
        {
            AudioFormat = format;

            IncomingSamples = format.CalculateNumberOfSamplesForDuration(tsDurationSave);
            IncomingData = new short[IncomingSamples];
            IncomingDataTemp = new short[IncomingSamples];
        }
Exemple #3
0
        public SimpleEchoCanceller(AudioFormat format, TimeSpan tsDurationSave)
        {
            AudioFormat = format;

            IncomingSamples  = format.CalculateNumberOfSamplesForDuration(tsDurationSave);
            IncomingData     = new short[IncomingSamples];
            IncomingDataTemp = new short[IncomingSamples];
        }
Exemple #4
0
 public MediaSample(TimeSpan tsduration, AudioFormat format)
 {
     MediaType       = MediaType.Audio;
     m_objAudioFormt = format;
     m_bData         = new byte[m_objAudioFormt.CalculateNumberOfSamplesForDuration(tsduration) * BytesPerSample];
 }
Exemple #5
0
 public MediaSample(TimeSpan tsduration, AudioFormat format)
 {
     MediaType = MediaType.Audio;
     m_objAudioFormt = format;
     m_bData = new byte[m_objAudioFormt.CalculateNumberOfSamplesForDuration(tsduration) * BytesPerSample];
 }
Exemple #6
0
        short[] BuildTonePayload(AudioFormat format, TimeSpan tsDuration)
        {
            int nSamples = format.CalculateNumberOfSamplesForDuration(tsDuration);

            short[] sPayload = new short[nSamples]; /// 320 samples for 20 ms packets

            if (w1 == w2)
            {
                double fAmplitude = Utils.SampleFromDb(short.MaxValue, m_fDecibels);
                for (int i = 0; i < nSamples; i++)
                {
                    double t = (i + nSequence) / 16000.0f;

                    sPayload[i] = (short)(fAmplitude * (Math.Sin(w1 * t)));
                }
            }
            else
            {
                double fAmplitude = Utils.SampleFromDbDualFrequency(short.MaxValue, m_fDecibels);

                for (int i = 0; i < nSamples; i++)
                {
                    double t = (i + nSequence) / 16000.0f;

                    sPayload[i] = (short)(fAmplitude * (Math.Sin(w1 * t) + Math.Sin(w2 * t)));
                }
            }

            nSequence += nSamples;
            return sPayload;
        }