MCPcopy Create free account
hub / github.com/LabSound/LabSound / sqr2

Method sqr2

src/extended/PolyBLEPNode.cpp:246–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244 }
245
246 double sqr2() const
247 {
248 double t1 = t + 0.875 + 0.25 * (pulseWidth - 0.5);
249 t1 -= bitwise_or_zero(t1);
250
251 double t2 = t + 0.375 + 0.25 * (pulseWidth - 0.5);
252 t2 -= bitwise_or_zero(t2);
253
254 // Square #1
255 double y = t1 < 0.5 ? 1 : -1;
256
257 y += blep(t1, freqInSecondsPerSample) - blep(t2, freqInSecondsPerSample);
258
259 t1 += 0.5 * (1 - pulseWidth);
260 t1 -= bitwise_or_zero(t1);
261
262 t2 += 0.5 * (1 - pulseWidth);
263 t2 -= bitwise_or_zero(t2);
264
265 // Square #2
266 y += t1 < 0.5 ? 1 : -1;
267
268 y += blep(t1, freqInSecondsPerSample) - blep(t2, freqInSecondsPerSample);
269
270 return amplitude * 0.5 * y;
271 }
272
273 double rect() const
274 {

Callers

nothing calls this directly

Calls 2

bitwise_or_zeroFunction · 0.85
blepFunction · 0.85

Tested by

no test coverage detected