• Please review our updated Terms and Rules here

How to make c64 music

Doing music in BASIC is something of an ordeal; it will involve quite a bit of POKEing, as there's no commands in C64 BASIC to support the video or sound hardware. What you'll want to do is read through the SID section of the Programmer's Reference Guide or Mapping The Commodore 64 until you understand it, and then try to build a simple music player around that.
 
Here is an example of a very simple music player. The first set of DATA statements define note values (frequencies) which is a handy way so you can use indexes in your music data instead of fixed values. The second set of DATA statements would be the music data itself.

Code:
10 data2195,2463,2765,2930,3288,3691,4143,4389,-1
20 data1,10,3,10,4,10,5,50,1,10,3,10,4,10,5,50
25 data1,10,3,10,4,10,5,20,3,20,1,20,3,20,2,60
30 data3,10,2,10,1,40,3,20,5,30,4,50,3,10,4,10
35 data5,20,3,20,1,20,2,20,1,50,-1,-1
40 diml%(10),h%(10):i=1:s=54272
45 reada:ifa<>-1thenh%(i)=a/256:l%(i)=a-h%(i)*256:i=i+1:goto45
50 pokes+24,15:pokes+6,240
55 reada,b:ifa=-1then70
60 pokes,l%(a):pokes+1,h%(a):pokes+4,33
65 fori=1tob*10:next:pokes+4,32:goto55
70 pokes+24,0

As you see, there is a lot of code just to play a very lousy, one channel version of When the Saints. If you want to use two or three channels, it will involve even more DATA statements and code to parse your data, depending on how complex you make it.
 
On a longer, more complex music in a bit of thought Giana Sisters music and musical parts of the Commando is packed with
Thank you for the musical examples: Clarkson's!!!
 
Last edited:
Yeah.. you won't be making a cover of Rob Hubbard's music from Commando with a Basic program. If you manage that, you are worth all my praises.

However the question is why you would like to write your own Basic program to make music. It is cumbersome and yields mediocre results. With so many quality music programs out there, which will export a nice, tight executable in machine code, there is little practical use for a program like the one I listed. You could set up a music routine in machine code to run on interrupt while your Basic program is running, and with some skills even turn it on and off from within Basic. That is probably the way I would go ahead if I made a game or other program in Basic and wanted background music.
 
Basic just cannot run fast enough to do the things that made the Commodore SID chip famous. To really push the 64, you have to program in assembly language, or possibly with a C cross compiler like cc65.
 
I just signed up for this forum, because of the SID music. I have recently gotten a C64 and C 64C, and no games or software. I did manage to get Music Maker and MSSIAH online. MSSIAh allows you to track loop etc, so it is pretty amazing, (I don't have any interest in the cart or anything).

I can't wait to make some tracks!
 
Back
Top