ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Oscilloscope Class Reference

A dynamic oscilloscope material for visualizing audio signals. More...

#include <Oscilloscope.h>

Inheritance diagram for Oscilloscope:
Collaboration diagram for Oscilloscope:

Public Member Functions

 Oscilloscope (Vector2D size, Vector2D offset)
 Constructs an Oscilloscope with the specified size and offset.
 
 ~Oscilloscope ()
 Destroys the Oscilloscope instance.
 
void SetMaterial (Material *material)
 Sets an additional material for visual effects.
 
floatGetSampleData ()
 Retrieves the current sample data.
 
void SetSize (Vector2D size)
 Sets the size of the oscilloscope visualization.
 
void SetPosition (Vector2D offset)
 Sets the position of the oscilloscope visualization.
 
void SetRotation (float angle)
 Sets the rotation angle of the visualization.
 
void SetHueAngle (float hueAngle)
 Sets the hue angle for color adjustments.
 
void Update (float *data)
 Updates the oscilloscope visualization based on new audio data.
 
RGBColor GetRGB (const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
 Computes the color at a given position in the visualization.
 
- Public Member Functions inherited from Material
virtual ~Material ()=default
 Virtual destructor for proper cleanup in derived classes.
 

Private Attributes

BouncePhysicsbPhy [128]
 Array of BouncePhysics instances for dynamic bouncing behavior.
 
Vector2D size
 The size of the oscilloscope visualization.
 
Vector2D offset
 The position offset of the visualization.
 
float angle = 0.0f
 Rotation angle of the visualization.
 
float hueAngle = 0.0f
 Hue angle for color adjustments.
 
float radius = 40.0f
 Radius for circular visualization patterns.
 
uint8_t colors
 Number of colors in the gradient.
 
floatdata
 Pointer to the audio sample data.
 
float midPoint = 0.0f
 Midpoint for audio data normalization.
 
uint8_t bins = 128
 Number of bins for audio data processing.
 
MaxFilter< 40 > maxF = MaxFilter<40>()
 Filter for tracking maximum values.
 
MinFilter< 40 > minF = MinFilter<40>()
 Filter for tracking minimum values.
 
RGBColor rainbowSpectrum [6] = {RGBColor(255, 0, 0), RGBColor(255, 255, 0), RGBColor(0, 255, 0), RGBColor(0, 255, 255), RGBColor(0, 0, 255), RGBColor(255, 0, 255)}
 Predefined rainbow colors.
 
GradientMaterial< 6 > gM = GradientMaterial<6>(rainbowSpectrum, 1.0f, false)
 Gradient material for the rainbow spectrum.
 
Materialmaterial
 Pointer to an additional material for effects.
 
float minValue
 
float maxValue
 Minimum and maximum values for data scaling.
 

Additional Inherited Members

- Public Types inherited from Material
enum  Method {
  Base , Add , Subtract , Multiply ,
  Divide , Darken , Lighten , Screen ,
  Overlay , SoftLight , Replace , EfficientMask ,
  Bypass
}
 Defines blending methods for combining colors. More...
 

Detailed Description

A dynamic oscilloscope material for visualizing audio signals.

The Oscilloscope class provides real-time visualization of audio signals, featuring bouncing physics, gradient colors, and customizable attributes such as size, position, and rotation.

Definition at line 29 of file Oscilloscope.h.

Constructor & Destructor Documentation

◆ Oscilloscope()

Oscilloscope ( Vector2D  size,
Vector2D  offset 
)

Constructs an Oscilloscope with the specified size and offset.

Parameters
sizeThe size of the oscilloscope visualization.
offsetThe position offset of the visualization.

Definition at line 3 of file Oscilloscope.cpp.

References Vector2D::Divide(), gM, material, offset, and size.

◆ ~Oscilloscope()

Destroys the Oscilloscope instance.

Definition at line 9 of file Oscilloscope.cpp.

References bPhy.

Member Function Documentation

◆ GetRGB()

RGBColor GetRGB ( const Vector3D position,
const Vector3D normal,
const Vector3D uvw 
)
overridevirtual

Computes the color at a given position in the visualization.

Parameters
positionThe position in 3D space.
normalThe surface normal vector.
uvwThe texture coordinates.
Returns
The computed color as an RGBColor.

Implements Material.

Definition at line 48 of file Oscilloscope.cpp.

References angle, bins, Mathematics::CosineInterpolation(), data, Material::GetRGB(), hueAngle, RGBColor::HueShift(), Mathematics::IsClose(), Mathematics::Map(), material, maxValue, minValue, offset, Vector2D::Rotate(), size, Vector2D::X, Vector3D::X, Vector2D::Y, and Vector3D::Y.

◆ GetSampleData()

float * GetSampleData ( )

Retrieves the current sample data.

Returns
Pointer to the audio sample data array.

Definition at line 19 of file Oscilloscope.cpp.

References data.

◆ SetHueAngle()

◆ SetMaterial()

void SetMaterial ( Material material)

Sets an additional material for visual effects.

Parameters
materialPointer to the Material instance.

Definition at line 15 of file Oscilloscope.cpp.

References material.

◆ SetPosition()

◆ SetRotation()

void SetRotation ( float  angle)

Sets the rotation angle of the visualization.

Parameters
angleThe new rotation angle in degrees.

Definition at line 31 of file Oscilloscope.cpp.

References angle.

Referenced by GammaAnimation::Update().

◆ SetSize()

◆ Update()

Member Data Documentation

◆ angle

float angle = 0.0f
private

Rotation angle of the visualization.

Definition at line 34 of file Oscilloscope.h.

Referenced by GetRGB(), and SetRotation().

◆ bins

uint8_t bins = 128
private

Number of bins for audio data processing.

Definition at line 40 of file Oscilloscope.h.

Referenced by GetRGB(), and Update().

◆ bPhy

BouncePhysics* bPhy[128]
private

Array of BouncePhysics instances for dynamic bouncing behavior.

Definition at line 31 of file Oscilloscope.h.

Referenced by ~Oscilloscope().

◆ colors

uint8_t colors
private

Number of colors in the gradient.

Definition at line 37 of file Oscilloscope.h.

◆ data

float* data
private

Pointer to the audio sample data.

Definition at line 38 of file Oscilloscope.h.

Referenced by GetRGB(), GetSampleData(), and Update().

◆ gM

Gradient material for the rainbow spectrum.

Definition at line 46 of file Oscilloscope.h.

Referenced by Oscilloscope().

◆ hueAngle

float hueAngle = 0.0f
private

Hue angle for color adjustments.

Definition at line 35 of file Oscilloscope.h.

Referenced by GetRGB(), and SetHueAngle().

◆ material

Material* material
private

Pointer to an additional material for effects.

Definition at line 48 of file Oscilloscope.h.

Referenced by GetRGB(), Oscilloscope(), and SetMaterial().

◆ maxF

MaxFilter<40> maxF = MaxFilter<40>()
private

Filter for tracking maximum values.

Definition at line 42 of file Oscilloscope.h.

Referenced by Update().

◆ maxValue

float maxValue
private

Minimum and maximum values for data scaling.

Definition at line 50 of file Oscilloscope.h.

Referenced by GetRGB(), and Update().

◆ midPoint

float midPoint = 0.0f
private

Midpoint for audio data normalization.

Definition at line 39 of file Oscilloscope.h.

Referenced by Update().

◆ minF

MinFilter<40> minF = MinFilter<40>()
private

Filter for tracking minimum values.

Definition at line 43 of file Oscilloscope.h.

Referenced by Update().

◆ minValue

float minValue
private

Definition at line 50 of file Oscilloscope.h.

Referenced by GetRGB(), and Update().

◆ offset

Vector2D offset
private

The position offset of the visualization.

Definition at line 33 of file Oscilloscope.h.

Referenced by GetRGB(), Oscilloscope(), and SetPosition().

◆ radius

float radius = 40.0f
private

Radius for circular visualization patterns.

Definition at line 36 of file Oscilloscope.h.

◆ rainbowSpectrum

RGBColor rainbowSpectrum[6] = {RGBColor(255, 0, 0), RGBColor(255, 255, 0), RGBColor(0, 255, 0), RGBColor(0, 255, 255), RGBColor(0, 0, 255), RGBColor(255, 0, 255)}
private

Predefined rainbow colors.

Definition at line 45 of file Oscilloscope.h.

◆ size

Vector2D size
private

The size of the oscilloscope visualization.

Definition at line 32 of file Oscilloscope.h.

Referenced by GetRGB(), Oscilloscope(), and SetSize().


The documentation for this class was generated from the following files: