12 for (uint8_t i = 0; i < 128; i++) {
19 for (uint8_t i = 0; i < 128; i++) {
63 for (uint8_t i = 0; i < 128; i++) {
88 height = height * 3.0f;
96 if (
flipY) yColor = 1.0f - yColor;
98 if (yColor <= height) {
A material for visualizing audio data as a colorful spectrum analyzer.
Simulates bouncing physics with gravity and velocity damping.
float Calculate(float velocity, unsigned long currentMillis)
Calculates the new position and velocity based on the current velocity and time.
Abstract base class for rendering materials.
virtual RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw)=0
Pure virtual function to calculate color based on surface parameters.
static bool IsClose(float v1, float v2, float epsilon)
Checks if two values are close within a specified epsilon.
static T Map(T value, T inLow, T inMax, T outMin, T outMax)
Maps a value from one range to another.
static float CosineInterpolation(float beg, float fin, float ratio)
Applies a cosine-based interpolation between two values.
Represents an RGB color and provides methods for manipulation.
RGBColor HueShift(const float &hueDeg)
Shifts the hue of the color by a specified angle in degrees.
void SetPosition(Vector2D offset)
Sets the position of the visualization area.
float bounceData[128]
Processed bounce data for visualization.
float * data
Pointer to the input audio data.
BouncePhysics * bPhy[128]
Array of bounce physics objects for each frequency bin.
float hueAngle
Hue adjustment angle for the spectrum colors.
bool flipY
Whether to flip the visualization along the Y-axis.
void SetMirrorYState(bool state)
Sets the mirroring state for the visualization.
bool bounce
Whether to apply bouncing animation to the spectrum.
float * GetFourierData()
Retrieves the Fourier data used for visualization.
void Update(float *readData)
Updates the spectrum visualization with new audio data.
RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
Computes the color at a given position in the material.
void SetFlipYState(bool state)
Sets the flipping state for the visualization.
void SetSize(Vector2D size)
Sets the size of the visualization area.
Vector2D offset
Offset position of the visualization area.
float angle
Rotation angle of the visualization.
GradientMaterial< 6 > gM
Gradient material for coloring the spectrum.
void SetMaterial(Material *material)
Sets a custom material for additional effects.
SpectrumAnalyzer(Vector2D size, Vector2D offset, bool bounce=false, bool flipY=false, bool mirrorY=false)
Constructor for SpectrumAnalyzer.
void SetRotation(float angle)
Sets the rotation angle of the visualization.
bool mirrorY
Whether to mirror the visualization along the Y-axis.
Material * material
Optional sub-material for additional effects.
~SpectrumAnalyzer()
Destructor for SpectrumAnalyzer.
uint8_t bins
Number of frequency bins.
void SetHueAngle(float hueAngle)
Sets the hue adjustment angle for the spectrum colors.
Vector2D size
Size of the visualization area.
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Vector2D Rotate(const float &angle, const Vector2D &offset) const
Rotates this vector by a specified angle (in degrees or radians) around a given offset.
Vector2D Divide(const Vector2D &vector) const
Divides this vector by another Vector2D component-wise.
float X
The X-component of the 2D vector.
float Y
The Y-component of the 2D vector.
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
float X
The X-component of the 3D vector.
float Y
The Y-component of the 3D vector.