Classic Computer Magazine Archive ANTIC VOL. 3, NO. 10 / FEBRUARY 1985

DRUM SYNTH / BASS SYNTH

Powerful AUDCTL Rhythm Section
by GLENN GUTIERREZ

These are the most realistic Atari musical instrument simulation we’ve ever heard at Antic.  What’s more, they come with an outstanding tutorial on how to use the AUDCTL memory address to POKE more powerful and varied sounds.  The drum and bass synthesizer programs are both written in BASIC and will play on any Atari of any memory size.  Paddles can be used to augment the program, but are not necessary.

Who hasn't sometimes daydreamed about being a musician?  We'd all like to be in the spotlight at a rock concert or classical recital - or at least express ourselves in our favorite styles of music.
  It's surprisingly easy to make your Atari into a drum synthesizer or electric bass synthesizer.  Hooked up to your stereo, these synthesizers will sound remarkably professional.

USING DRUM SYNTH

Type in Listing 2, check it with TYPO II and SAVE a copy.  When you RUN it, the prompt, "Press START or any key," will appear at the bottom of the screen.  Once you press [START], or any key except [BREAK], the screen will turn solid green.  Now you can play.
  Figure 1 shows you which keys control the different sounds in your synthesized drum set.  As you'll see, I programmed at least two keys for each sound, choosing a pattern that lets you play any drum with either your left or right hand.
  Pressing [START] while you're set up to play toggles you between fast and slow modes.  Stop the program at any time by pressing [BREAK] - Type END [RETURN] and all of the sound channels will be turned off.
  If you wish to edit any of the sounds, you can initiate them by GOSUBing to their line numbers, but the Graphics Zero screen will slow them down considerably Remember this when making up new sounds.



        Figure 1
Drum Synth Keyboard

 KEYS    SOUND
AS + *   BASS DRUM
D    ;   SNARE DRUM
F    L   DRUM-SYNTH
G    K   HAND CLAP
Z    X   TOM 1 (LOW)
C    V   TOM 2
B    N   TOM 3 (MEDIUM)
M    ,   TOM 4
.    /   TOM 5 (HIGH)
ART      REPEAT TOM
         (PADDLE(O)=TONE)
         (PADDLE(l)=SPEED)
Q    =   REPEAT HIGH HAT
           CYMBAL
         (PADDLE(l)=SPEED)
W    -   HIGH HAT (CLOSED)
E    P   HIGH HAT (OPEN)
R    O   CRASH CYMBAL
T    I   CRASH CYMBAL (SLOW
         DECAY)
RETURN   DRUM DEMO
          (BASS/SNARE)



INSIDE THE PROGRAMS

There are two main things I needed to do to make these programs sound good.  The first was getting the fastest speed possible from BASIC.  One way I did this was to put the title page subroutine on line 30000, while the keyboard reading loop is at the very beginning.  So the computer responds more quickly.  I also turned the screen off during playing, so the computer doesn't need to take time telling your TV to draw something.
  The second important thing I did was POKEing the sounds on-instead of working with the more commonly used SOUND commands.
  These two statements are exactly alike:

SOUND 0,200,10,8
POKE 53760,200:POKE 53761,168

  The locations for POKEing sounds begin at 53760.  Each sound requires only two addresses.  The first is the sound's pitch and the second is a combination of distortion and volume.
  Consider these two commands:

SOUND 1,PITCH,DISTORTION,
VOLUME
POKE 53762,PITCH:POKE 53763,
(DISTORTION*16)+VOLUME.

  Notice that the registers used this time were 53762 and 53763. (See Figure 2 for a complete listing of SOUND commands and their equivalent POKES.) This is because we are using voice one instead of voice zero.  The location 53763 is POKEd with the value of the distortion multiplied by 16, then added to the volume.  If you only wish to change the volume or the pitch independently, this is a much faster method.



Figure 2
POKE & SOUND

Voice   Sound Command    Equivalent POKE

1       SOUND 0,P,D,V    POKE 53760,P:POKE 53761,(16*D)+V
2       SOUND 1,P,D,V    POKE 53762,P:POKE 53763,(16*D)+V
3       SOUND 2,P,D,V    POKE 53764,P:POKE 53765,(16*D)+V
4       SOUND 3,P,D,V    POKE 53766,P:POKE 53767,(16*D)+V


AUDCTL VARIATIONS

