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

Method tri2

src/extended/PolyBLEPNode.cpp:106–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104 }
105
106 double tri2() const
107 {
108 double pulseWidth = std::fmax(0.0001, std::fmin(0.9999, this->pulseWidth));
109
110 double t1 = t + 0.5 * pulseWidth;
111 t1 -= bitwise_or_zero(t1);
112
113 double t2 = t + 1 - 0.5 * pulseWidth;
114 t2 -= bitwise_or_zero(t2);
115
116 double y = t * 2;
117
118 if (y >= 2 - pulseWidth)
119 {
120 y = (y - 2) / pulseWidth;
121 }
122 else if (y >= pulseWidth)
123 {
124 y = 1 - (y - pulseWidth) / (1 - pulseWidth);
125 }
126 else
127 {
128 y /= pulseWidth;
129 }
130
131 y += freqInSecondsPerSample / (pulseWidth - pulseWidth * pulseWidth) * (blamp(t1, freqInSecondsPerSample) - blamp(t2, freqInSecondsPerSample));
132
133 return amplitude * y;
134 }
135
136 double trip() const
137 {

Callers

nothing calls this directly

Calls 2

bitwise_or_zeroFunction · 0.85
blampFunction · 0.85

Tested by

no test coverage detected