109 static const int NUM_WAVELET_SAMPLES{100};
127 bool showEggs{
false};
128 bool showPlayheads{
true};
134 showPlayheads =
true;
138 showPlayheads =
true;
142 showPlayheads =
false;
146 bool isFirstPlayingGrain =
true;
147 float waveletSamples[NUM_WAVELET_SAMPLES];
148 bool waveletSamplesValid =
false;
157 float halfGrainHeight = grainHeight * 0.5f;
162 float positionStartPercent =
167 g.setColour(Colours::green.withAlpha(1.0f));
171 g.setColour(Colours::red.withAlpha(1.0f));
175 g.setColour(Colours::violet.withAlpha(0.2f));
179 g.setColour(Colours::orange.withAlpha(0.2f));
182 g, {positionStartPercent,
188 if (showPlayheads && hasSampleAccess)
195 float centerHeight = 0.5f;
205 g.setColour(Colours::yellow.withAlpha(
206 jmin<float>(0.25f + halfGrainHeight * 2.0f, 1.f)));
210 g.setColour(Colours::lightgoldenrodyellow.withAlpha(
211 jmin<float>(0.25f + halfGrainHeight * 2.0f, 1.f)));
214 {percentage, centerHeight + halfGrainHeight, percentage,
215 centerHeight - halfGrainHeight},
221 Rectangle<float> voiceIndexBounds;
222 voiceIndexBounds.setPosition(percentage + 0.005f, centerHeight);
223 voiceIndexBounds.setSize(0.2f, 0.3f);
229 g.setColour(Colours::cyan);
231 g, {percentage - 0.01f, yPosition, percentage + 0.01f, yPosition}, 2);
235 g.setColour(Colours::magenta);
237 g, {percentage - 0.01f, yPosition, percentage + 0.01f, yPosition}, 2);
249 {percentage, centerHeight + halfGrainHeight,
250 percentage, centerHeight - halfGrainHeight},
259 if (isFirstPlayingGrain)
261 isFirstPlayingGrain =
false;
265 static_cast<float>(NUM_WAVELET_SAMPLES));
267 float min = 1000.f, max = -1000.f;
268 for (
int wSample = 0; wSample < NUM_WAVELET_SAMPLES; wSample++)
270 waveletSamples[wSample] =
m_sampleEngine->getSample(0, startIndex);
272 if (waveletSamples[wSample] < min)
273 min = waveletSamples[wSample];
274 if (waveletSamples[wSample] > max)
275 max = waveletSamples[wSample];
277 startIndex += increment;
278 if (
static_cast<int>(startIndex) >
m_sampleEngine->getNumSamples() - 1)
284 for (
int wSample = 0; wSample < NUM_WAVELET_SAMPLES; wSample++)
286 waveletSamples[wSample] = jmap<float>(waveletSamples[wSample], min, max, 0.f, 1.f);
288 waveletSamplesValid =
true;
302 float minY = 10000000.0f;
307 g.setColour(Colours::cyan.withAlpha(0.3f));
308 for (
auto& grainDescription : grainDescriptionByTime)
310 float xPosition = float(grainDescription.audioIndex) / numSamples;
312 if (grainDescription.frequency > maxY)
313 maxY = grainDescription.frequency;
314 if (grainDescription.frequency < minY)
315 minY = grainDescription.frequency;
321 for (
auto& grainDescription : grainDescriptionByTime)
323 float xPosition = float(grainDescription.audioIndex) / numSamples;
324 float yPosition = jmap<float>(grainDescription.frequency, minY, maxY, 1.0f, 0.0f);
327 linePath.startNewSubPath(xPosition, yPosition);
331 linePath.lineTo(xPosition, yPosition);
335 g.setColour(Colours::red.withAlpha(0.9f));
343 Line<float> line1 = Line<float>(0.f, indicator1Value *
static_cast<float>(getHeight()),
344 static_cast<float>(getWidth()) * 0.025f,
345 indicator1Value *
static_cast<float>(getHeight()));
348 Line<float> line2 = Line<float>(0.f, indicator2Value *
static_cast<float>(getHeight()), getWidth(),
349 indicator2Value *
static_cast<float>(getHeight()));
351 g.setColour(Colours::black.withAlpha(0.5f));
352 g.drawLine(line1, 5);
353 g.drawLine(line2, 2);
355 g.setColour(Colours::yellow.withAlpha(1.f));
356 g.drawLine(line1, 3);
358 g.setColour(Colours::lightcyan.withAlpha(1.f));
359 g.drawLine(line2, 1);
363 g.setColour(Colours::red.withAlpha(1.f));
364 g.drawFittedText(sDisplay, getWidth() / 2, 0, getWidth() / 4, getHeight() / 2,
365 Justification::centredLeft, 1);
368 if (waveletSamplesValid)
371 float wxPosition = 0.75f;
372 float xIncrement = 0.125f /
static_cast<float>(NUM_WAVELET_SAMPLES);
373 waveletPath.startNewSubPath(wxPosition, waveletSamples[0]);
374 for (
int wSample = 1; wSample < NUM_WAVELET_SAMPLES; wSample++)
376 wxPosition += xIncrement;
377 waveletPath.lineTo(wxPosition, waveletSamples[wSample]);
379 g.setColour(Colours::white.withAlpha(1.0f));