PulseCanvas / app · pulsecanvas.ai / scripts / StrobeSmoke.swift
| 1 | import Foundation |
| 2 | @main struct StrobeSmoke { |
| 3 | static func main() { |
| 4 | var detector = StrobeDetector() |
| 5 | let silence = [Float](repeating: 0, count: 32) |
| 6 | var bass = silence; bass[2] = 1; bass[3] = 1 |
| 7 | for frame in 0..<120 { precondition(detector.nextFrame(time: Double(frame) / 60, bands: frame % 4 == 0 ? bass : silence) == 0) } |
| 8 | detector.reset() |
| 9 | var hats = silence; for band in 24..<32 { hats[band] = 0.8 } |
| 10 | var triggers = 0 |
| 11 | for frame in 0..<120 { |
| 12 | let flash = detector.nextFrame(time: Double(frame) / 60, bands: frame % 6 == 0 ? hats : silence) |
| 13 | if frame % 6 == 0 { precondition(flash == 1); triggers += 1 } |
| 14 | if frame % 6 == 3 { precondition(flash == 0) } |
| 15 | } |
| 16 | precondition(triggers == 20) |
| 17 | precondition(detector.nextFrame(time: 0, bands: silence) == 0, "Seek backwards must reset") |
| 18 | detector.reset(); _ = detector.nextFrame(time: 0, bands: hats) |
| 19 | for frame in 1..<120 { precondition(detector.nextFrame(time: Double(frame) / 60, bands: hats) == (frame == 1 ? 1 : 0)) } |
| 20 | print("PASS strobe: 10 rapid hat attacks/sec, bass rejection, short flashes, sustained treble rejection, seek reset") |
| 21 | } |
| 22 | } |