MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / scope_sync

Function scope_sync

plugins/Cardinal/src/sassy/sassy_scope.cpp:147–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145
146
147static int scope_sync(ScopeData* gScope, int index)
148{
149 const float gSamplerate = gScope->mSampleRate;
150 int samples = (int)(gSamplerate * gScope->mTimeScale);
151 int cycle = gSamplerate * 10;
152 int ofs = samples;
153
154 if (gScope->mMode == 0)
155 {
156 // calculate sync
157 if (gScope->mSyncMode == 0)
158 {
159 float* graphdata = gScope->mCh[gScope->mSyncChannel].mData;
160 int over = ofs;
161 while (over < (cycle - ofs) && graphdata[(index - over + cycle) % cycle] < 0) over++;
162 int under = over;
163 while (under < (cycle - ofs) && graphdata[(index - under + cycle) % cycle] > 0) under++;
164 ofs = under;
165 }
166 else
167 if (gScope->mSyncMode == 1)
168 {
169 float* graphdata = gScope->mCh[gScope->mSyncChannel].mData;
170 int under = ofs;
171 while (under < (cycle - ofs) && graphdata[(index - under + cycle) % cycle] > 0) under++;
172 int over = under;
173 while (over < (cycle - ofs) && graphdata[(index - over + cycle) % cycle] < 0) over++;
174 ofs = over;
175 }
176 // default: ofs = samples
177 }
178 else
179 {
180 // pause mode, scroll bar is active
181 ofs = -(int)(gScope->mScroll * gSamplerate);
182 if (ofs < samples)
183 ofs = samples;
184 if (ofs > gSamplerate * 10 - samples)
185 ofs = gSamplerate * 10 - samples;
186 }
187 gScope->mScroll = -((float)ofs / gSamplerate);
188
189 return ofs;
190}
191
192#if 0
193static void scope_plot(ScopeData* gScope, const float uiScale, int index)

Callers 3

scope_plotFunction · 0.85
scope_timeFunction · 0.85
scope_freqFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected