Absolutely amazing,the VIC20 actually has 5 sound channels!

PET, VIC-20, MAX, 264 series, C128, C65...
Amiga discussions belong to Lemon Amiga or Chit Chat.

Moderator: Lemoners

Post Reply
User avatar
Kong Daddy
Posts: 2941
Joined: Thu Mar 27, 2003 6:25 am

Absolutely amazing,the VIC20 actually has 5 sound channels!

Post by Kong Daddy »

Yes that's right, 3+1 noise channel AND an extra sound channel which you can access from two pins on the user port and mix with the original output to get 5 channel sound on our humble trooper of an 8bit Commodore. I am seriously impressed by this. And it's all detailed in the VIC20 Programmers Reference Guide!

Code: Select all


MORE MUSIC FOR THE VIC
Now that you know about the USER PORT, there is a little surprise
left. Up to now, the VIC has had 4 musical voices...three music
registers and a white noise register. By connecting a small amplifier
and speaker to the USER PORT, and doing a little programming,
you can get another musical voice.

THEORY
Most music is made up of square waves of different amplitudes
and frequencies. One of the functions of the 6522 chip is to
generate square waves through the CB2 line. If we connect the
CB2 line to a speaker, we will be able to hear the square waves
generated by the VIC.

NOTE: Connecting a speaker directly to CB2 may damage your
VIC. You must connect the speaker through an amplifier to protect
the VIC.

PARTS NEEDED
1. Small battery powered speaker/amplifier
2. User Port Connector (12 position, 24 contact edge connector
with .156" spacing
3. Wire
CONNECTING TO YOUR VIC
1. Wire the GROUND of the amplifier to the GROUND of the USER
PORT (pin N).
2. Wire the SIGNAL of the amplifier to the CB2 output of the USER
PORT (pin M).
You are now ready to add your other voice through a BASIC
program.


BASIC PROGRAM STEPS:
1. Set the 6522 shift register to free running mode by:
POKE 37147,16

2. Set the shift rate by:
POKE 37144,C where C is an integer from 0 to 255
C in the note to be played.

3. Load the shift register by:
POKE 37146,D where D = 15,51, or 85 for a square wave.

This step sets the octave for the note.
This step must be done last, since as soon as it is set, the VIC
starts generating the square waves.

The frequency of the square wave can be found by the following
formula:
500000 Hz

FREQUENCY = --------- Where D1 = 8 when D = 15
(C+2)(D1) D1 = 4 when D = 51
D1 = 2 when D = 85

When you are in this mode, the VIC will not read or write to
cassette. To restore normal operations, you must:
POKE 37147,0


The following program demonstrates music using this method.
By hitting a letter the note will be played.
10 PRINT "MUSICAL USING CB2."
15 PRINT "HIT + TO GO UP AN OCTAVE"
16 PRINT "HIT - TO GO DOWN AN OCTAVE"
17 PRINT:PRINT "USE E TO EXIT."
20 POKE37147,16:DIMA(30):FORK=1TO30:READA(K):
NEXT
40 GETA$:IFA$=""THEN40
42 IFA$="E"THEN POKE37147,0:END
45 IFA$="+"THEN SF=SF-(SF<2):GOTO40
50 IFA$="-"THEN SF=SF+(SF<0):GOTO40
60 A=8-ASC(A$)+64:IF A>7 OR A<1 THEN 40
70 POKE37144,A(A-(SF=1)*10-(SF=2)*20)
80 POKE37146,-(SF=0)*15-(SF=1)*51-(SF=2)*85
90 GOTO40
100 DATA 59,61,65,69,73,77,82,87,90,93
110 DATA 99,104,111,117,120,124,132,140,149,157
120 DATA 167,177,182,188,199,211,224,237,244,251

User avatar
eslapion
Jumpman
Jumpman
Posts: 4530
Joined: Mon Jul 24, 2006 9:04 pm
Location: Mourrial esti de tabarnak

Post by eslapion »

Well, can we really can this extra sound channels?

This trick uses the bit shift registers of the 6522... and it can only generate square waves. Also, because you're tapping directly onto the unbuffrered output of the 6522, you can easily destroy the chip if you don't pay serious attention to what you're plugging there.

Using this kind of trick it would also be possible to add extra sound channels to the 64 but nobody should expect anything close to the quality and flexibility of the SID.

The funny thing is, this extra output can generate a better sound quality than the normal sound output of the VIC.
User avatar
gklinger
Bruce Lee
Bruce Lee
Posts: 9473
Joined: Mon Dec 06, 2004 1:43 am
Location: Toronto, CANADA

Post by gklinger »

I think this belongs in Other 8-bit C= computers...
Here's to feeling good all the time.
User avatar
Kong Daddy
Posts: 2941
Joined: Thu Mar 27, 2003 6:25 am

Post by Kong Daddy »

Ah I didn't know the same output line was available on the C64. Can you have an extra one voice in the same way with the C64 then from the user or cartridge port then?

If you input both the normal A/V sound output and the user port square wave into a standard stereo amp and set it to mono you get all the channels and the 6522 is protected :)
User avatar
airship
Jack The Nipper
Jack The Nipper
Posts: 951
Joined: Tue Aug 05, 2008 5:47 pm
Location: Iowa, USA
Age: 72
Contact:

