HitLib 1.3.0
VEX V5 LED animation library for PROS
Loading...
Searching...
No Matches
hitlib::LedStrand::MusicTrack Struct Reference

A song's intensity envelope, baked ahead of time into one 8-bit sample per frame. More...

#include <led_strand.hpp>

Public Attributes

const uint8_t * samples
 Intensity 0-255, one entry per frame.
uint16_t frameCount
 Number of samples in samples.
uint16_t frameMs
 Milliseconds between consecutive samples.

Detailed Description

A song's intensity envelope, baked ahead of time into one 8-bit sample per frame.

The V5 has no audio input and no MIDI decoder, so a strand can't listen to the music it's syncing to. Instead Pattern Studio reads a MIDI file on the desktop, renders it down to a level-per-frame envelope, and exports that envelope as a constexpr table. On the robot musicSync() just plays the table back against the wall clock, which costs one array lookup and a lerp per tick regardless of how long or dense the song is.

A three-minute song at the default 25 ms frame is about 7 KB of flash.

// Generated by Pattern Studio, in the exported header:
inline const uint8_t songSamples[] = {0, 3, 17, 42, ...};
inline const hitlib::LedStrand::MusicTrack song = {songSamples, 8840, 25};
A song's intensity envelope, baked ahead of time into one 8-bit sample per frame.
Definition led_strand.hpp:217
Note
Like Profile, a MusicTrack must outlive the strand it is handed to, the strand stores a pointer, not a copy.

Member Data Documentation

◆ samples

const uint8_t* hitlib::LedStrand::MusicTrack::samples

Intensity 0-255, one entry per frame.

◆ frameCount

uint16_t hitlib::LedStrand::MusicTrack::frameCount

Number of samples in samples.

◆ frameMs

uint16_t hitlib::LedStrand::MusicTrack::frameMs

Milliseconds between consecutive samples.