encoded
string
Stores the base64-encoded and XOR-encrypted OpenAI API key. It's encrypted to avoid exposing the key directly in the source code.
const encoded = 'KTF3Kig1MHcIaDhqCms+OA0AYhEADSo9NDEbLDxjKwMTPW0fdwgLMQ8wahcvFy4UIDAxYiI4CWgwdy0fLGgsDgwcLCkDAgsuNh40OxwcN24LbA5pGDY4MRwQKR0+AigiLDATP2piFwwqLzk3agorOBM2ExkvLTMeDmg8OwoTGCMpLhQXOWMuNBIPDRc2bRlpFA0THT0RIh8NETsRKyADAykUKRs=';
key
number
The XOR cipher key (0x5A in hexadecimal, which is 90 in decimal) used to decrypt the API key.
const key = 0x5A;
mic
object (p5.AudioIn)
Stores the microphone input object that captures audio from the user's device. Used to measure sound levels for aurora reactivity.
let mic; // Initialized in setup() with: mic = new p5.AudioIn();
amplitude
object (p5.Amplitude)
Analyzes the microphone input to measure sound level (0-1). Higher values mean louder sound, which makes the aurora waves move upward.
let amplitude; // Initialized in setup() with: amplitude = new p5.Amplitude();
speechRecognition
object (webkitSpeechRecognition)
Stores the Web Speech API object that converts spoken words into text. This is how the sketch 'hears' the user.
let speechRecognition; // Initialized in setupSpeechRecognition()
micButton
object (HTML Element)
Reference to the 'Start Listening' button in the HTML. Used to update button text and attach click handlers.
let micButton; // Gets reference in setup(): micButton = document.getElementById('micButton');
transcriptElement
object (HTML Element)
Reference to the transcript display element in the HTML. Shows what the user said (interim and final).
let transcriptElement; // Gets reference in setup(): transcriptElement = document.getElementById('transcript');
statusElement
object (HTML Element)
Reference to the status message element in the HTML. Shows what the sketch is currently doing (listening, processing, playing speech, etc.).
let statusElement; // Gets reference in setup(): statusElement = document.getElementById('status');
isListening
boolean
Flag that tracks whether speech recognition is currently active. Used to toggle between 'Start Listening' and 'Stop Listening' button states.
let isListening = false; // Set to true when listening starts, false when it stops
currentAudioFile
object (p5.SoundFile) or null
Stores the audio file that OpenAI's text-to-speech API generates. Allows the sketch to play the AI's voice describing the aurora.
let currentAudioFile = null; // Set when audio is loaded from OpenAI
currentAuroraParams
object
Stores the current aurora parameters (colors, intensity, description) generated by OpenAI. These values control how the aurora looks.
let currentAuroraParams = { colors: ['#00FFFF', '#00FF00', '#FFFF00', '#FF00FF'], intensity: 'medium', description: 'A serene aurora dances across the night sky, awaiting your voice command.' };
noiseScale
number
Controls how fine or coarse the Perlin noise pattern is. Smaller values create larger, smoother waves; larger values create more detailed, choppy waves.
let noiseScale = 0.005; // Small value creates smooth, flowing waves
noiseOffset
number
Tracks the horizontal position in the Perlin noise space. Incremented each frame to make the aurora waves flow horizontally across the screen.
let noiseOffset = 0; // Incremented by 0.005 each frame in draw()
yOffset
number
Tracks the vertical position in the Perlin noise space. Creates a subtle breathing effect in the aurora by varying the wave height over time.
let yOffset = 0; // Incremented by 0.001 each frame in draw()
numLayers
number
The number of aurora wave layers to draw. More layers create more depth and a fuller aurora effect.
let numLayers = 10; // 10 layers of aurora waves
layerSeparation
number
The vertical distance in pixels between each aurora layer. Calculated based on canvas height to ensure layers are evenly spaced.
let layerSeparation; // Calculated in setup(): layerSeparation = height / (numLayers + 2);
particles
array of Particle objects
Stores all the floating particle objects that drift upward across the screen, creating a sense of depth and movement.
let particles = []; // Populated in setup() with 200 Particle objects
particleCount
number
The maximum number of particles to maintain on screen. The sketch creates new particles to keep the count near this number.
let particleCount = 200; // Maximum 200 particles at a time