public Afedri() { settings.SamplingRate = DEFAULT_SAMPLING_RATE; Format = new SignalFormat(DEFAULT_SAMPLING_RATE, true, settings.IsSync(), settings.ChannelCount(), -(int)(DEFAULT_SAMPLING_RATE * 0.47), (int)(DEFAULT_SAMPLING_RATE * 0.47), 0); buffer.SamplesAvailable += (o, e) => SamplesAvailable?.Invoke(this, e); }
//IIqProcessor /// <summary>Initializes the resampler for processing data from the specified source.</summary> /// <param name="source">The data source.</param> public void Initialize(ISampleStream source) { Format = new SignalFormat(source.Format); Format.SamplingRate = outputSamplingRate; var wrapper = new SampleSourceWrapper(source).ToWaveSource(); dmo = new DmoResampler(wrapper, outputSamplingRate); dmo.Quality = Quality; resampler = dmo.ToSampleSource(); }
/// <summary>Writes one of the channels of the strided data to the ring buffer.</summary> /// <param name="data">The data.</param> /// <param name="offset">The offset to the first value.</param> /// <param name="inFloatCount">The number of the input floating point values.</param> /// <param name="format">The format of the data.</param> public void WriteStrided(float[] data, int offset, int inFloatCount, SignalFormat format) { //single channel, just copy if (format.Channels == 1) { Write(data, offset, inFloatCount); } //multiple complex channels else if (format.IsComplex) { int stride = format.Channels * Dsp.COMPONENTS_IN_COMPLEX; int floatCount = inFloatCount / format.Channels; int complexCount = inFloatCount / stride; if (buffer == null || this.buffer.Length < floatCount) { buffer = new float[floatCount]; } Dsp.StridedToComplex(data, offset, stride, buffer, 0, complexCount); Write(buffer, 0, floatCount); } //multiple real channels else { int floatCount = inFloatCount / format.Channels; if (buffer == null || this.buffer.Length < floatCount) { buffer = new float[floatCount]; } Dsp.StridedToFloat(data, offset, format.Channels, buffer, 0, floatCount); Write(buffer, 0, floatCount); } }