Hack Club log in

bytebeat

bytebeat is music written as one line of code. ship a track to earn music gear from hack club.

log in with hack club

try it

edit the formula and press play. changes apply while it plays.

the examples are loud. lower your volume before pressing play.

what is bytebeat?

digital audio is a list of numbers that tells the speaker where to move, usually thousands per second. in bytebeat you write a formula that makes that list. the player counts t up from 0, 8,000 times a second, and runs your formula each time. the result is cut down to a number from 0 to 255, and that number is the next sample.

it runs in the browser, so there's nothing to install.

the basics

each step adds one idea to the step before it. press play to hear it.

  1. 01

    sound

    t

    t counts up to 255, then wraps back to 0. that repeating ramp is a sawtooth wave, which sounds like a low buzz.

  2. 02

    pitch

    t*4

    multiplying t makes the ramp wrap 4 times as often, so the note is higher.

  3. 03

    rhythm

    t*4*(t>>11&1)

    t>>11&1 switches between 0 and 1 every quarter second. multiplying by 0 mutes the sound, so it turns on and off.

  4. 04

    melody

    t*[4,5,6,8][t>>12&3]

    t>>12&3 steps through 0, 1, 2, 3 (one step about every half second) and picks a multiplier from the list, so the note changes.

  5. 05

    chords

    ((t*4&255)+(t*6&255))/2

    adding two waves plays both notes at the same time. dividing by 2 keeps the result in range.

  6. 06

    combine

    t*(t>>5|t>>8)

    two slow counters joined with | (bitwise or) change the pitch in a pattern that repeats, which you hear as a melody.

where it's been used

bytebeat started in september 2011, when viznut posted a video called "experimental music from very short c programs" and wrote about it on his blog, countercomplex. people started sharing their own formulas, and the name "bytebeat" came out of that. later that year he wrote a paper about it.

bytebeat sounds a lot like chiptune, the music from consoles like the nes and game boy, but it works differently. those consoles have sound chips with a few fixed channels (pulse waves, noise and so on), and the game tells each channel which note to play. bytebeat calculates every sample itself, so one formula is the whole sound.

how it works

  1. go through the basics above.
  2. write a track in the bytebeat editor (coming soon). hackatime logs the time you spend.
  3. ship the track to earn prizes. the prize list isn't out yet.

running a club?

club leaders will be able to get a workshop link, so members can log in and make a track during a meeting. this is coming soon.