The VIC's default synthesizer

Basic and Machine Language

Moderator: Moderators

Post Reply
JoshuaHorn
Vic 20 Drifter
Posts: 37
Joined: Fri Feb 06, 2009 11:03 am

The VIC's default synthesizer

Post by JoshuaHorn »

Hey everyone,

I usually have my mixer board at Church to record services, as I am part of the Technical Crew. However as of recent our recording board has cratered. So I took my board home for some home recording.

I want to utilize my VIC-20's internal synth (both the norm and whitenoise) to create songs. Can someone give me an example of BASIC program code that shows how to program a song?

And if possible, a youtube or other video of a VIC running a song?

Thanks

Josh
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

A program in BASIC would mostly be a series of data statements. It can be as complex as you wish, but the more kinds of data you feed it, the slower it will run. Here is a rather simple example:

1 data 225,2,225,2,225,2,227,2
2 data 229,4,229,4,227,2,227,2
3 data 229,4,227,2,225,8,-1
4 v=36874:poke v+4,15:rem volume
5 read a:if a=-1 then 10
6 poke v+2,a:read b:for i=1 to b*50
7 next:poke v+2,0:goto 5
10 poke v+4,0:end

I am using exact note values but multiples of duration. Ideally you would define a note table first:

1 data 128,137,xxx,xxx, ... ,229,-1
2 dim n(30):i=0
3 read a:if a<>-1 then n(i)=a:i=i+1:goto 3
...
10 data 12,2,14,2,16,2,14,2, ...
...
15 read a:if a=-1 then ...
17 poke v+2,n(a):read b:for ...

All the ... means code is omitted, either similar to the first program or for you to fill in on your own. The idea here is to have a note table in N(30) and the actual music data only consists of note indexes and duration multiples. For a short music, you can even optimize the note table to only contain the notes you need instead of a full 12-tone scale.

Technically speaking, each voice on the VIC-20 can handle about 2 1/3 octaves before note resolution gets so bad you don't want to bother anymore. Personally I never use values beyond 229 for music anymore. Although you can play sounds with frequencies up to 254, it gets badly detuned in the last part.

The songs you might find on YouTube however are likely to come from VIC demos. These demos generally are written in machine code which allows for much faster and more advanced handling of the sound registers. While the capacities and limitations are exactly the same, you can get it to simulate more effects in machine code, e.g. vibratos, glissando or arpeggio. Some of the demos may even use "Viznut waveforms" which I think is very hard if not impossible to set up in Basic.

I hope this will get you going. There are a couple of people on this forum making music on VIC-20's in one form or another, so you're not alone. For example I spent yesterday updating my own music player..
Anders Carlsson

Image Image Image Image Image
Post Reply