MakeCode Games!

A fan-made community library of MakeCode Arcade games. Visit MakeCode Arcade to make a game!

← Back to extensions

Retro FX

Add juicy 8-bit sound synthesizers, screen shakes, particle explosions, camera effects, and retro text displays to your games.

quantize pitch

Problem it solves

You are generating dynamic pitches for player movement or combos and want the notes to lock onto clean, stepped musical intervals.

What this block does

Rounds a pitch frequency to the nearest step value so tones sound coherent and chiptune-like.

The block

Block ID: retro_quantize_pitch

quantize pitch $pitch step $step block

Parameters

NameTypeDefaultMeaning
pitchnumber440The raw pitch frequency in Hertz.
stepnumber50The rounding step interval.

Returns

number — The quantized pitch rounded to the closest step.

Example

let roundedPitch = Retro.quantizePitch(432, 50)
console.log(roundedPitch)

Add the extension

Add github:CrzLe0723/RetroFx to your project, or open: Import RetroFx.