Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
graph_scale.hpp
Go to the documentation of this file.
1#pragma once
2
13
14#include <cstddef>
15#include <span>
16#include <vector>
17
18namespace pulp::view {
19
24 float min_hz = 20.0f;
25 float max_hz = 20000.0f;
26 float x = 0.0f;
27 float width = 0.0f;
28
32 float to_x(float hz) const;
33
35 float to_frequency(float px) const;
36
41 float frequency_at(std::size_t index, std::size_t count) const;
42
45 std::vector<float> ticks() const;
46
49 static bool is_major_tick(float hz);
50};
51
56 float min_db = -24.0f;
57 float max_db = 24.0f;
58 float y = 0.0f;
59 float height = 0.0f;
60
61 float to_y(float db) const;
62 float to_decibels(float py) const;
63
66 std::vector<float> ticks(float step_db) const;
67};
68
82void resample_spectrum_log(std::span<const float> bins_db,
83 float sample_rate,
85 std::span<float> out);
86
87} // namespace pulp::view
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ px
Absolute pixels.
Definition geometry.hpp:393
void resample_spectrum_log(std::span< const float > bins_db, float sample_rate, const LogFrequencyScale &scale, std::span< float > out)
Resample a real-FFT magnitude array (bins spanning DC..Nyquist) onto out.size() log-spaced frequencie...
@ scale
Definition css_animation.hpp:126
Maps decibels to a vertical pixel position on a linear axis (dB is already logarithmic in amplitude,...
Definition graph_scale.hpp:55
std::vector< float > ticks(float step_db) const
Gridline values every step_db, always including 0 dB when it is in range (the unity line a reader loo...
float to_y(float db) const
float height
axis height, pixels
Definition graph_scale.hpp:59
float max_db
Definition graph_scale.hpp:57
float min_db
Definition graph_scale.hpp:56
float y
top edge, pixels
Definition graph_scale.hpp:58
float to_decibels(float py) const
Maps frequency (Hz) to a horizontal pixel position on a logarithmic axis.
Definition graph_scale.hpp:23
float frequency_at(std::size_t index, std::size_t count) const
Frequency of point index of count, log-spaced across the axis, so point i lands on evenly spaced pixe...
float to_x(float hz) const
Pixel x of a frequency.
float width
axis width, pixels
Definition graph_scale.hpp:27
float x
left edge, pixels
Definition graph_scale.hpp:26
static bool is_major_tick(float hz)
True for decade boundaries (100, 1k, 10k) — the lines conventionally drawn heavier and labeled.
float to_frequency(float px) const
Frequency at a pixel x. Inverse of to_x().
float max_hz
Definition graph_scale.hpp:25
std::vector< float > ticks() const
Gridline frequencies in a 1-2-5 sequence per decade (20, 30, 50, 100, 200, …) clipped to [min_hz,...
float min_hz
Definition graph_scale.hpp:24