Oscilloscope 0.5.0
A simple oscilloscope VST
Loading...
Searching...
No Matches
UntriggeredOscilloscope.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 UntriggeredOscilloscope.cpp
5 Created: 28 Feb 2023 4:25:16pm
6 Author: wadda
7
8 ==============================================================================
9*/
10
12
14 : OscilloscopeComponent(aProcessor, sampleRate, aProcessor.getEditorRefreshRate())
15{
16}
17
18void UntriggeredOscilloscope::plot(juce::Graphics &g, juce::Rectangle<float> rect, float scaler, float offset)
19{
20 // get beginning and num samples
21 auto data = sampleData.data();
22 auto numSamples = sampleData.size();
23
24 // get bounds
25 auto w = rect.getWidth();
26 auto h = rect.getHeight();
27 auto right = rect.getRight();
28 auto center = rect.getBottom() - offset;
29 auto gain = h * scaler;
30
31 // set colour
32 g.setColour(WAVEFORMCOLOUR());
33
34 // for each point map and draw line
35 for (size_t i = 1; i < numSamples; ++i)
36 {
37 g.drawLine({juce::jmap(float(i - 1), float(0), float(numSamples - 1), float(right - w), float(right)),
38 center - gain * data[i - 1],
39 juce::jmap(float(i), float(0), float(numSamples - 1), float(right - w), float(right)),
40 center - gain * data[i]});
41 }
42}
43
44void UntriggeredOscilloscope::subclassSpecificCallback()
45{
46 // Nothing to do for this subclass
47 return;
48}
Oscilloscope audio processor.
std::vector< float > sampleData
UntriggeredOscilloscope(OscilloscopeAudioProcessor &aProcessor, int sampleRate)