3#include "../Animation.h"
4#include "../KeyFrameTrack.h"
5#include "../EasyEaseAnimator.h"
6#include "../../Objects/Background.h"
7#include "../../Objects/LEDStripBackground.h"
8#include "../../Morph/ProtoV2Morph.h"
9#include "../../Render/Scene.h"
10#include "../../Signals/FunctionGenerator.h"
11#include "../../Menu/Menu.h"
12#include "../../Sensors/APDS9960.h"
13#include "../../Sensors/SSD1306.h"
15#include "../../Materials/Animated/RainbowNoise.h"
16#include "../../Materials/Animated/RainbowSpiral.h"
17#include "../../Materials/Animated/SpectrumAnalyzer.h"
18#include "../../Materials/Animated/AudioReactiveGradient.h"
19#include "../../Materials/Animated/Oscilloscope.h"
21#include "../../Materials/MaterialAnimator.h"
23#include "../AnimationTracks/BlinkTrack.h"
25#include "../../Signals/FFTVoiceDetection.h"
27#include "../../Sensors/MicrophoneFourier_MAX9814.h"
88 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Normal), ProtoV2::Normal, 15, 0.0f, 1.0f);
89 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Blush), ProtoV2::Blush, 25, 0.0f, 1.0f);
90 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Hideblush), ProtoV2::Hideblush, 25, 0.0f, 1.0f);
91 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Squint), ProtoV2::Squint, 30, 0.0f, 1.0f);
92 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Surprised), ProtoV2::Surprised, 10, 0.0f, 1.0f);
93 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Happy), ProtoV2::Happy, 20, 0.0f, 1.0f);
94 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Sad), ProtoV2::Sad, 45, 0.0f, 1.0f);
95 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Talk), ProtoV2::Talk, 2, 0.0f, 1.0f);
96 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Whoop), ProtoV2::Whoop, 30, 0.0f, 1.0f);
97 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Side1), ProtoV2::Side1, 30, 0.0f, 1.0f);
98 eEA.
AddParameter(
pM.GetMorphWeightReference(ProtoV2::Angry), ProtoV2::Angry, 20, 0.0f, 1.0f);
141 oledDisplay.Display(F(
"Animating..."), F(
"Face: "), F(
"Default"));
146 oledDisplay.Display(F(
"Animating..."), F(
"Face: "), F(
"Squint"));
152 oledDisplay.Display(F(
"Animating..."), F(
"Face: "), F(
"Surprised"));
158 oledDisplay.Display(F(
"Animating..."), F(
"Face: "), F(
"Happy"));
164 oledDisplay.Display(F(
"Animating..."), F(
"Face: "), F(
"Sad"));
170 oledDisplay.Display(F(
"Animating..."), F(
"Face: "), F(
"Whoop"));
176 oledDisplay.Display(F(
"Animating..."), F(
"Face: "), F(
"Angry"));
182 oledDisplay.Display(F(
"Animating..."), F(
"Face: "), F(
"Blush"));
187 oledDisplay.Display(F(
"Animating..."), F(
"Audio: "), F(
"Fourier"));
195 oledDisplay.Display(F(
"Animating..."), F(
"Audio: "), F(
"Round"));
203 oledDisplay.Display(F(
"Animating..."), F(
"Audio: "), F(
"Oscillo"));
214 if(MicrophoneFourierIT::GetCurrentMagnitude() > 0.05f){
247 scene.AddObject(
pM.GetObject());
263 MicrophoneFourierIT::Initialize(22, 8000, 50.0f, 120.0f);
271 return pM.GetObject();
287 MicrophoneFourierIT::Update();
293 aRG.
SetSize(
Vector2D((xOffset + 2.0f) * 10.0f + 50.0f, (xOffset + 2.0f) * 10.0f + 50.0f));
311 else if (mode == 1)
Squint();
312 else if (mode == 2)
Happy();
313 else if (mode == 3)
Sad();
314 else if (mode == 4)
Whoop();
315 else if (mode == 5)
Angry();
317 else if (mode == 7) {
318 aRG.
Update(MicrophoneFourierIT::GetFourierFiltered());
322 oSC.
Update(MicrophoneFourierIT::GetSamples());
326 sA.
Update(MicrophoneFourierIT::GetFourierFiltered());
347 float scale = menuRatio * 0.5f + 0.5f;
348 float xShift = (1.0f - menuRatio) * -10.0f;
349 float yShift = (1.0f - menuRatio) * 70.0f +
offsetFaceSA * -150.0f;
350 float adjustFacePos = float(4 - faceSize) * 5.0f;
351 float adjustFaceX = float(faceSize) * 0.05f;
353 pM.GetObject()->GetTransform()->SetPosition(
Vector3D(20.0f + xOffset, 0.0f + yOffset, 600.0f));
356 pM.GetObject()->GetTransform()->SetRotation(
Vector3D(sinf(ratio * 3.14159f / 180.0f * 1440.0f) * 1.0f, sinf(ratio * 3.14159f / 180.0f * 720.0f) * 1.0f, 0.0f));
358 pM.GetObject()->UpdateTransform();
A class for managing the Adafruit APDS9960 sensor.
static bool Initialize(uint8_t threshold)
Initializes the APDS9960 sensor.
static bool isBooped()
Checks if the sensor is "booped" (close proximity detected).
void AddParameter(float *parameter)
Adds a parameter to the animation track.
float Update()
Updates the animation track and returns the current parameter value.
A material class for creating an audio-reactive gradient effect.
void SetRadius(float radius)
Sets the radius for circular gradient patterns.
void SetPosition(Vector2D offset)
Sets the position of the gradient.
void Update(float *readData)
Updates the gradient based on new audio data.
void SetSize(Vector2D size)
Sets the size of the gradient.
void SetRotation(float angle)
Sets the rotation angle of the gradient.
void SetHueAngle(float hueAngle)
Sets the hue angle for color adjustments.
A template class for animating eye blinking using keyframes.
A template class for implementing advanced animation easing.
void AddParameterFrame(uint16_t dictionaryValue, float value) override
Adds a single frame value for a parameter.
void Update() override
Updates the animator, advancing all animations.
void SetInterpolationMethod(uint16_t dictionaryValue, InterpolationMethod interpMethod) override
Sets the interpolation method for a specific parameter.
void AddParameter(float *parameter, uint16_t dictionaryValue, uint16_t frames, float basis, float goal) override
Adds a parameter to the animator.
Detects visemes based on FFT voice analysis.
void SetThreshold(float threshold)
Sets the threshold for formant calculations.
A class to generate various waveform functions with customizable parameters.
@ Triangle
Triangle waveform.
float Update()
Updates and calculates the next value of the waveform.
Creates a customizable gradient material for rendering.
FunctionGenerator fGenMatHue
SimpleMaterial greenMaterial
FunctionGenerator fGenMatYMove
SimpleMaterial redMaterial
void UpdateKeyFrameTracks()
RainbowSpiral rainbowSpiral
SimpleMaterial blueMaterial
FunctionGenerator fGenMatRMenu
void AudioReactiveGradientFace()
SimpleMaterial yellowMaterial
void ChangeInterpolationMethods()
GradientMaterial< 2 > gradientMat
void SpectrumAnalyzerFace()
FunctionGenerator fGenMatPos
FunctionGenerator fGenScale
FunctionGenerator fGenRotation
SimpleMaterial orangeMaterial
FunctionGenerator fGenMatXMenu
FunctionGenerator sineSidePanel
void FadeIn(float stepRatio) override
void FadeOut(float stepRatio) override
RainbowNoise rainbowNoise
FunctionGenerator fGenMatYMenu
FunctionGenerator fGenMatXMove
MaterialAnimator< 10 > materialAnimator
SimpleMaterial purpleMaterial
void Update(float ratio) override
FFTVoiceDetection< 128 > voiceDetection
RGBColor gradientSpectrum[2]
MaterialAnimator< 4 > backgroundMaterial
EasyEaseAnimator< 21 > eEA
SimpleMaterial whiteMaterial
AudioReactiveGradient aRG
Animates transitions and blends between multiple materials.
void AddMaterial(Material::Method method, Material *material, uint16_t frames, float minOpacity, float maxOpacity)
Adds a material to the animation with specified properties.
void SetBaseMaterial(Material::Method method, Material *material)
Sets the base material for the animation.
void AddMaterialFrame(Material &material, float opacity)
Adds a specific frame for a material in the animation.
void Update()
Updates the animator, advancing the transitions.
@ Lighten
Chooses the lighter color.
@ Add
Adds colors together.
@ Replace
Replaces the base color.
Represents a 3D object with geometry, material, and transformation data.
A dynamic oscilloscope material for visualizing audio signals.
void SetPosition(Vector2D offset)
Sets the position of the oscilloscope visualization.
void SetSize(Vector2D size)
Sets the size of the oscilloscope visualization.
void Update(float *data)
Updates the oscilloscope visualization based on new audio data.
void SetHueAngle(float hueAngle)
Sets the hue angle for color adjustments.
Represents an RGB color and provides methods for manipulation.
A dynamic material that creates a rainbow effect using simplex noise.
void Update(float ratio)
Updates the material animation based on the time ratio.
A dynamic material creating a colorful rainbow spiral animation.
void Update(float ratio)
Updates the material animation based on the time ratio.
A material that applies a single, solid RGB color to surfaces.
A material that visualizes audio data as a spectrum.
void SetMirrorYState(bool state)
Sets the mirroring state for the visualization.
void Update(float *readData)
Updates the spectrum visualization with new audio data.
void SetFlipYState(bool state)
Sets the flipping state for the visualization.
void SetHueAngle(float hueAngle)
Sets the hue adjustment angle for the spectrum colors.
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.