NanoLux (Device) 3.0
Codebase for the open-source AudioLux device.
Loading...
Searching...
No Matches
globals.h
Go to the documentation of this file.
1
13
14#ifndef GLOBALS_H
15#define GLOBALS_H
16
17#include "nanolux_types.h"
18#include "audio_analysis.h"
19#include "AudioPrism.h"
20
21int formant_pose = 0;
22double formants[3]; // Master formants array that constantly changes;
23bool noise; // Master Noisiness versus Periodic flag that is TRUE when noisy, FALSE when periodic;
24bool drums[3]; // Master drums array that stores whether a KICK, SNARE, or CYMBAL is happening in each element of the array;
25double fbs[5]; // Master FIVE BAND SPLIT which stores changing bands based on raw frequencies
26double fss[5]; // Master FIVE SAMPLE SPLIT which stores changing bands based on splitting up the samples
27int salFreqs[3];
28float centroid;
29float noisiness;
30bool percussionPresent = false;
31int advanced_size = 20;
32unsigned int sampling_period_us = round(1000000 / SAMPLING_FREQUENCY);
33int F0arr[20];
34int F1arr[20];
35int F2arr[20];
36unsigned long microseconds;
37double vReal[SAMPLES]; // Sampling buffers
38double vImag[SAMPLES];
39double vRealHist[SAMPLES]; // Delta freq
40float audioPrismInput[SAMPLES];
41extern Spectrogram fftHistory;
42double delt[SAMPLES];
43double maxDelt = 0.; // Frequency with the biggest change in amp.
44unsigned long myTime; // For nvp
46
47
48//
49// Patterns structure.
50//
51// Describes a pattern by name, whether it will be presented to the user in the
52// web application and the function that implements the pattern.
53//
54typedef struct {
55 int index;
56 const char *pattern_name;
57 bool enabled;
58 void (*pattern_handler)(Strip_Buffer * buf, int len, Pattern_Data* params);
59} Pattern;
60
61//
62// Register all the patterns here. The index property must be sequential, but the code make sure
63// that constraint is satisfied. The name is arbitrary, but keep it relatively short as it will be
64// presented in a UI to the user. The enabled flag indicates whether the pattern will be shown
65// in the UI or not. If not shown, it i snot selectable. If a pattern is not registered here,
66// It will not be selectable and the loop below will not know about it.
67//
69 { 0, "None", true, blank},
70 { 1, "Equalizer", true, eq},
71 { 2, "Bands", true, bands},
72 { 3, "Splash Theory", true, splashTheory},
73 { 4, "deltaHeat", true, deltaHeat},
74 { 5, "Fire 2012", true, Fire2012},
75 { 6, "Pixel Frequency", true, pix_freq},
76 { 7, "Confetti", true, confetti},
77 { 8, "Hue Trail", true, hue_trail},
78 { 9, "Saturated", true, saturated},
79 { 10, "Groovy", true, groovy},
80 { 11, "Talking", true, talking},
81 { 12, "Glitch", true, glitch},
82 { 13, "Rain Drop", true, random_raindrop},
83 { 14, "Bar Fill", true, bar_fill},
84 { 15, "Blend In", true, blendIn},
85 { 16, "Bleed Through", true, bleedThrough},
86 { 17, "Synesthesia Rolling", true, synesthesiaRolling},
87 { 18, "Note EQ", true, noteEQ},
88 { 19, "String Theory", true, stringTheory},
89};
90int NUM_PATTERNS = 20; // MAKE SURE TO UPDATE THIS WITH THE ACTUAL NUMBER OF PATTERNS (+1 last array pos) pos)
91
92#endif
AudioAnalysis audioAnalysis
External reference to the AudioAnalysis instance.
Definition globals.h:45
Handles audio signal processing and feature extraction.
Definition audio_analysis.h:38
int NUM_PATTERNS
The number of patterns that can be shown, externed from globals.h.
Definition globals.h:90
Pattern mainPatterns[]
The current list of patterns, externed from globals.h.
Definition globals.h:68
void splashTheory(Strip_Buffer *buf, int len, Pattern_Data *params)
Maps the LED strip to volume. The starting position is based on the volume of the sampled audio....
Definition patterns.cpp:1066
void pix_freq(Strip_Buffer *buf, int len, Pattern_Data *params)
Based on a sufficient volume, a pixel will float to some position on the light strip and fall down (v...
Definition patterns.cpp:108
void bar_fill(Strip_Buffer *buf, int len, Pattern_Data *params)
Displays a pattern that occupies "lower" pixels at lower values, and "higher" pixels at higher values...
Definition patterns.cpp:742
void noteEQ(Strip_Buffer *buf, int len, Pattern_Data *params)
Maps the current note to a section on the led strip.
Definition patterns.cpp:953
void blendIn(Strip_Buffer *buf, int len, Pattern_Data *params)
Maps the LED strip to the different frequencies, and each LED blends between two different colors bas...
Definition patterns.cpp:800
void synesthesiaRolling(Strip_Buffer *buf, int len, Pattern_Data *params)
Maps the current note to a color.
Definition patterns.cpp:904
void bands(Strip_Buffer *buf, int len, Pattern_Data *params)
Basic band config : Uses the band_split_bounce() function to generate a five band split,...
Definition patterns.cpp:397
void confetti(Strip_Buffer *buf, int len, Pattern_Data *params)
Confetti effect using frequency and brightness. Colored speckles that blink and fade smoothly are sca...
Definition patterns.cpp:143
void talking(Strip_Buffer *buf, int len, Pattern_Data *params)
Generates three clusters of lights, one in the middle, and two symmetric ones that travel out from th...
Definition patterns.cpp:297
void hue_trail(Strip_Buffer *buf, int len, Pattern_Data *params)
Outputs a steady moving stream of lights where each pixel correlates to a previous fHue value....
Definition patterns.cpp:161
void deltaHeat(Strip_Buffer *buf, int len, Pattern_Data *params)
Maps the LED strip to frequencies. Creates a heatmap, where frequencies that have had drastic/continu...
Definition patterns.cpp:1126
void bleedThrough(Strip_Buffer *buf, int len, Pattern_Data *params)
A color blended between a base and transitioning color is sent down the LED strip....
Definition patterns.cpp:850
void groovy(Strip_Buffer *buf, int len, Pattern_Data *params)
A cool fluctuating pattern that changes color in waves of greens, yellows, purples and blue....
Definition patterns.cpp:253
void random_raindrop(Strip_Buffer *buf, int len, Pattern_Data *params)
A random spot is chosen along the length and does a ripple based on frequency.
Definition patterns.cpp:665
void stringTheory(Strip_Buffer *buf, int len, Pattern_Data *params)
Maps the LED strip to a string on a violin. The color changes based on which string of the violin is ...
Definition patterns.cpp:1032
void glitch(Strip_Buffer *buf, int len, Pattern_Data *params)
Creates two light clusters that move according to sine wave motion, but their speed is affected by th...
Definition patterns.cpp:339
void Fire2012(Strip_Buffer *buf, int len, Pattern_Data *params)
Fire2012 pattern utilizing heating and cooling.
Definition patterns.cpp:683
void eq(Strip_Buffer *buf, int len, Pattern_Data *params)
Short and sweet function. Each pixel corresponds to a value from vReal, where the volume at each pitc...
Definition patterns.cpp:567
void saturated(Strip_Buffer *buf, int len, Pattern_Data *params)
Fills the light strip with a nice ambient mess of colors that shift slowly over time....
Definition patterns.cpp:206
Definition storage.h:41
Definition globals.h:54
Holds persistent data for currently-running patterns.
Definition patterns.h:28