AUDCTL (memory location 53768) is not normally associated with Atari sound, but it is extremely useful.
  Do you think that SOUND 0,255,10,8 is the deepest pitch your computer can generate?  Try the same command followed by POKE 53768,l.  Much lower!  To get back to the original tone, type POKE 53768,0 or SOUND 0,255,10,8.
  At every SOUND command, the computer sets AUDCTL to zero.  Therefore the following is impossible without detecting the changing of AUDCTL.  Try typing it in.

FOR J=255 TO 100 STEP -1:
SOUND 0,J,10,8:POKE 53768,1:
NEXT J:SOUND 0,0,0,0

  In BASIC your Atari generates the normal tone then changes AUDCTL slowly enough to be audible.  It doesn't sound very nice.  The computer only resets AUDCTL when it sees SOUND, not when it sees POKE, so let's POKE a new sound in without changing AUDCTL.  Now try this:

POKE 53768,1:POKE 53761,168:
FOR J=255 TO 100 STEP -1:
POKE 53760,J:NEXT J:POKE 53761,0

  Notice how we first POKE AUDCTL, then POKE the distortion and volume, because they don't change throughout the whole FOR-NEXT loop.  Because the distortion and volume are already set, all we have to change inside the loop is the pitch, and that only requires one POKE.  Thus POKEing becomes very useful when you need maximum speed in a sound program.
  The last command is also simpler than SOUND.  All we wish to do is turn the sound volume off.  We don't need to change the pitch.  POKE 53761,0 turns off that sound the same way SOUND 0,0,0,0 does.  But the overall process is much faster.
  Of course, you can do much more with AUDCRL than just make the tone lower.  Figure 3 tells you what the computer is thinking when you POKE AUDCTL with a certain number.



Figure 3
AUDCTL Variations (Memory Location 53768)

Bit #  AUDCTL     Result
-      0          (normal)
0      +1         switches main clock base from64 KHz to
                  15 KHz (which lowers the pitch)
1      +2         high-pass filter on chan 2, clocked by chan
                  4 (any chan 2 tone lower than chan 4 tone
                  will be filtered out)
2      +4         high-pass filter on chan 1, clocked by
                  chan 3
3      +8         joins channel 4 to channel 3(16 bit resolu-
                  tion) (allows better pitch control)
4      +16        joins channel 2 to channel 1(16 bit
                  resolution)
5      +32        clocks channel 3 with 1.79 MHz(1.79 MHz is
                  normal speed)
6      +64        clocks channel 1 with 1.79 MHz
7      +128       makes the 17 bit poly-counter a 9 bit
                  one(changes the noise distortion sounds)
Try experimenting with different values.



SOUND INGREDIENTS

  All of a computer's sound is made up by a series of clicks played at different speeds.  Imagine the sound made when you turned your bicycle upside-down, spun the front wheel, and stuck a playing card into the moving spokes.  You get a buzzing sound or a clicking sound, depending on the speed the wheel turns.  Of course, the Atari clicks are much faster-64,000 per second.
  You can change the computer's clock speed from 64 KHz to 15 KHz by turning on bit 0 of AUDCTL (See Figure 3).  This will slow down the clicks and lower the pitch of the sound.
  Bits 1 and 2 of AUDCI'L are strange.  With bit 1 on, any tone played by channel 2 that's lower than the tone in channel 4 is supposed to be filtered out.  Bit 2 controls channels 1 and 3 the same way.  But the sounds are not totally off, however.  Try this:

POKE 53768,5:POKE 53760,200:
POKE 53764,0:POKE 53761,165

  Channel 1 produces an insect-sounding tone as a result of being "filtered out." Notice that channel 3 doesn't have to be "on," just tuned.  AUDCTL is POKEd with 5, turning on the filter and slowing down the clock.  It sounds nicer at 15 KHz.
  Now try harmonizing the two channels:

POKE 53768,5:POKE 53760,200:
POKE 53764,199:POKE 53761,165:
POKE 53765,165

  Bit 3 causes channel 4 to be fine tuned by channels 3 and bit 4. This allows better pitch control over high notes.
Bit 5 and bit 6 return channel 3 and 1 to normal speed.  This is useful when you have slowed down the clock for one sound, but you want another sound to be played at normal speed.
  The last bit, number 7, changes something called the poly-counter from a 17-bit position to a 9-bit position.
Distortion 8 is called "white noise." It consists of the same clicks as normal tones, but a few delays are thrown in between the clicks.  These glitches are set in a pattern and repeated every 17 clicks so that the sound remains constant.  By setting bit 7, you cause the pattern to be repeated every 9 times, making the noise a little more basic.  Its use is up to you.

MIX YOUR OWN

