| 105 | } |
| 106 | |
| 107 | void 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 | |
| 152 | void SpectralDisplay::Resize(float w, float h) |
| 153 | { |
nothing calls this directly
no test coverage detected