Post by airship »

The secret with a trick like this is to not expect too much from the user port outputs. Anything you compose needs to take into account the pulse (not square) waveform limitation. You can also add external filters to mellow the tone.

Frankly, I'm surprised that none of the dedicated C64 SID boxes have used these 'extra' outputs for additional effects.

Even if you don't use them for tone generation, the user port lines can be used to trigger external effect circuitry.
airship
(Former Managing Editor, INFO Magazine)
User avatar
Kong Daddy
Posts: 2941
Joined: Thu Mar 27, 2003 6:25 am

Post by Kong Daddy »

One things for sure, I need to experiment with all that juicy information in the VIC20 prog ref guide. So much stuff I personally didn't know about is in there apart from this little gem :)
User avatar
airship
Jack The Nipper
Jack The Nipper
Posts: 951
Joined: Tue Aug 05, 2008 5:47 pm
Location: Iowa, USA
Age: 72
Contact:

Post by airship »

Here's how the user port could be used to enhance SID output (under proper program control, of course).

Image

The SID's output is routed through a small board (green) that includes several effects circuits. The user port is connected to control those circuits.

In this example, the first FX circuit, FX1, is controlled by three of the parallel lines from the user port to provide a possible eight different levels of effect. FX2 is a simple on/off effect, while FX3 uses four of the parallel outputs to provide 16 different effect levels. MIX takes the resulting SID output and mixes in the pulse waveform being generated by the user port's serial output. The pulse output could, of course, be conditioned by its own filter, and filters could also be added after the MIX output.

By adding chips you could easily control 256 different effects and/or levels.

And this doesn't even get into feeding signals back into the SID's audio input line, adding external sound generation chips controlled by the user port, etc. :)
airship
(Former Managing Editor, INFO Magazine)
User avatar
Kong Daddy
Posts: 2941
Joined: Thu Mar 27, 2003 6:25 am

Post by Kong Daddy »

I once did some user port hacking on my C64. I made a set of LEDs in the shape of the flux capacitor from the back to the future movies 7 LEDs wide. Then attached them to the user port and wrote a little program to make them flash towards the centre just like on the movie. Silly huh?

Gotta love the programmers reference guides, not like the soulless crap under windows where you can't do sod all exciting with 10 mins coding and a bit of wire and solder *meh*
User avatar
airship
Jack The Nipper
Jack The Nipper
Posts: 951
Joined: Tue Aug 05, 2008 5:47 pm
Location: Iowa, USA
Age: 72
Contact:

Post by airship »

Kong Daddy wrote:I once did some user port hacking on my C64. I made a set of LEDs in the shape of the flux capacitor from the back to the future movies 7 LEDs wide. Then attached them to the user port and wrote a little program to make them flash towards the centre just like on the movie.
Self-described electronics guru Don Lancaster has published a circuit that lets you run 56 LEDs from the user port using no additional components, save for 8 resistors. The diagram is on page 3 of this PDF, with a short article on page 4. Very nice.
http://www.tinaja.com/glib/muse152.pdf
airship
(Former Managing Editor, INFO Magazine)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests