Repository navigation
Added in 1.3. Requires TIC-80 started with --fft; see FFT.
The Variable-Q Transform maps the spectrum onto 120 logarithmically spaced bins — 10 octaves of 12 notes. Bin frequency is 19.445 * 2^(bin/12) Hz; bin 0 is D#0/Eb0. The normalized variants return a value roughly 0..1 for their bin; the raw variants are not peak-normalized, so their scale depends on the input.
Every variant answers one question: normalized or raw, smoothed or not, whitened or not.
| Function | Peak-normalized | Smoothed | Whitened | Notes |
|---|---|---|---|---|
vqt(bin) |
yes | no | no | the everyday magnitude |
vqts(bin) |
yes | yes | no | steadier for visuals |
vqtr(bin) |
no | no | no | raw magnitude |
vqtrs(bin) |
no | yes | no | raw and smoothed |
vqtw(bin) |
yes | no | yes | notes stand out from the spectral envelope |
vqtsw(bin) |
yes | yes | yes | whitened and steadier |
vqtrw(bin) |
no | no | yes | whitened without auto-gain |
vqtrsw(bin) |
no | yes | yes | raw, smoothed and whitened |
bin is 0..119. A value outside the range reads as zero.
-- one bar per octave, using the smoothed normalized magnitude
function TIC()
cls(0)
for octave = 0, 9 do
local sum = 0
for note = 0, 11 do
sum = sum + vqts(octave * 12 + note)
end
local h = sum / 12 * 100
rect(10 + octave * 22, 120 - h, 16, h, 12)
end
endUse FFT when you want linear buckets instead of musical notes.
TIC-80 tiny computer https://tic80.com | Twitter | Telegram | Terms
Built-in Editors
Console
save | export | load | import | menu | config | surf | shelf | demo | eval
Platform
RAM | VRAM | Display | Palette | Bits per Pixel (BPP) |
.ticFormat | Supported Languages
Other
Tutorials | Code Snippets | Libraries | External Tools | FFT
API
Callbacks
Input
Drawing
circ | circb | clip | cls | elli | ellib | font | line | map | paint | pix | print | rect | rectb | rrect | rrectb | spr | tri | trib | ttri | fill patterns
- textri (deprecated)
Sound
Memory
memcpy | memset | mget | mset | peek | poke | pmem | sync | vbank
System