![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
A material that visualizes audio data as a spectrum. More...
#include <SpectrumAnalyzer.h>
Public Member Functions | |
SpectrumAnalyzer (Vector2D size, Vector2D offset, bool bounce=false, bool flipY=false, bool mirrorY=false) | |
Constructor for SpectrumAnalyzer. | |
~SpectrumAnalyzer () | |
Destructor for SpectrumAnalyzer. | |
void | SetMirrorYState (bool state) |
Sets the mirroring state for the visualization. | |
void | SetFlipYState (bool state) |
Sets the flipping state for the visualization. | |
void | SetMaterial (Material *material) |
Sets a custom material for additional effects. | |
float * | GetFourierData () |
Retrieves the Fourier data used for visualization. | |
void | SetSize (Vector2D size) |
Sets the size of the visualization area. | |
void | SetPosition (Vector2D offset) |
Sets the position of the visualization area. | |
void | SetRotation (float angle) |
Sets the rotation angle of the visualization. | |
void | SetHueAngle (float hueAngle) |
Sets the hue adjustment angle for the spectrum colors. | |
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. | |
![]() | |
virtual | ~Material ()=default |
Virtual destructor for proper cleanup in derived classes. | |
Private Attributes | |
BouncePhysics * | bPhy [128] |
Array of bounce physics objects for each frequency bin. | |
Vector2D | size |
Size of the visualization area. | |
Vector2D | offset |
Offset position of the visualization area. | |
float | angle = 0.0f |
Rotation angle of the visualization. | |
float | hueAngle = 0.0f |
Hue adjustment angle for the spectrum colors. | |
uint8_t | colors |
Number of colors in the gradient. | |
float * | data |
Pointer to the input audio data. | |
float | bounceData [128] |
Processed bounce data for visualization. | |
uint8_t | bins = 128 |
Number of frequency bins. | |
bool | mirrorY = false |
Whether to mirror the visualization along the Y-axis. | |
bool | flipY = false |
Whether to flip the visualization along the Y-axis. | |
bool | bounce = false |
Whether to apply bouncing animation to the spectrum. | |
RGBColor | rainbowSpectrum [6] |
Predefined rainbow color gradient. | |
GradientMaterial< 6 > | gM = GradientMaterial<6>(rainbowSpectrum, 1.0f, false) |
Gradient material for coloring the spectrum. | |
Material * | material |
Optional sub-material for additional effects. | |
Additional Inherited Members | |
![]() | |
enum | Method { Base , Add , Subtract , Multiply , Divide , Darken , Lighten , Screen , Overlay , SoftLight , Replace , EfficientMask , Bypass } |
Defines blending methods for combining colors. More... | |
A material that visualizes audio data as a spectrum.
The SpectrumAnalyzer class processes audio data to create a colorful and dynamic spectrum visualization with options for customization, including mirroring and flipping.
Definition at line 25 of file SpectrumAnalyzer.h.
SpectrumAnalyzer | ( | Vector2D | size, |
Vector2D | offset, | ||
bool | bounce = false , |
||
bool | flipY = false , |
||
bool | mirrorY = false |
||
) |
Constructor for SpectrumAnalyzer.
size | The size of the visualization area. |
offset | The offset position of the visualization. |
bounce | Enables bouncing animation for the spectrum. |
flipY | Enables flipping the visualization along the Y-axis. |
mirrorY | Enables mirroring the visualization along the Y-axis. |
Definition at line 3 of file SpectrumAnalyzer.cpp.
References bounce, bPhy, Vector2D::Divide(), flipY, gM, material, mirrorY, offset, and size.
~SpectrumAnalyzer | ( | ) |
Destructor for SpectrumAnalyzer.
Definition at line 18 of file SpectrumAnalyzer.cpp.
References bPhy.
float * GetFourierData | ( | ) |
Retrieves the Fourier data used for visualization.
Definition at line 36 of file SpectrumAnalyzer.cpp.
References bounce, bounceData, and data.
|
overridevirtual |
Computes the color at a given position in the material.
position | The position in 3D space. |
normal | The surface normal vector. |
uvw | The texture coordinates. |
Implements Material.
Definition at line 72 of file SpectrumAnalyzer.cpp.
References angle, bins, bounce, bounceData, Mathematics::CosineInterpolation(), data, flipY, Material::GetRGB(), hueAngle, RGBColor::HueShift(), Mathematics::IsClose(), Mathematics::Map(), material, mirrorY, offset, Vector2D::Rotate(), size, Vector2D::X, Vector3D::X, Vector2D::Y, and Vector3D::Y.
Sets the flipping state for the visualization.
state | True to enable flipping along the Y-axis, false to disable. |
Definition at line 28 of file SpectrumAnalyzer.cpp.
References flipY.
Referenced by AphoriAnimation::Update(), ArtleckAnimationV2::Update(), BasilGardenAnimation::Update(), BroookAnimation::Update(), ElGatoAnimation::Update(), GalaxyAnimation::Update(), HertzzAnimation::Update(), InfraredAnimation::Update(), LeonHuskyAnimation::Update(), MyntAnimation::Update(), ProtobottAnimation::Update(), SammyAnimation::Update(), SergaliciousAnimation::Update(), StrawberryAnimation::Update(), TamamoAnimation::Update(), TechSaneAnimation::Update(), VesperAnimation::Update(), WaffleDaProtoAnimation::Update(), WarzoneAnimation::Update(), Warzone2Animation::Update(), XenraxAnimation::Update(), AlphaAnimation::Update(), GammaAnimation::Update(), HUB75AnimationSplit::Update(), WS35AnimationSplit::Update(), and ProtogenProject::UpdateFace().
Sets the hue adjustment angle for the spectrum colors.
hueAngle | The hue adjustment angle in degrees. |
Definition at line 56 of file SpectrumAnalyzer.cpp.
References hueAngle.
Referenced by AphoriAnimation::Update(), ArtleckAnimationV2::Update(), BasilGardenAnimation::Update(), BroookAnimation::Update(), ElGatoAnimation::Update(), GalaxyAnimation::Update(), HertzzAnimation::Update(), InfraredAnimation::Update(), LeonHuskyAnimation::Update(), MyntAnimation::Update(), ProtobottAnimation::Update(), SammyAnimation::Update(), SergaliciousAnimation::Update(), StrawberryAnimation::Update(), TamamoAnimation::Update(), TechSaneAnimation::Update(), VesperAnimation::Update(), WaffleDaProtoAnimation::Update(), WarzoneAnimation::Update(), Warzone2Animation::Update(), XenraxAnimation::Update(), AlphaAnimation::Update(), GammaAnimation::Update(), HUB75AnimationSplit::Update(), WS35AnimationSplit::Update(), and ProtogenProject::UpdateFace().
Sets a custom material for additional effects.
material | Pointer to the custom material. |
Definition at line 32 of file SpectrumAnalyzer.cpp.
References material.
Sets the mirroring state for the visualization.
state | True to enable mirroring along the Y-axis, false to disable. |
Definition at line 24 of file SpectrumAnalyzer.cpp.
References mirrorY.
Referenced by AphoriAnimation::Update(), ArtleckAnimationV2::Update(), BasilGardenAnimation::Update(), BroookAnimation::Update(), ElGatoAnimation::Update(), GalaxyAnimation::Update(), HertzzAnimation::Update(), InfraredAnimation::Update(), LeonHuskyAnimation::Update(), MyntAnimation::Update(), ProtobottAnimation::Update(), SammyAnimation::Update(), SergaliciousAnimation::Update(), StrawberryAnimation::Update(), TamamoAnimation::Update(), TechSaneAnimation::Update(), VesperAnimation::Update(), WaffleDaProtoAnimation::Update(), WarzoneAnimation::Update(), Warzone2Animation::Update(), XenraxAnimation::Update(), AlphaAnimation::Update(), GammaAnimation::Update(), HUB75AnimationSplit::Update(), WS35AnimationSplit::Update(), and ProtogenProject::UpdateFace().
Sets the position of the visualization area.
offset | The new position as a Vector2D. |
Definition at line 48 of file SpectrumAnalyzer.cpp.
References offset.
Referenced by ProtogenProject::ProtogenProject().
Sets the rotation angle of the visualization.
angle | The rotation angle in degrees. |
Definition at line 52 of file SpectrumAnalyzer.cpp.
References angle.
Referenced by AlphaAnimation::Update().
Sets the size of the visualization area.
size | The new size as a Vector2D. |
Definition at line 44 of file SpectrumAnalyzer.cpp.
References Vector2D::Divide(), and size.
Referenced by ProtogenProject::ProtogenProject().
Updates the spectrum visualization with new audio data.
readData | Pointer to the new audio data. |
Definition at line 60 of file SpectrumAnalyzer.cpp.
References bounce, bounceData, bPhy, BouncePhysics::Calculate(), and data.
Referenced by ProtogenProject::SpectrumAnalyzerFace(), AphoriAnimation::Update(), ArtleckAnimationV2::Update(), BasilGardenAnimation::Update(), BroookAnimation::Update(), ElGatoAnimation::Update(), HertzzAnimation::Update(), InfraredAnimation::Update(), LeonHuskyAnimation::Update(), MyntAnimation::Update(), ProtobottAnimation::Update(), SammyAnimation::Update(), SergaliciousAnimation::Update(), StrawberryAnimation::Update(), TamamoAnimation::Update(), TechSaneAnimation::Update(), VesperAnimation::Update(), WaffleDaProtoAnimation::Update(), WarzoneAnimation::Update(), Warzone2Animation::Update(), XenraxAnimation::Update(), AlphaAnimation::Update(), GammaAnimation::Update(), HUB75AnimationSplit::Update(), and WS35AnimationSplit::Update().
|
private |
Rotation angle of the visualization.
Definition at line 30 of file SpectrumAnalyzer.h.
Referenced by GetRGB(), and SetRotation().
|
private |
Whether to apply bouncing animation to the spectrum.
Definition at line 38 of file SpectrumAnalyzer.h.
Referenced by GetFourierData(), GetRGB(), SpectrumAnalyzer(), and Update().
|
private |
Processed bounce data for visualization.
Definition at line 34 of file SpectrumAnalyzer.h.
Referenced by GetFourierData(), GetRGB(), and Update().
|
private |
Array of bounce physics objects for each frequency bin.
Definition at line 27 of file SpectrumAnalyzer.h.
Referenced by SpectrumAnalyzer(), Update(), and ~SpectrumAnalyzer().
|
private |
Number of colors in the gradient.
Definition at line 32 of file SpectrumAnalyzer.h.
|
private |
Pointer to the input audio data.
Definition at line 33 of file SpectrumAnalyzer.h.
Referenced by GetFourierData(), GetRGB(), and Update().
Whether to flip the visualization along the Y-axis.
Definition at line 37 of file SpectrumAnalyzer.h.
Referenced by GetRGB(), SetFlipYState(), and SpectrumAnalyzer().
|
private |
Gradient material for coloring the spectrum.
Definition at line 49 of file SpectrumAnalyzer.h.
Referenced by SpectrumAnalyzer().
|
private |
Hue adjustment angle for the spectrum colors.
Definition at line 31 of file SpectrumAnalyzer.h.
Referenced by GetRGB(), and SetHueAngle().
|
private |
Optional sub-material for additional effects.
Definition at line 50 of file SpectrumAnalyzer.h.
Referenced by GetRGB(), SetMaterial(), and SpectrumAnalyzer().
Whether to mirror the visualization along the Y-axis.
Definition at line 36 of file SpectrumAnalyzer.h.
Referenced by GetRGB(), SetMirrorYState(), and SpectrumAnalyzer().
|
private |
Offset position of the visualization area.
Definition at line 29 of file SpectrumAnalyzer.h.
Referenced by GetRGB(), SetPosition(), and SpectrumAnalyzer().
|
private |
|
private |
Size of the visualization area.
Definition at line 28 of file SpectrumAnalyzer.h.
Referenced by GetRGB(), SetSize(), and SpectrumAnalyzer().