Vital
Loading...
Searching...
No Matches
equalizer_response.cpp
Go to the documentation of this file.
2
3#include "shaders.h"
4#include "skin.h"
5#include "utils.h"
6
8 unselected_points_(2, Shaders::kRingFragment),
9 selected_point_(Shaders::kCircleFragment),
10 dragging_point_(Shaders::kCircleFragment), shader_(nullptr) {
11 unselected_points_.setThickness(1.0f);
12 setFill(true);
13
14 addAndMakeVisible(unselected_points_);
15 addAndMakeVisible(selected_point_);
16 addAndMakeVisible(dragging_point_);
17
18 low_cutoff_ = nullptr;
19 low_resonance_ = nullptr;
20 low_gain_ = nullptr;
21 band_cutoff_ = nullptr;
22 band_resonance_ = nullptr;
23 band_gain_ = nullptr;
24 high_cutoff_ = nullptr;
25 high_resonance_ = nullptr;
26 high_gain_ = nullptr;
27
28 low_cutoff_output_ = nullptr;
29 low_resonance_output_ = nullptr;
30 low_gain_output_ = nullptr;
31 band_cutoff_output_ = nullptr;
32 band_resonance_output_ = nullptr;
33 band_gain_output_ = nullptr;
34 high_cutoff_output_ = nullptr;
35 high_resonance_output_ = nullptr;
36 high_gain_output_ = nullptr;
37
38 current_cutoff_ = nullptr;
39 current_gain_ = nullptr;
40
41 low_filter_.setSampleRate(kViewSampleRate);
42 band_filter_.setSampleRate(kViewSampleRate);
43 high_filter_.setSampleRate(kViewSampleRate);
44 low_filter_.setDriveCompensation(false);
45 high_filter_.setDriveCompensation(false);
46
47 active_ = false;
48 high_pass_ = false;
49 notch_ = false;
50 low_pass_ = false;
51 animate_ = true;
52 draw_frequency_lines_ = true;
53 selected_band_ = 0;
54
55 line_data_ = std::make_unique<float[]>(kResolution);
56 line_buffer_ = 0;
57 response_buffer_ = 0;
58 vertex_array_object_ = 0;
59
60 for (int i = 0; i < kResolution; ++i) {
61 float t = i / (kResolution - 1.0f);
62 line_data_[i] = 2.0f * t - 1.0f;
63 }
64
65 db_buffer_ratio_ = kDefaultDbBufferRatio;
66 min_db_ = 0.0f;
67 max_db_ = 1.0f;
68}
69
71
72void EqualizerResponse::initEq(const vital::output_map& mono_modulations) {
73 low_cutoff_output_ = mono_modulations.at("eq_low_cutoff");
74 low_resonance_output_ = mono_modulations.at("eq_low_resonance");
75 low_gain_output_ = mono_modulations.at("eq_low_gain");
76 band_cutoff_output_ = mono_modulations.at("eq_band_cutoff");
77 band_resonance_output_ = mono_modulations.at("eq_band_resonance");
78 band_gain_output_ = mono_modulations.at("eq_band_gain");
79 high_cutoff_output_ = mono_modulations.at("eq_high_cutoff");
80 high_resonance_output_ = mono_modulations.at("eq_high_resonance");
81 high_gain_output_ = mono_modulations.at("eq_high_gain");
82}
83
84void EqualizerResponse::initReverb(const vital::output_map& mono_modulations) {
85 low_cutoff_output_ = mono_modulations.at("reverb_low_shelf_cutoff");
86 low_gain_output_ = mono_modulations.at("reverb_low_shelf_gain");
87 high_cutoff_output_ = mono_modulations.at("reverb_high_shelf_cutoff");
88 high_gain_output_ = mono_modulations.at("reverb_high_shelf_gain");
89}
90
93
94 unselected_points_.init(open_gl);
95 selected_point_.init(open_gl);
96 dragging_point_.init(open_gl);
97
98 open_gl.context.extensions.glGenVertexArrays(1, &vertex_array_object_);
99 open_gl.context.extensions.glBindVertexArray(vertex_array_object_);
100
101 GLsizeiptr vert_size = static_cast<GLsizeiptr>(kResolution * sizeof(float));
102 open_gl.context.extensions.glGenBuffers(1, &line_buffer_);
103 open_gl.context.extensions.glBindBuffer(GL_ARRAY_BUFFER, line_buffer_);
104 open_gl.context.extensions.glBufferData(GL_ARRAY_BUFFER, vert_size, line_data_.get(), GL_STATIC_DRAW);
105
106 open_gl.context.extensions.glGenBuffers(1, &response_buffer_);
107 open_gl.context.extensions.glBindBuffer(GL_ARRAY_BUFFER, response_buffer_);
108 open_gl.context.extensions.glBufferData(GL_ARRAY_BUFFER, vert_size, nullptr, GL_STATIC_READ);
109
110 const GLchar* varyings[] = { "response_out" };
112 shader_->use();
113
114 position_attribute_ = getAttribute(open_gl, *shader_, "position");
115 midi_cutoff_uniform_ = getUniform(open_gl, *shader_, "midi_cutoff");
116 resonance_uniform_ = getUniform(open_gl, *shader_, "resonance");
117 low_amount_uniform_ = getUniform(open_gl, *shader_, "low_amount");
118 band_amount_uniform_ = getUniform(open_gl, *shader_, "band_amount");
119 high_amount_uniform_ = getUniform(open_gl, *shader_, "high_amount");
120}
121
123 glEnable(GL_BLEND);
125 setFillCenter(1.0f - 2.0f * max_db_ / (max_db_ - min_db_));
126
127 Colour color_line = findColour(Skin::kWidgetPrimary1, true);
128 Colour color_fill_to = findColour(Skin::kWidgetSecondary1, true);
129
130 if (!active_) {
131 color_line = findColour(Skin::kWidgetPrimaryDisabled, true);
132 color_fill_to = findColour(Skin::kWidgetSecondaryDisabled, true);
133 }
134 else if (index) {
135 color_line = findColour(Skin::kWidgetPrimary2, true);
136 color_fill_to = findColour(Skin::kWidgetSecondary2, true);
137 }
138
139 setColor(color_line);
140 float fill_fade = findValue(Skin::kWidgetFillFade);
141 setFillColors(color_fill_to.withMultipliedAlpha(1.0f - fill_fade), color_fill_to);
142
143 shader_->use();
144 open_gl.context.extensions.glBindVertexArray(vertex_array_object_);
145 open_gl.context.extensions.glBindBuffer(GL_ARRAY_BUFFER, line_buffer_);
146 open_gl.context.extensions.glVertexAttribPointer(position_attribute_->attributeID, 1, GL_FLOAT, GL_FALSE,
147 sizeof(float), nullptr);
148 open_gl.context.extensions.glEnableVertexAttribArray(position_attribute_->attributeID);
149 open_gl.context.extensions.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, response_buffer_);
150
151 midi_cutoff_uniform_->set(low_filter_.getMidiCutoff()[index],
152 band_filter_.getMidiCutoff()[index],
153 high_filter_.getMidiCutoff()[index]);
154 resonance_uniform_->set(low_filter_.getResonance()[index],
155 band_filter_.getResonance()[index],
156 high_filter_.getResonance()[index]);
157
158 low_amount_uniform_->set(low_filter_.getLowAmount()[index],
159 band_filter_.getLowAmount()[index],
160 high_filter_.getLowAmount()[index]);
161 band_amount_uniform_->set(low_filter_.getBandAmount()[index],
162 band_filter_.getBandAmount()[index],
163 high_filter_.getBandAmount()[index]);
164 high_amount_uniform_->set(low_filter_.getHighAmount()[index],
165 band_filter_.getHighAmount()[index],
166 high_filter_.getHighAmount()[index]);
167
168 open_gl.context.extensions.glBeginTransformFeedback(GL_POINTS);
169 glDrawArrays(GL_POINTS, 0, kResolution);
170 open_gl.context.extensions.glEndTransformFeedback();
171
172 void* buffer = open_gl.context.extensions.glMapBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0,
173 kResolution * sizeof(float), GL_MAP_READ_BIT);
174
175 float* response_data = (float*)buffer;
176 float width = getWidth();
177 float range = max_db_ - min_db_;
178 float y_mult = getHeight() / range;
179 for (int i = 0; i < kResolution; ++i) {
180 setXAt(i, i * width / (kResolution - 1.0f));
181 setYAt(i, (max_db_ - response_data[i]) * y_mult);
182 }
183
184 open_gl.context.extensions.glUnmapBuffer(GL_TRANSFORM_FEEDBACK_BUFFER);
185
186 OpenGlLineRenderer::render(open_gl, animate_);
187}
188
189void EqualizerResponse::render(OpenGlWrapper& open_gl, bool animate) {
190 animate_ = animate;
192 if (active_ && animate_)
193 drawResponse(open_gl, 1);
194 drawResponse(open_gl, 0);
195
196 open_gl.context.extensions.glDisableVertexAttribArray(position_attribute_->attributeID);
197 open_gl.context.extensions.glBindBuffer(GL_ARRAY_BUFFER, 0);
198 open_gl.context.extensions.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
199
200 checkGlError();
201
202 drawControlPoints(open_gl);
203 renderCorners(open_gl, animate);
204}
205
208
209 unselected_points_.destroy(open_gl);
210 selected_point_.destroy(open_gl);
211 dragging_point_.destroy(open_gl);
212
213 open_gl.context.extensions.glDeleteBuffers(1, &line_buffer_);
214 open_gl.context.extensions.glDeleteBuffers(1, &response_buffer_);
215 line_buffer_ = 0;
216 response_buffer_ = 0;
217
218 shader_ = nullptr;
219 position_attribute_ = nullptr;
220 midi_cutoff_uniform_ = nullptr;
221 resonance_uniform_ = nullptr;
222 low_amount_uniform_ = nullptr;
223 band_amount_uniform_ = nullptr;
224 high_amount_uniform_ = nullptr;
225}
226
227void EqualizerResponse::setControlPointBounds(float selected_x, float selected_y,
228 float unselected_x1, float unselected_y1,
229 float unselected_x2, float unselected_y2) {
230 static constexpr float kHandleRadius = 0.06f;
231 static constexpr float kDraggingRadius = 0.18f;
232
233 float width = getWidth();
234 float height = getHeight();
235 float handle_radius = kHandleRadius * height;
236 float handle_width = handle_radius * 4.0f / width;
237 float handle_height = handle_radius * 4.0f / height;
238
239 float dragging_radius = kDraggingRadius * height;
240 float dragging_width = dragging_radius * 4.0f / width;
241 float dragging_height = dragging_radius * 4.0f / height;
242
243 selected_point_.setQuad(0, selected_x - handle_width * 0.5f, selected_y - handle_height * 0.5f,
244 handle_width, handle_height);
245 dragging_point_.setQuad(0, selected_x - dragging_width * 0.5f, selected_y - dragging_height * 0.5f,
246 dragging_width, dragging_height);
247 unselected_points_.setQuad(0, unselected_x1 - handle_width * 0.5f, unselected_y1 - handle_height * 0.5f,
248 handle_width, handle_height);
249 unselected_points_.setQuad(1, unselected_x2 - handle_width * 0.5f, unselected_y2 - handle_height * 0.5f,
250 handle_width, handle_height);
251}
252
254
255 Point<float> low_position = getLowPosition();
256 Point<float> band_position = getBandPosition();
257 Point<float> high_position = getHighPosition();
258
259 float width = getWidth();
260 float height = getHeight();
261
262 float low_x = 2.0f * low_position.x / width - 1.0f;
263 float band_x = 2.0f * band_position.x / width - 1.0f;
264 float high_x = 2.0f * high_position.x / width - 1.0f;
265 float low_y = 1.0f - 2.0f * low_position.y / height;
266 float band_y = 1.0f - 2.0f * band_position.y / height;
267 float high_y = 1.0f - 2.0f * high_position.y / height;
268
269 if (band_cutoff_output_ == nullptr)
270 band_x = -2.0f;
271
272 if (selected_band_ == 0)
273 setControlPointBounds(low_x, low_y, band_x, band_y, high_x, high_y);
274 else if (band_cutoff_output_ && selected_band_ == 1)
275 setControlPointBounds(band_x, band_y, low_x, low_y, high_x, high_y);
276 else if (selected_band_ == 2)
277 setControlPointBounds(high_x, high_y, low_x, low_y, band_x, band_y);
278
279 dragging_point_.setColor(findColour(Skin::kLightenScreen, true));
280 if (current_cutoff_ && current_gain_)
281 dragging_point_.render(open_gl, true);
282 selected_point_.setColor(findColour(Skin::kWidgetPrimary1, true));
283 selected_point_.render(open_gl, true);
284 unselected_points_.setColor(findColour(Skin::kWidgetPrimary1, true));
285 unselected_points_.render(open_gl, true);
286}
287
289 static constexpr int kLineSpacing = 10;
290
292 if (!draw_frequency_lines_)
293 return;
294
295 float min_frequency = vital::utils::midiNoteToFrequency(low_cutoff_->getMinimum());
296 float max_frequency = vital::utils::midiNoteToFrequency(low_cutoff_->getMaximum());
297
298 int height = getHeight();
299 float max_octave = log2f(max_frequency / min_frequency);
300 g.setColour(findColour(Skin::kLightenScreen, true).withMultipliedAlpha(0.5f));
301 float frequency = 0.0f;
302 float increment = 1.0f;
303
304 int x = 0;
305 while (frequency < max_frequency) {
306 for (int i = 0; i < kLineSpacing; ++i) {
307 frequency += increment;
308 float t = log2f(frequency / min_frequency) / max_octave;
309 x = std::round(t * getWidth());
310 g.fillRect(x, 0, 1, height);
311 }
312 g.fillRect(x, 0, 1, height);
313 increment *= kLineSpacing;
314 }
315}
316
317void EqualizerResponse::mouseWheelMove(const MouseEvent& e, const MouseWheelDetails& wheel) {
318 int band = getHoveredBand(e);
319
320 if (band == 0 && low_resonance_)
321 low_resonance_->mouseWheelMove(e, wheel);
322 else if (band == 1 && band_resonance_)
323 band_resonance_->mouseWheelMove(e, wheel);
324 else if (band == 2 && high_resonance_)
325 high_resonance_->mouseWheelMove(e, wheel);
326 else
327 OpenGlComponent::mouseWheelMove(e, wheel);
328}
329
330void EqualizerResponse::mouseDown(const MouseEvent& e) {
331 selected_band_ = getHoveredBand(e);
332
333 if (selected_band_ == 0) {
334 current_cutoff_ = low_cutoff_;
335 current_gain_ = low_gain_;
336 for (Listener* listener : listeners_)
337 listener->lowBandSelected();
338 }
339 else if (selected_band_ == 1) {
340 current_cutoff_ = band_cutoff_;
341 current_gain_ = band_gain_;
342 for (Listener* listener : listeners_)
343 listener->midBandSelected();
344 }
345 else if (selected_band_ == 2) {
346 current_cutoff_ = high_cutoff_;
347 current_gain_ = high_gain_;
348 for (Listener* listener : listeners_)
349 listener->highBandSelected();
350 }
351
352 OpenGlLineRenderer::mouseDown(e);
353}
354
355void EqualizerResponse::mouseDrag(const MouseEvent& e) {
356 moveFilterSettings(e.position);
357 OpenGlLineRenderer::mouseDrag(e);
358}
359
360void EqualizerResponse::mouseUp(const MouseEvent& e) {
361 if (current_cutoff_ == nullptr && current_gain_ == nullptr) {
362 OpenGlLineRenderer::mouseUp(e);
363 return;
364 }
365
366 current_cutoff_ = nullptr;
367 current_gain_ = nullptr;
368 OpenGlLineRenderer::mouseUp(e);
369}
370
371void EqualizerResponse::mouseExit(const MouseEvent& e) {
372 if (low_cutoff_) {
373 low_cutoff_->hidePopup(true);
374 low_cutoff_->hidePopup(false);
375 }
376 OpenGlLineRenderer::mouseExit(e);
377}
378
379int EqualizerResponse::getHoveredBand(const MouseEvent& e) {
380 const float grab_distance = 0.06f * getWidth();
381
382 float delta_low = e.position.getDistanceSquaredFrom(getLowPosition());
383 float delta_band = e.position.getDistanceSquaredFrom(getBandPosition());
384 float delta_high = e.position.getDistanceSquaredFrom(getHighPosition());
385
386 float min_sqr_dist = grab_distance * grab_distance;
387 float min = std::min(std::min(min_sqr_dist, delta_low), delta_high);
388 if (band_cutoff_output_)
389 min = std::min(min, delta_band);
390
391 if (delta_low <= min)
392 return 0;
393 if (band_cutoff_output_ && delta_band <= min)
394 return 1;
395 if (delta_high <= min)
396 return 2;
397
398 return -1;
399}
400
402 float cutoff_range = low_cutoff_->getMaximum() - low_cutoff_->getMinimum();
403 float min_cutoff = low_cutoff_->getMinimum();
404 float gain_range = max_db_ - min_db_;
405
406 float low_x = getWidth() * (low_cutoff_->getValue() - min_cutoff) / cutoff_range;
407 float low_y = getHeight() * (max_db_ - low_gain_->getValue()) / gain_range;
408 return Point<float>(low_x, low_y);
409}
410
412 if (band_cutoff_ == nullptr)
413 return Point<float>(0.0f, 0.0f);
414
415 float cutoff_range = band_cutoff_->getMaximum() - band_cutoff_->getMinimum();
416 float min_cutoff = band_cutoff_->getMinimum();
417 float gain_range = max_db_ - min_db_;
418
419 float band_x = getWidth() * (band_cutoff_->getValue() - min_cutoff) / cutoff_range;
420 float band_y = getHeight() * (max_db_ - band_gain_->getValue()) / gain_range;
421 return Point<float>(band_x, band_y);
422}
423
425 float cutoff_range = high_cutoff_->getMaximum() - high_cutoff_->getMinimum();
426 float min_cutoff = high_cutoff_->getMinimum();
427 float gain_range = max_db_ - min_db_;
428
429 float high_x = getWidth() * (high_cutoff_->getValue() - min_cutoff) / cutoff_range;
430 float high_y = getHeight() * (max_db_ - high_gain_->getValue()) / gain_range;
431 return Point<float>(high_x, high_y);
432}
433
435 low_filter_state_.midi_cutoff = getOutputTotal(low_cutoff_output_, low_cutoff_);
436 low_filter_state_.resonance_percent = getOutputTotal(low_resonance_output_, low_resonance_);
437 low_filter_state_.gain = getOutputTotal(low_gain_output_, low_gain_);
438 if (high_pass_) {
439 low_filter_state_.style = vital::DigitalSvf::k12Db;
440 low_filter_state_.pass_blend = 2.0f;
441 }
442 else {
443 low_filter_state_.style = vital::DigitalSvf::kShelving;
444 low_filter_state_.pass_blend = 0.0f;
445 }
446 low_filter_.setupFilter(low_filter_state_);
447
448 band_filter_state_.midi_cutoff = getOutputTotal(band_cutoff_output_, band_cutoff_);
449 band_filter_state_.resonance_percent = getOutputTotal(band_resonance_output_, band_resonance_);
450 band_filter_state_.gain = getOutputTotal(band_gain_output_, band_gain_);
451 band_filter_state_.pass_blend = 1.0f;
452 if (notch_)
453 band_filter_state_.style = vital::DigitalSvf::kNotchPassSwap;
454 else
455 band_filter_state_.style = vital::DigitalSvf::kShelving;
456 band_filter_.setupFilter(band_filter_state_);
457
458 high_filter_state_.midi_cutoff = getOutputTotal(high_cutoff_output_, high_cutoff_);
459 high_filter_state_.resonance_percent = getOutputTotal(high_resonance_output_, high_resonance_);
460 high_filter_state_.gain = getOutputTotal(high_gain_output_, high_gain_);
461 if (low_pass_) {
462 high_filter_state_.style = vital::DigitalSvf::k12Db;
463 high_filter_state_.pass_blend = 0.0f;
464 }
465 else {
466 high_filter_state_.style = vital::DigitalSvf::kShelving;
467 high_filter_state_.pass_blend = 2.0f;
468 }
469
470 high_filter_.setupFilter(high_filter_state_);
471}
472
473void EqualizerResponse::moveFilterSettings(Point<float> position) {
474 if (current_cutoff_) {
475 float ratio = vital::utils::clamp(position.x / getWidth(), 0.0f, 1.0f);
476 float min = current_cutoff_->getMinimum();
477 float max = current_cutoff_->getMaximum();
478 float new_cutoff = ratio * (max - min) + min;
479 current_cutoff_->showPopup(true);
480 current_cutoff_->setValue(new_cutoff);
481 }
482 if (current_gain_) {
483 float local_position = position.y - 0.5f * db_buffer_ratio_ * getHeight();
484 float ratio = vital::utils::clamp(local_position / ((1.0f - db_buffer_ratio_) * getHeight()), 0.0f, 1.0f);
485 float min = current_gain_->getMinimum();
486 float max = current_gain_->getMaximum();
487 float new_db = ratio * (min - max) + max;
488 current_gain_->setValue(new_db);
489 current_gain_->showPopup(false);
490 }
491 else
492 low_gain_->hidePopup(false);
493}
494
497 float buffer = gain->getRange().getLength() * db_buffer_ratio_;
498 min_db_ = gain->getMinimum() - buffer;
499 max_db_ = gain->getMaximum() + buffer;
500 low_cutoff_ = cutoff;
501 low_resonance_ = resonance;
502 low_gain_ = gain;
503 low_cutoff_->addSliderListener(this);
504 if (low_resonance_)
505 low_resonance_->addSliderListener(this);
506 low_gain_->addSliderListener(this);
507 repaint();
508}
509
512 band_cutoff_ = cutoff;
513 band_resonance_ = resonance;
514 band_gain_ = gain;
515 band_cutoff_->addSliderListener(this);
516 if (band_resonance_)
517 band_resonance_->addSliderListener(this);
518 band_gain_->addSliderListener(this);
519 repaint();
520}
521
524 high_cutoff_ = cutoff;
525 high_resonance_ = resonance;
526 high_gain_ = gain;
527 high_cutoff_->addSliderListener(this);
528 if (high_resonance_)
529 high_resonance_->addSliderListener(this);
530 high_gain_->addSliderListener(this);
531 repaint();
532}
533
534void EqualizerResponse::setSelectedBand(int selected_band) {
535 selected_band_ = selected_band;
536 repaint();
537}
538
540 active_ = active;
541 repaint();
542}
543
544void EqualizerResponse::setHighPass(bool high_pass) {
545 high_pass_ = high_pass;
546 repaint();
547}
548
550 notch_ = notch;
551 repaint();
552}
553
554void EqualizerResponse::setLowPass(bool low_pass) {
555 low_pass_ = low_pass;
556 repaint();
557}
558
559vital::poly_float EqualizerResponse::getOutputTotal(vital::Output* output, Slider* slider) {
560 if (output == nullptr || slider == nullptr)
561 return 0.0f;
562 if (!active_ || !animate_ || !output->owner->enabled())
563 return slider->getValue();
564 return output->trigger_value;
565}
Interface for objects that want to be notified when a band is selected.
Definition equalizer_response.h:36
void drawControlPoints(OpenGlWrapper &open_gl)
Draws the control points (markers) for the EQ bands.
Definition equalizer_response.cpp:253
void moveFilterSettings(Point< float > position)
Moves the currently selected filter's cutoff and gain based on a mouse drag position.
Definition equalizer_response.cpp:473
void setHighSliders(SynthSlider *cutoff, SynthSlider *resonance, SynthSlider *gain)
Assigns the sliders for the high band.
Definition equalizer_response.cpp:522
void mouseUp(const MouseEvent &e) override
Handles mouse up events, finalizing any changes made during drag.
Definition equalizer_response.cpp:360
void setControlPointBounds(float selected_x, float selected_y, float unselected_x1, float unselected_y1, float unselected_x2, float unselected_y2)
Sets the bounds for the control points (selected and unselected) in normalized coordinates.
Definition equalizer_response.cpp:227
void setActive(bool active)
Sets the active state of the EQ visualization.
Definition equalizer_response.cpp:539
virtual void destroy(OpenGlWrapper &open_gl) override
Destroys OpenGL resources.
Definition equalizer_response.cpp:206
void mouseExit(const MouseEvent &e) override
Handles mouse exit events to hide popups or reset state.
Definition equalizer_response.cpp:371
static constexpr float kDefaultDbBufferRatio
Ratio of dB range used as a buffer around min/max gain values.
Definition equalizer_response.h:27
void setNotch(bool notch)
Configures the mid band as a notch filter (or a shelf).
Definition equalizer_response.cpp:549
void mouseDown(const MouseEvent &e) override
Handles mouse down events to select a band.
Definition equalizer_response.cpp:330
void setHighPass(bool high_pass)
Configures the low band as a high-pass filter (or a shelf).
Definition equalizer_response.cpp:544
void mouseDrag(const MouseEvent &e) override
Handles mouse drag events to adjust filter settings.
Definition equalizer_response.cpp:355
void initEq(const vital::output_map &mono_modulations)
Initializes the Equalizer response for a standard 3-band EQ using the provided outputs.
Definition equalizer_response.cpp:72
~EqualizerResponse()
Destructor.
EqualizerResponse()
Constructs an EqualizerResponse component.
Definition equalizer_response.cpp:7
void setLowPass(bool low_pass)
Configures the high band as a low-pass filter (or a shelf).
Definition equalizer_response.cpp:554
void paintBackground(Graphics &g) override
Paints the background and optionally draws frequency lines.
Definition equalizer_response.cpp:288
int getHoveredBand(const MouseEvent &e)
Determines which band is currently hovered by the mouse.
Definition equalizer_response.cpp:379
void mouseWheelMove(const MouseEvent &e, const MouseWheelDetails &wheel) override
Handles mouse wheel movements for adjusting resonance if hovering over a band.
Definition equalizer_response.cpp:317
static constexpr int kResolution
Number of points used for resolution in the frequency response display.
Definition equalizer_response.h:21
void setLowSliders(SynthSlider *cutoff, SynthSlider *resonance, SynthSlider *gain)
Assigns the sliders for the low band.
Definition equalizer_response.cpp:495
static constexpr int kViewSampleRate
A high view sample rate for accurate visualization (not actual audio processing).
Definition equalizer_response.h:24
void initReverb(const vital::output_map &mono_modulations)
Initializes the Equalizer response for a reverb's shelving EQ.
Definition equalizer_response.cpp:84
virtual void init(OpenGlWrapper &open_gl) override
Initializes OpenGL resources.
Definition equalizer_response.cpp:91
void setBandSliders(SynthSlider *cutoff, SynthSlider *resonance, SynthSlider *gain)
Assigns the sliders for the mid (band) band.
Definition equalizer_response.cpp:510
void setSelectedBand(int selected_band)
Sets the currently selected band.
Definition equalizer_response.cpp:534
void computeFilterCoefficients()
Computes the filter coefficients based on current slider values and states.
Definition equalizer_response.cpp:434
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the EQ response and control points.
Definition equalizer_response.cpp:189
Point< float > getLowPosition()
Returns the current low band control point position in component coordinates.
Definition equalizer_response.cpp:401
void drawResponse(OpenGlWrapper &open_gl, int index)
Draws the response of the filters.
Definition equalizer_response.cpp:122
Point< float > getHighPosition()
Returns the current high band control point position in component coordinates.
Definition equalizer_response.cpp:424
Point< float > getBandPosition()
Returns the current mid (band) control point position in component coordinates.
Definition equalizer_response.cpp:411
static std::unique_ptr< OpenGLShaderProgram::Attribute > getAttribute(const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name)
Retrieves an attribute from the shader program if it exists.
Definition open_gl_component.h:79
void renderCorners(OpenGlWrapper &open_gl, bool animate, Colour color, float rounding)
Renders the corner shapes using the given color and rounding amount.
Definition open_gl_component.cpp:153
force_inline void checkGlError()
Checks for and asserts that there are no OpenGL errors.
Definition open_gl_component.h:231
float findValue(Skin::ValueId value_id)
Finds a float value from the skin associated with this component's parent.
Definition open_gl_component.cpp:173
static std::unique_ptr< OpenGLShaderProgram::Uniform > getUniform(const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name)
Retrieves a uniform from the shader program if it exists.
Definition open_gl_component.h:64
virtual void paintBackground(Graphics &g)
Paints a standard background for the component.
Definition open_gl_component.cpp:105
A component for rendering lines with optional filling and boost effects using OpenGL.
Definition open_gl_line_renderer.h:16
virtual void init(OpenGlWrapper &open_gl) override
Initializes OpenGL resources for rendering the line.
Definition open_gl_line_renderer.cpp:78
virtual void destroy(OpenGlWrapper &open_gl) override
Destroys OpenGL resources allocated by this line renderer.
Definition open_gl_line_renderer.cpp:468
force_inline void setFillCenter(float fill_center)
Sets the vertical center for the fill area.
Definition open_gl_line_renderer.h:138
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the line using OpenGL.
Definition open_gl_line_renderer.cpp:464
force_inline void setYAt(int index, float val)
Sets the y-coordinate of a point, marking data as dirty.
Definition open_gl_line_renderer.h:98
force_inline void setFill(bool fill)
Enables or disables filling below the line.
Definition open_gl_line_renderer.h:124
force_inline void setXAt(int index, float val)
Sets the x-coordinate of a point, marking data as dirty.
Definition open_gl_line_renderer.h:105
force_inline void setFillColors(Colour fill_color_from, Colour fill_color_to)
Sets a gradient fill from one color to another.
Definition open_gl_line_renderer.h:132
force_inline void setLineWidth(float width)
Sets the line width in pixels.
Definition open_gl_line_renderer.h:66
force_inline void setColor(Colour color)
Sets the line color.
Definition open_gl_line_renderer.h:63
void setThickness(float thickness, bool reset=false)
Sets the thickness used by some shaders and can reset to this thickness.
Definition open_gl_multi_quad.h:338
virtual void init(OpenGlWrapper &open_gl) override
Initializes OpenGL buffers and shader attributes.
Definition open_gl_multi_quad.cpp:37
void setQuad(int i, float x, float y, float w, float h)
Sets the position and size of a quad in normalized device space.
Definition open_gl_multi_quad.h:313
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the quads using OpenGL.
Definition open_gl_multi_quad.cpp:92
virtual void destroy(OpenGlWrapper &open_gl) override
Releases OpenGL resources when the component is destroyed.
Definition open_gl_multi_quad.cpp:69
force_inline void setColor(Colour color)
Sets the base color for the quads.
Definition open_gl_multi_quad.h:102
Manages and provides access to vertex and fragment shaders used by the OpenGL rendering pipeline.
Definition shaders.h:19
@ kEqFilterResponseVertex
Definition shaders.h:44
@ kColorFragment
Definition shaders.h:63
OpenGLShaderProgram * getShaderProgram(VertexShader vertex_shader, FragmentShader fragment_shader, const GLchar **varyings=nullptr)
Retrieves or creates an OpenGLShaderProgram from a given vertex and fragment shader pair.
Definition shaders.cpp:953
@ kWidgetLineWidth
Definition skin.h:105
@ kWidgetFillFade
Definition skin.h:108
@ kWidgetPrimaryDisabled
Definition skin.h:167
@ kWidgetPrimary2
Definition skin.h:166
@ kWidgetPrimary1
Definition skin.h:165
@ kWidgetSecondary1
Definition skin.h:168
@ kLightenScreen
Definition skin.h:141
@ kWidgetSecondaryDisabled
Definition skin.h:170
@ kWidgetSecondary2
Definition skin.h:169
A specialized slider with extended functionality for modulation, parameter control,...
Definition synth_slider.h:314
void addSliderListener(SliderListener *listener)
Definition synth_slider.cpp:631
void hidePopup(bool primary)
Definition synth_slider.cpp:640
void showPopup(bool primary)
Definition synth_slider.cpp:635
virtual void mouseWheelMove(const MouseEvent &e, const MouseWheelDetails &wheel) override
Definition synth_slider.cpp:346
void setDriveCompensation(bool drive_compensation)
Enables or disables drive compensation (reducing drive as resonance increases).
Definition digital_svf.h:407
poly_float getMidiCutoff() const
Retrieves the current MIDI-based cutoff frequency.
Definition digital_svf.h:345
poly_float getResonance() const
Retrieves the current resonance value (inverted if needed).
Definition digital_svf.h:351
void setupFilter(const FilterState &filter_state) override
Configures this SVF based on a FilterState (cutoff, resonance, style, etc.).
Definition digital_svf.cpp:237
poly_float getBandAmount() const
Retrieves the current band-frequency mix portion.
Definition digital_svf.h:363
poly_float getHighAmount() const
Retrieves the current high-frequency mix portion.
Definition digital_svf.h:369
poly_float getLowAmount() const
Retrieves the current low-frequency mix portion.
Definition digital_svf.h:357
force_inline bool enabled() const
Checks if this Processor is enabled.
Definition processor.h:310
virtual void setSampleRate(int sample_rate)
Updates the sample rate of this Processor (scaled by oversampling).
Definition processor.h:285
poly_float pass_blend
Blend parameter in [0..2], controlling pass type.
Definition synth_filter.h:117
int style
Filter style enum (e.g., k12Db, k24Db)
Definition synth_filter.h:116
poly_float gain
Additional gain parameter.
Definition synth_filter.h:115
poly_float midi_cutoff
MIDI note-based cutoff value.
Definition synth_filter.h:110
poly_float resonance_percent
Resonance parameter in [0..1].
Definition synth_filter.h:112
@ kNotchPassSwap
Definition synth_filter.h:77
@ kShelving
Definition synth_filter.h:80
@ k12Db
Definition synth_filter.h:75
cr::Value gain
Relative gain for this formant stage.
Definition formant_filter.cpp:17
cr::Value resonance
Resonance factor for this formant.
Definition formant_filter.cpp:18
force_inline poly_float clamp(poly_float value, mono_float min, mono_float max)
Clamps each lane of a vector to [min, max].
Definition poly_utils.h:306
force_inline poly_float midiNoteToFrequency(poly_float value)
Converts a MIDI note to a frequency (vectorized).
Definition poly_utils.h:123
std::map< std::string, Output * > output_map
Maps parameter names to Output pointers, representing output signals from various modules.
Definition synth_types.h:229
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174
OpenGLContext & context
The OpenGLContext for current rendering.
Definition shaders.h:181
Shaders * shaders
Pointer to the Shaders instance providing compiled shaders.
Definition shaders.h:182
Holds and manages a buffer of samples (poly_float) for a Processor's output.
Definition processor.h:35
Processor * owner
Owning processor.
Definition processor.h:112
poly_float trigger_value
Trigger values for voices.
Definition processor.h:116
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600
Provides various utility functions, classes, and constants for audio, math, and general-purpose opera...