MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / sampleManual

Method sampleManual

Tasks/WaveSampler.cpp:96–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96bool
97WaveSampler::sampleManual(void)
98{
99 long amount = static_cast<long>(this->properties.symbolCount) - this->p;
100 long p = this->p;
101
102 unsigned int q = 0;
103 qreal start, end;
104 SUFLOAT tStart, tEnd;
105 SUFLOAT deltaInv = 1.f / SCAST(SUFLOAT, this->delta);
106 qint64 iStart, iEnd;
107
108 SUCOMPLEX avg;
109 SUCOMPLEX x = 0, prev = this->prevSample;
110
111 if (amount > SIGDIGGER_WAVESAMPLER_FEEDER_BLOCK_LENGTH)
112 amount = SIGDIGGER_WAVESAMPLER_FEEDER_BLOCK_LENGTH;
113
114 while (amount--) {
115 start = (p++ - this->sampOffset) * this->delta + this->properties.symbolSync;
116
117 end = start + this->delta;
118 avg = 0;
119
120 iStart = static_cast<qint64>(std::floor(start));
121 iEnd = static_cast<qint64>(std::ceil(end));
122
123 tStart = SCAST(SUFLOAT, 1 - (start - SCAST(qreal, iStart)));
124 tEnd = SCAST(SUFLOAT, 1 - (SCAST(qreal, iEnd) - end));
125
126 // Average all symbols between start and end. This is actually some
127 // terrible filtering algorithm, but it should work
128
129 for (auto i = iStart; i <= iEnd; ++i) {
130 if (i >= 0 && i < SCAST(qint64, this->properties.length)) {
131 if (i == iStart)
132 x = tStart * this->properties.data[i];
133 else if (i == iEnd)
134 x = tEnd * this->properties.data[i];
135 else
136 x = this->properties.data[i];
137 } else {
138 x = 0;
139 }
140
141 // Sample averaging is performed differently according to the
142 // decision space.
143
144 switch (this->properties.space) {
145 // Phase (and frequency, which is encoded in the phase): we perform
146 // an averaged weight by the modulus. This is, we just sum up samples.
147 case FREQUENCY:
148 case PHASE:
149 avg += x * SU_C_CONJ(prev);
150 break;
151
152 // Ampltude: we perform a power estimation over the symbol length and
153 // from there, deduce the amplitude (i.e. RMS)

Callers 1

workMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected