Code music with STUDIO 28B
Let's make music with code, right here in your browser. Nothing to install. Every box below is a live editor: change the code, press play, and listen.
This page uses Strudel, a live coding environment inspired by Sonic Pi and TidalCycles.
How does it work?
every code box has a PLAY and a STOP button on top. tap or click them to start and stop the music. this works on phones, tablets and computers.
on a computer, tablet, or iphone with a keyboard, use CTRL + ENTER to play and CTRL + . to stop.
on a mac, use the control key (not cmd) or the option key.
only one box plays at a time. make sure to click the editor window first to use your keyboard to start and stop the editor window.
if you hear nothing, check your volume and that your device is not on silent or the volume is down. the first sounds take a moment to download.
1. LETS MAKE A BEAT
Each word in quotes is a sound: bd is a bass drum, sd is a snare, hh is a hi-hat. They are spread evenly across one cycle, and the cycle repeats forever.
Try it: swap a sound for cp (clap) or oh (open hat).
changed the code? tap PLAY again to hear your changes. you do not need to stop first.
2. LETS ADD SOME RHYTHM
Make the pattern more interesting with a few symbols:
*2 repeats a sound twice as fast. ~ is a rest (silence). [ ] squeezes sounds into one step. , plays patterns at the same time.
Try it: change hh*8 to hh*16.
changed the code? tap PLAY again to hear your changes. you do not need to stop first.
3. ADD SOME MELODY
use note to play pitches, and .s to choose the instrument. Note names like c3 and eb4 work, and so do numbers.
Try it: change sawtooth to square, triangle, or sine. Then change the notes.
changed the code? tap PLAY again to hear your changes. you do not need to stop first.
4. ADD SOME EFFECTS
add .something() to the end of a pattern to change it. Chain as many as you like.
.lpf() is a low-pass filter (darker sound). .room() adds reverb. .delay() adds echoes. .gain() sets volume. a sine.range(a, b).slow(n) slowly sweeps a value up and down.
Try it: change .slow(4) to .slow(1) and listen to the filter move faster.
changed the code? tap PLAY again to hear your changes. you do not need to stop first.
5. WE ARE COOKING!
stack plays several patterns at once, like tracks in a song. .every(4, rev) reverses the pattern on every 4th cycle, and .slow(2) stretches it over two cycles.
Try it: delete one layer, change the tempo with .cpm(100), or write your own bassline.
changed the code? tap PLAY again to hear your changes. you do not need to stop first.
Keep going
Keep coding with the editor window on this page and make more music.