One-Line C64 BASIC Music

Monday 26 July 2010, 1:10 pm   ////////  

Local sound artist/electronic musician Keith Fullerton Whitman released an extraordinary piece on the b-side of his November 2009 cassette hallicrafters, inc. The piece is called 10 poke 54272+int(rnd(1)*25),int(rnd(1)*256) : goto 10 and is 18 minutes of sound produced by a Commodore 64 emulator running the BASIC program that is the title of the piece.

The memory locations beginning at 54272 are mapped on the Commodore 64 to the registers of the SID (Sound Interface Device). By POKEing random values into them, the SID, although it is a musical chip, is stimulated to produce sounds in what probably seems like a non-musical way: based on the effect of register settings and the sequence produced by the system’s random number generator, a polynomial counter.

I’m listening to the piece running on a hardware C64 now, which is soothing, although it seems like it shouldn’t be. Looking at the code, I note that the program

10 poke 54272+rnd(1)*25,rnd(1)*256 : goto 10

will put the same values into the same memory locations (and therefore SID registers) in the same order. The INT function is unnecessary because all arithmetic in C64 BASIC is done in floating point and then cast to integer whenever necessary. It’s possible that removing these functions will cause the piece to speed up, however, and I suspect it will, even though a BASIC interpreter could skip the unnecessary INT calls to begin with. There would be various ways of determining this, but the one I’d like to try involves getting two C64s, each with one version of the program, and seeing if they go out of phase.

By the way, I say that these two programs will put the same values in the same order because RND(1) returns a deterministic sequence. Any time either of these programs is invoked before other calls to RND are made, they will produce the same sequence. Using RND(0) would seed the random number generator on the jiffy clock, so would do different things depending upon how long the computer had been on before startup.

Thanks to sound artist and digital media scholar Kevin Driscoll, a.k.a. Lone Wolf, for letting me know about this.

Update: Hilariously, I overlooked that Whitman is not the author of this program – he credits Noah Vawter, a.k.a. Shifty, who is currently collaborating with me on a project about a one-line Commodore 64 BASIC program. I guess I was too distracted by that picture of an iPhone running a C64 emulator.


  1. Love the detail about seeding the RND function to generate a predictable sequence of pseudorandom integers! Does this make the distinction between “song” and “song-making machine”?

    Random numbers also play an interesting role in your thread demo. Pulling a value off of the SID is an elegant shortcut to randomness.

    I’d love to see a historical look at randomness in the history of computing. e.g. I’ve seen some programs use the milliseconds digit from the UNIX time function.

    My fave reflection on randomness is Tom Jenning’s review of a Rand Corp book titled, “A Million Random Digits with 100,000 Normal Deviates” (nice beach reading):

    Incidentally, it’s the same random technology used in the Lone Wolf playable book series!

    Comment by Kevin — 2010-07-26 @ 5:34 pm
  2. Jen Bervin, the author of Nets and The Desert (books created by erasure), is working on a book based on A Million Random Digits with 100,000 Normal Deviates.

    Also, check out the more than 100 reviews of that book on Amazon.

    Comment by Nick Montfort — 2010-07-26 @ 6:21 pm
  3. That’s pretty awesome. It amazes me what people can still do with a C=64.

    Comment by Eddie — 2010-07-27 @ 4:02 am
  4. I came across a web server running on a C64 some time ago it was slow but worked. Its amazing that these old machines still work.

    Comment by Jon Grim — 2010-08-04 @ 3:06 pm
  5. about

    10 poke54296,15:poke54272+rnd(1)*23,rnd(1)*256:goto 10

    poking 54296 with random values makes my emulator click a lot

    also, how about

    10 poke54296,15:poke54272+rnd(1)*23,rnd(1)*128+rnd(1)*128:goto 10

    ..i wonder if the kernal or basic rom has some music in it..

    Comment by claus — 2010-10-18 @ 3:30 pm
  6. claus, thanks for your comment, which not only gave us some music – it also revealed a bug in the “Markdown for WordPress and bbPress” plugin for WordPress: “/*” isn’t correctly rendered as an asterisk. I fixed this for now by switching to the “Text Control” plugin, which allows me to use Markdown for blog posts but default formatting for comments.

    Comment by Nick Montfort — 2010-10-19 @ 12:59 am
  7. […] Another very short art piece in BASIC is 10 poke 54272+int(rnd(1)25),int(rnd(1)256) : goto 10 by Noah Vawter – this code generates 18 minutes of sound on a C64 (review by Nick Montfort). […]

  8. Greetings! what an interesting idea! RANDOM MUSIC!!

    I have recently decided to re-release my 1984 C64 SID lead synthesizer called Fastfingers. I’m getting amazing response, considering that it is 27 year old. If response is big enough I may even develop Fastfingers II . However , the 27 pages of source code don’t look as familiar to me as they were 27 years ago. I used only a few comments.

    I have tried it on the VICE emulator and noticed that the sounds are OUT OF TUNE on the Vice. I hope that your emulator is IN TUNE.

    Check out the fastfingers link below complete with video demo to see what the buzz is about.

    Comment by Dan Laskowski — 2011-03-17 @ 1:22 pm
  9. 1pO54296,15:pO54272+rN(1)*7,rN(1)*256:?cH(98.5+rN(1));:gO1

    A little longer but incorporates the one line screen art as well and only uses one voice.

    Comment by Dave — 2018-04-12 @ 11:53 pm
  10. Very nice! (I changed the code to incorporate the fix you sent in a later comment.) This is a great visual + sound one-liner, with all the elements of a demo in a single BASIC line.

    Comment by Nick Montfort — 2018-04-13 @ 12:52 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2018 Post Position | Barecity theme