public unsafe static void ForwardTransformLut(Complex *buffer, int length) { int num = length - 1; int num2 = length / 2; Complex complex = default(Complex); complex.Real = 0f; complex.Imag = 0f; Complex c = default(Complex); c.Real = 0f; c.Imag = 0f; int num3 = 0; for (int num4 = length; num4 > 1; num4 >>= 1) { num3++; } int num5 = num2; for (int num4 = 1; num4 < num; num4++) { if (num4 < num5) { complex = buffer[num5]; buffer[num5] = buffer[num4]; buffer[num4] = complex; } int num6; for (num6 = num2; num6 <= num5; num6 /= 2) { num5 -= num6; } num5 += num6; } for (int i = 1; i <= num3; i++) { int num7 = 1 << i; int num8 = num7 / 2; int num9 = 16 - i; for (num5 = 1; num5 <= num8; num5++) { int num10 = num5 - 1; int num11 = num10 << num9; c.Real = Fourier._lr[num11]; c.Imag = Fourier._li[num11]; for (int num4 = num10; num4 <= num; num4 += num7) { num11 = num4 + num8; Complex.Mul(ref complex, c, buffer[num11]); Complex.Sub(ref buffer[num11], buffer[num4], complex); Complex.Add(ref buffer[num4], complex); } } } }
public Complex Process(Complex sample) { Complex result = Trig.SinCos(this._phase); Complex.Mul(ref result, sample); float phaseError = 0f - result.FastArgument(); this.ProcessPhaseError(phaseError); return(result); }
public unsafe static void ForwardTransformRot(Complex *buffer, int length) { int num = length - 1; int num2 = length / 2; Complex c = default(Complex); c.Real = 0f; c.Imag = 0f; Complex complex = default(Complex); complex.Real = 0f; complex.Imag = 0f; int num3 = 0; for (int num4 = length; num4 > 1; num4 >>= 1) { num3++; } int num5 = num2; for (int num4 = 1; num4 < num; num4++) { if (num4 < num5) { complex = buffer[num5]; buffer[num5] = buffer[num4]; buffer[num4] = complex; } int num6; for (num6 = num2; num6 <= num5; num6 /= 2) { num5 -= num6; } num5 += num6; } for (int i = 1; i <= num3; i++) { int num7 = 1 << i; int num8 = num7 / 2; double num9 = 3.1415926535897931 / (double)num8; for (num5 = 1; num5 <= num8; num5++) { int num10 = num5 - 1; Complex.FromAngle(ref c, num9 * (double)num10); Complex.Conjugate(ref c); for (int num4 = num10; num4 <= num; num4 += num7) { int num11 = num4 + num8; Complex.Mul(ref complex, c, buffer[num11]); Complex.Sub(ref buffer[num11], buffer[num4], complex); Complex.Add(ref buffer[num4], complex); } } } }
public unsafe void Mix(Complex *buffer, int length, int startIndex, int stepSize) { for (int i = startIndex; i < length; i += stepSize) { this.Tick(); Complex c = default(Complex); c.Real = (float)this._outR; c.Imag = (float)this._outI; Complex.Mul(ref buffer[i], c); } }
public unsafe void Process(float *baseBand, int length) { if (this._rawBuffer == null || this._rawBuffer.Length != length) { this._rawBuffer = UnsafeBuffer.Create(length, sizeof(Complex)); this._rawPtr = (Complex *)(void *)this._rawBuffer; } if (this._magBuffer == null || this._magBuffer.Length != length) { this._magBuffer = UnsafeBuffer.Create(length, 4); this._magPtr = (float *)(void *)this._magBuffer; } if (this._dataBuffer == null || this._dataBuffer.Length != length) { this._dataBuffer = UnsafeBuffer.Create(length, 4); this._dataPtr = (float *)(void *)this._dataBuffer; } for (int i = 0; i < length; i++) { this._osc->Tick(); Complex.Mul(ref this._rawPtr[i], this._osc->Out, baseBand[i]); } this._decimator.Process(this._rawPtr, length); length /= this._decimationFactor; this._baseBandFilter.Process(this._rawPtr, length); for (int j = 0; j < length; j++) { this._dataPtr[j] = this._pll->Process(this._rawPtr[j]).Imag; } this._matchedFilter.Process(this._dataPtr, length); for (int k = 0; k < length; k++) { this._magPtr[k] = Math.Abs(this._dataPtr[k]); } this._syncFilter->Process(this._magPtr, length); for (int l = 0; l < length; l++) { float lastData = this._dataPtr[l]; float num = this._magPtr[l]; float num2 = num - this._lastSync; this._lastSync = num; if (num2 < 0f && this._lastSyncSlope * num2 < 0f) { bool flag = this._lastData > 0f; this._bitDecoder.Process(flag ^ this._lastBit); this._lastBit = flag; } this._lastData = lastData; this._lastSyncSlope = num2; } }
public static Complex[] MakeKernelFromFFT(Complex[] buf, int len, WindowType window, int order) { float[] array = FilterBuilder.MakeWindow(window, order + 1); Complex[] array2 = new Complex[order + 1]; for (int i = 0; i < order + 1; i++) { int num = i - order / 2; if (num < 0) { num += len; } Complex.Mul(ref array2[i], buf[num], array[i]); } return(array2); }
private unsafe void ProcessStandard(Complex *buffer, int length) { if (this._queueBuffer != null) { for (int i = 0; i < length; i++) { Complex *ptr = this._queuePtr + this._offset; * ptr = buffer[i]; this._acc.Real = 0f; this._acc.Imag = 0f; int num = this._queueSize; Complex *ptr2 = ptr; Complex *ptr3 = this._coeffPtr; if (num >= 4) { do { Complex.Mul(ref this._acc, *ptr2, *ptr3); Complex.Mul(ref this._tmp, ptr2[1], ptr3[1]); Complex.Add(ref this._acc, this._tmp); Complex.Mul(ref this._tmp, ptr2[2], ptr3[2]); Complex.Add(ref this._acc, this._tmp); Complex.Mul(ref this._tmp, ptr2[3], ptr3[3]); Complex.Add(ref this._acc, this._tmp); ptr2 += 4; ptr3 += 4; }while ((num -= 4) >= 4); } while (num-- > 0) { ref Complex tmp = ref this._tmp; Complex * intPtr = ptr2; ptr2 = intPtr + 1; Complex c = *intPtr; Complex *intPtr2 = ptr3; ptr3 = intPtr2 + 1; Complex.Mul(ref tmp, c, *intPtr2); Complex.Add(ref this._acc, this._tmp); } if (--this._offset < 0) { this._offset = this._queueSize * 3; Utils.Memcpy(this._queuePtr + this._offset + 1, this._queuePtr, (this._queueSize - 1) * sizeof(Complex)); } buffer[i] = this._acc; } }
public unsafe void Demodulate(Complex *iq, float *audio, int length) { for (int i = 0; i < length; i++) { Complex.Conjugate(ref this._tmp, this._iqState); Complex.Mul(ref this._f, iq[i], this._tmp); float num = this._f.Modulus(); if (num > 0f) { Complex.Div(ref this._f, num); } float num2 = this._f.Argument(); audio[i] = num2 * 1E-05f; this._iqState = iq[i]; } if (this._mode == FmMode.Narrow) { this.ProcessSquelch(audio, length); for (int j = 0; j < length; j++) { audio[j] *= 0.5f; } } }
public unsafe void Process(Complex *buffer, int length) { int i = 0; int j = 0; for (; i < length; i++) { this._fftBufferPtr[this._fftBufferPos++] = buffer[i]; if (this._fftBufferPos == this._fftSize) { int num = this._halfSize; int num2 = 0; while (num < this._fftSize) { this._overlapBufferPtr[num2] = this._fftBufferPtr[num]; num++; num2++; } for (; j < length; j++) { if (this._sampleBufferHead == this._sampleBufferTail) { break; } buffer[j] = this._sampleBufferPtr[this._sampleBufferTail]; this._sampleBufferTail = (this._sampleBufferTail + 1 & this._fftSize - 1); } Fourier.ForwardTransform(this._fftBufferPtr, this._fftSize, false); this.ProcessFft(this._fftBufferPtr, this._fftSize); Fourier.BackwardTransform(this._fftBufferPtr, this._fftSize); int num3 = 0; int num4 = this._halfSize - this._overlapSize; while (num3 < this._halfSize) { if (num3 < this._overlapSize) { float num5 = (float)num3 * this._blendFactor; Complex.Mul(ref this._sampleBufferPtr[this._sampleBufferHead], this._fftBufferPtr[num4], num5); Complex.Mul(ref this._tmp, this._outOverlapPtr[num3], 1f - num5); Complex.Add(ref this._sampleBufferPtr[this._sampleBufferHead], this._tmp); } else { this._sampleBufferPtr[this._sampleBufferHead] = this._fftBufferPtr[num4]; } this._sampleBufferHead = (this._sampleBufferHead + 1 & this._fftSize - 1); num3++; num4++; } int num6 = 0; int num7 = this._fftSize - this._overlapSize; while (num6 < this._overlapSize) { this._outOverlapPtr[num6] = this._fftBufferPtr[num7]; num6++; num7++; } for (int k = 0; k < this._halfSize; k++) { this._fftBufferPtr[k] = this._overlapBufferPtr[k]; } this._fftBufferPos = this._halfSize; } } for (; j < length; j++) { if (this._sampleBufferHead == this._sampleBufferTail) { break; } buffer[j] = this._sampleBufferPtr[this._sampleBufferTail]; this._sampleBufferTail = (this._sampleBufferTail + 1 & this._fftSize - 1); } }