Someone on the JEDI-SDL mailing list was asking how they could use
SDL_Mixer or SDL_Sound to create Commodore PET sounds. I am not much of
a sound person I thought I would ask here.
Any C code or suggestions that could point us in the right direction
would be most usefull.
The original message follows…
Thanks…> ----- Original Message -----
I am trying to write Delphi JEDI SDL code that will produce sound effects
similar to those produced on the Commodore PET 4032 computers (told you it
was off topic). Anyway, attached below is an explanation of sorts called
"HOW DO I MAKE SOUND ON MY PET?" from the URL listed (below). I found the
explanation very difficult to understand. (And yes, I used to own a
Commodore PET computer over 20 years ago and I did program it for sound
effects, way back then, but to be frank… the explanation below does not
make a lot of sense to me.)
I have copied some lines of code from the relevant parts of a PET Basic
program which does sound effects I am trying to convert. If you are
interested, then would you like to comment on (possibly) the Delphi JEDI
SDL equivalent of these sounds (or how that might be achieved).
// This next line initializes the computer for sound effects
// and defines q (used throughout the program)
poke59467,16:poke 59466,11:q=59464:poke q,0
// a little sound effect
500 poke q,6:poke q,0
// Here are some lines for a sound effect in a loop
// x is set to one of: 6,12 or 18
x =6 //(or x=12 or x=18 )
// then we do a for loop
for a=1 to x
// and do some sound followed by a delay (another for loop)
[…] poke q,a*4 [… includes small delay ]
// then turn off the sound
// this line is similar to the ones above
// go through a loop “beeping” a particular tone … then turns it off
1220 for z=200 to 100 step-5:poke q,z:next:poke q,0
// again similar… but poking a real number ?!? (the PET probably just
truncated it ?!?)
1230 for z=150 to 250 step .2 : poke q,z:next:poke q,0
Note: q is set at 59464 and the poke q,0 switches off sound.
*** What I am really after is how to I calculated the equivalent (or close)
frequencies and what commands do I use to produce the sounds using
SDL_Sound??? Does anyone have any SDL_Sound Demos???
— Peter W. :-)))
HOW DO I MAKE SOUND ON MY PET?
This process sets the PET's shift register in a free-running state
signal is used for sound generation. By adjusting the pattern of
and the frequency you can produce a wide variety of sounds, and even
Three pokes are required to make sound: POKE 59467,16 (turn on port for sound output use 0 to turn it off*) POKE 59466,octave (octave number, see below) POKE 59464,frequency (0 for no sound) After setting 59467 you can adjust 59466 and 59464 to get any sort
but to get music you need to set them with specific values, here is a
three-octave note table:
Note Table: octave=15 octave=51 octave=85 Note Oct.0 Oct.1 ! Oct.1 Oct.2 ! Oct.2 Oct.3 Freq ------------+-------------+-------------- B 251 125 ! 251 125 ! 251 125 C 238 118 ! 238 118 ! 238 118 C# 224 110 ! 224 110 ! 224 110 D 210 104 ! 210 104 ! 210 104 D# 199 99 ! 199 99 ! 199 99 E 188 93 ! 188 93 ! 188 93 F 177 88 ! 177 88 ! 177 88 F# 168 83 ! 168 83 ! 168 83 G 158 78 ! 158 78 ! 158 78 G# 149 74 ! 149 74 ! 149 74 A 140 69 ! 140 69 ! 140 69 A# 133 65 ! 133 65 ! 133 65 Set 59466 with octave range desired and play notes by setting the
in 59464. To stop any sound use POKE 59464,0.
* Note, due to a hardware bug, leaving the shift register in free
mode will cause problems when attempting to use the datasette so
POKE 59467,0 before attempting to use any tape commands.
The process for using and playing sound can also be done on the
VIC-20 the same connector pins are involved but the POKEs are different:
Instead of 59467, 59466, and 59464 for the PET use these: on the VIC-20: 37147, 37146, and 37144 on the 64 or 128: 56587, 56586, and 56584
pewill at optusnet.com.au
http://www.DelphiGamer.com := for all your Object Pascal game
http://www.delphi-jedi.org/Jedi:TEAM_SDL_HOME := Home of JEDI-SDL;
Cross-platform game development with Pascal, has never been easier.