MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / DrawModule

Method DrawModule

Source/SpectralDisplay.cpp:107–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void SpectralDisplay::DrawModule()
108{
109 if (Minimized() || IsVisible() == false || !mEnabled)
110 return;
111
112 ofPushStyle();
113 ofPushMatrix();
114
115 float w, h;
116 GetDimensions(w, h);
117
118 ofSetColor(255, 255, 255);
119 ofSetLineWidth(1);
120
121 //raw
122 int end = kNumFFTBins / 2 + 1;
123 ofBeginShape();
124 for (int i = kBinIgnore; i < end; i++)
125 {
126 float x = sqrtf(float(i - kBinIgnore) / (end - kBinIgnore - 1)) * w;
127 float samp = sqrtf(fabsf(mFFTData.mRealValues[i]) / end) * 3;
128 float y = ofClamp(samp, 0, 1) * h;
129 ofVertex(x, h - y);
130
131 mSmoother[i - kBinIgnore] = ofLerp(mSmoother[i - kBinIgnore], samp, .1f);
132 }
133 ofEndShape(false);
134
135 ofSetColor(245, 58, 135);
136 ofSetLineWidth(3);
137
138 //smoothed
139 ofBeginShape();
140 for (int i = kBinIgnore; i < end; i++)
141 {
142 float x = sqrtf(float(i - kBinIgnore) / (end - kBinIgnore - 1)) * w;
143 float y = ofClamp(mSmoother[i - kBinIgnore], 0, 1) * h;
144 ofVertex(x, h - y);
145 }
146 ofEndShape(false);
147
148 ofPopMatrix();
149 ofPopStyle();
150}
151
152void SpectralDisplay::Resize(float w, float h)
153{

Callers

nothing calls this directly

Calls 11

ofPushStyleFunction · 0.85
ofPushMatrixFunction · 0.85
ofSetColorFunction · 0.85
ofSetLineWidthFunction · 0.85
ofBeginShapeFunction · 0.85
ofClampFunction · 0.85
ofVertexFunction · 0.85
ofLerpFunction · 0.85
ofEndShapeFunction · 0.85
ofPopMatrixFunction · 0.85
ofPopStyleFunction · 0.85

Tested by

no test coverage detected