Now, on to the program structure.  It's not really complicated.  All of the sound effects begin at line 100 and have a REM statement declaring what the sound is supposed to resemble.
  It's easy to mix your own sounds too.  First, let's discuss the keyboard assigning process.  A series of DATA statements begins on line 31000.  There are 64 numbers in all.  Each line has ten numbers ranging from 0 to 9 for each DATA statement. (Except line 31006 which ranges from 0 to 3)
  Your Atari starts counting with zero instead of one, so these numbers count from 0 on line 31000 to 63 on line 31006.  Instead of using the usual GET statement to read the keyboard, I used the computer's internal codes.  Every time you press one of the keys on the keyboard, the computer stores a number in memory location 764 (Please see Figure 4).
  The numbers in the DATA statements correspond to the line numbers where that key's sound effect begins.  So, if you made up a sound and put it on line 2000, you would have to decide what key you wanted it triggered from.  You would then find that key on the Key Codes list and write down its number.
  Suppose you want the sound to be assigned to the TAB key.  The key number is 44, so you would put 2000 in the 44th number in the DATA statements.  Since the DATA is arranged in ten-number lines and each line goes from 0 to 9, 44 would be on line 31004 and would be the fifth number in. (40 would be the first, 41 would be the second, etc.) Figure 5 is a list of the line numbers and their corresponding hexadecimal numbers.
  The numbers that are already there are the sounds that I have made up.  I must admit the programming looks pretty messy.  When I first wrote the program, I tried to make it as simple and organized as possible.  But there's always room for artistic improvement, right?  I kept going back and adding and removing until I was completely satisfied with the sounds.  As a result, the coding looks like a jumble of POKEs and FOR-NEXTs.
  One technique I discovered is the way to get the solid bass drum "thump." By using a distortion of 1 (POKE 53761,(16*1)+VOLUME), the computer doesn't make a continuing sound, but a "click." And when you put a bunch of the clicks together in a preset way, you're on your way to a realistic bass drum sound.



Figure 4
Internal Key Codes
(Memory Location 764)

         KEY CODES
0    L      28      ESC
1    J      29      5
2    ;      30      2
5    K      31      1
6    +      32      ,
7    *      33      SPACE
8    O      34      .
10   P      35      N
11   U      37      M
12   RETURN 38      /
13   I      39      ATARI
14   -      40      R
15   =      42      E
16   V      43      Y
18   C      44      TAB
21   B      45      T
22   X      46      W
23   Z      47      Q
24   4      48      9
26   3      50      0
27   6      51      7
            52     Back S
            53      8
            54      <
            55      >
            56      F
            57      H
            58      D
            61      G
            62      S
            63      A

255 no key pressed



Figure 5
Key Assignment Numbers

DATA numbers    Line number

0-9             31000
10-19           31001
20-29           31002
30-39           31003
40-49           31004
50-59           31005
60-63           31006



AMPLIFY IT

Now to put some power in your drums.  Hearing a synthesizer through a television set's puny speaker is not the best way, so hook your computer up to your stereo.
  You can connect the monitor output of an Atari 800, 800XL or 1200XL to the auxiliary input of a stereo amplifier by using a cable that has a 5-pin DIN plug at one end and an RCA jack at the other.  You'll find this kind of cable for a few dollars at just about any electronics store (if you only find cables with 2 RCA jacks at one end, those will work too.)
  In case you prefer to make your own cable, Figure 6 is the front view of the 5-pin DIN plug.  Connect the cable's shielded wire to Ground and the center wire to Audio Output.
  If you have a 400 or 600XL, you probably must be content with the TV speaker unless somebody out there knows how to reroute the sound without a monitor output.  DO NOT GO INTO YOUR TELEVISION!  This can cause intensive electric shock even when unplugged!
5-Pin DIN Plug

BASS SYNTH

Listing 1, Bass Synth, is a bass synthesizer that's capable of some pretty astounding effects.  This program can be typed in and operated just about the same way as Drum Synth.

Figure 7 pictures a piano keyboard overlaid with the Atari keys that will get you each of the notes.  Some people even think Bass Synth sounds more like a heavy metal guitar or a keyboard synthesizer.  Anyway, have fun with your new musical instruments!



Bass Synth Keyboard



Glen Gutierrez is a sixteen-year old high school student in Fremont, California.  He’s had his Atari 800 for two years and he thinks of himself as a computer artist, rather than a computer programmer

Program Listings :
Listing 1: BASYNTH.BAS Download

Listing 2: SYNDRUM.BAS Download