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]; }
public SimpleEchoCanceller(AudioFormat format, TimeSpan tsDurationSave) { AudioFormat = format; IncomingSamples = format.CalculateNumberOfSamplesForDuration(tsDurationSave); IncomingData = new short[IncomingSamples]; IncomingDataTemp = new short[IncomingSamples]; }
public MediaSample(TimeSpan tsduration, AudioFormat format) { MediaType = MediaType.Audio; m_objAudioFormt = format; m_bData = new byte[m_objAudioFormt.CalculateNumberOfSamplesForDuration(tsduration) * BytesPerSample]; }
public MediaSample(TimeSpan tsduration, AudioFormat format) { MediaType = MediaType.Audio; m_objAudioFormt = format; m_bData = new byte[m_objAudioFormt.CalculateNumberOfSamplesForDuration(tsduration) * BytesPerSample]; }
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; }