Four on the floor
A kick on every beat and a hi-hat between each pair: the steady pulse of house and disco.
You will learn
- Write two rhythms on different grids and play them together with
stack
A kick on every beat
A rhythm is a grid. Four slots in a bar are four beats, and KICK fills every one. How the kick sounds comes from kickSound in the Sound Cookbook; this page only decides when it plays.
// Four equal slots, a kick in each: one on every beat.
export const kicks = chain(
fn('note', sequence(KICK, KICK, KICK, KICK)),
...kickSound(KICK_DEFAULTS),
)Kicks
Hi-hats between the kicks
The hi-hats use a finer grid: eight slots, two per beat. Rests fill the slots that land on a beat, so every hi-hat falls halfway between two kicks.
// Eight slots, a hi-hat in every second one: exactly between the kicks.
export const offBeatHats = chain(
fn('sample', sequence(rest(), NOISE, rest(), NOISE, rest(), NOISE, rest(), NOISE)),
...hiHatSound(HI_HAT_DEFAULTS),
)Off-beat hi-hats
Play both at once
stack plays its patterns at the same time. Each keeps its own grid: four slots for the kick, eight for the hi-hats, both one bar long.
export const fourOnTheFloor = chain(
fn('stack', kicks, offBeatHats), // Both parts at once.
fn('cpm', 30), // 120 BPM.
)Four on the floor
A shorter way to write it
The hi-hat line is one two-slot figure, rest then hit, four times over. repeat(…, 4) writes it once.
// The same hi-hats, written as a two-slot figure repeated four times.
export const offBeatHatsRepeat = chain(
fn('sample', repeat(sequence(rest(), NOISE), 4)),
...hiHatSound(HI_HAT_DEFAULTS),
)With repeat()
Both versions produce the same Mini-Notation timing: ~ white ~ white ~ white ~ white and [~ white]*4.