libbytebeat/example-song.js
2025-08-10 08:45:02 +05:00

68 lines
1.8 KiB
JavaScript

// ==ByteBeat==
// ^ above line must be exactly like that and be first.
// this header contains metadata for the song
// specify fields with lines like "// @field-name field-value"
// JSON strings are parsed. you can put in fields not recognized
// by libbytebeat, in which case they will be passed to the library
// user. fields from https://ffmpeg.org/doxygen/7.0/group__metadata__api.html
// can be recognized by media players, for example.
// all fields recognized by libbytebeat come with defaults, shown below
//
//
// Playback mode. Possible values:
// - bytebeat : 0..255 ints, wrapped
// - sbytebeat : -128..127 ints, wrapped
// - floatbeat : -1..1 floats, clamped
// - funcbeat : floatbeat but you return a func
//
// @mode bytebeat
//
//
// Sample rate
//
// @freq 8000
//
//
// Length of the song, in samples
//
// @len Infinity
//
//
// Set this to "no" if your code depends on side effects from
// previous samples, and doesn't work with constant jumps of
// `t` well.
//
// @parallel yes
//
//
// Set this to "no" if your code doesn't work with jumps of `t`
// at all. For example "Time Is A Suggestion", where `t` is not
// used at all and the song just guesses the correct value.
//
// @seekable yes
//
//
// If enabled, upscales the song to 48kHz with nearest neighbor.
// By default enabled if sample rate is below 44100.
//
// @f48k auto
//
//
// If enabled passes the entire song through a high-pass filter
// with a pass frequency of like 15 Hz. This ensures that the
// wavefront is centered at the, well, center. You may disable
// this if your song outputs a properly centered wave.
//
// @dcClean yes
//
//
// If you output textual graphics by throwing errors, set this
// to the dimensions of the virtual "screen", in characters,
// e.g. 80x25
//
// @term
//
// ==/ByteBeat==
t*(42&t>>10)