Page 1 of 2

Music on VIC

Posted: Sat Jul 22, 2017 11:27 am
by bishop144
Hello,

I'm trying to write a program on my VIC that will play a song. The problem I'm having is that I don't know how to make the VIC play all 3 voices plus noise in the program. I've been using the S assignments (S1=36874 S2=36875 S3=36876 S4=36877). However, I am unsure how to assign specific note & duration values to different voices, as well as timing the voices so they play at the right times with each other.

Any help would be appreciated.

Re: Music on VIC

Posted: Sat Jul 22, 2017 1:27 pm
by srowe
Welcome to Denial.

I recently implemented something that might be of help. It's best to think in terms of setting register values for relative intervals of time.

So, for example, you define a sequence of 'notes' which have a time, a register and a value

* Note1: time = 0, reg = voice1, value = 135
* Note2: time = 30, reg = voice1, value = 147
* Note3: time = 60, reg = voice1, value = 0
* Note4: time = 60, reg = voice2, value = 167
* Note5: time = 90, reg = voice2, value = 0

The time durations are in jiffies (60ths of a second). The 'play' routine does the following:

* takes the current jiffie clock as a starting reference
* looks at the current note, if the current jiffie time minus the start is greater than or equal to the note time then it sets the register to the value. Then it repeats for the next note
* if the current time minus the start is less than the note time the routine returns

This routine is then repeatedly called unto the tune is complete. This also allows the program to manage other tasks, such as moving graphics, polling the keyboard etc.

Re: Music on VIC

Posted: Sat Jul 22, 2017 11:04 pm
by R'zo
Are you writing in basic or ml?

Re: Music on VIC

Posted: Sun Jul 23, 2017 1:09 am
by srowe
I have an implementation in Forth. It would be easy enough to port to machine code, I don't think BASIC would be fast enough.

Re: Music on VIC

Posted: Sun Jul 23, 2017 2:06 am
by R'zo
srowe wrote:I have an implementation in Forth. It would be easy enough to port to machine code, I don't think BASIC would be fast enough.
Why not?

Code: Select all

1 data140,5,145,10,140,8,255,2          ; (note1, duration 1, note2...)

2 data 0                                                              ;(0=continue, 1= end)

3 data160,5,145,10,180,8,0,0 

4 data 1

5 s=36874:pokes+4,15  ; (sets s as voice at voice 1 add 1-3 for other voices 4 for volume, pokes volume to 15)

6 readn1:readd1:readn2:readd2:readn3:readd3:readn4:readd4     ; (reads note and duration values from data)

7 pokes,n1:pokes+1,n2:pokes+2,n3:pokes+3,n4         ; (pokes note values into voices)

8 fort=0to10               ; (time loop for duration)

9 ift=d1thenpokes,0      ; (lines 9 through 12 poke voices to 0 when t= duration value)

10 ift=d2thenpokes+1,0

11 ift=d3thenpokes+2,0

12 ift=d4thenpokes+3,0

13 next t

14 reade                                    ; (checks for song end)

15 ife=1 then restore:end      ; (ends song)

16goto6                          ; (loops to the next set of notes)

This format in basic works fine. It may not be superfast but it is fast enough for most tunes. There is even room to add in effects if your creative enough.

Re: Music on VIC

Posted: Sun Jul 23, 2017 2:23 am
by R'zo
Ml is faster but if all your doing is writing a piece of music with no graphic or other processes to occupancy it basic is plenty fast enough to write a piece of music.

If the music is part of a greater program i.e. a game then yes I recommend writing the music routine in ml. Particularly as an Irq if it needs to play alongside with other processes.

Re: Music on VIC

Posted: Sun Jul 23, 2017 7:26 am
by srowe
Here's something to annoy the neighbours with.

Re: Music on VIC

Posted: Sun Jul 23, 2017 10:06 am
by vicist
Or this, from 'An Introduction to Basic Part 2'
gavotte.prg

It's in basic so list it to get an idea of how it works.

Re: Music on VIC

Posted: Thu Sep 07, 2017 6:06 am
by armypavarmy
hello everyone is Armando
These two music tracks are
realized by me with a program in Basic
The listed ones are available to those who have them.
The notes and the value match
to the original score.
I hope they are happy ......
Greetings ...... Armando

Re: Music on VIC

Posted: Mon Nov 20, 2017 6:50 am
by armypavarmy
Success of the moment
"Havana" music in basic
for Vic20 Piano and xylophone
Armando --------------
havana.prg.zip
(1.09 KiB) Downloaded 225 times

Re: Music on VIC

Posted: Mon Dec 11, 2017 7:54 am
by armypavarmy
For Christmas
Vic 20 piano
"What Christmas Mean To Me"
Merry Christmas to all
Armando --------------
Christmas.zip
(4.03 KiB) Downloaded 209 times

Re: Music on VIC

Posted: Wed Dec 13, 2017 6:43 am
by armypavarmy
Hello
music in BASIC
the piano medley for Vic20
if you like music or song
send me the title.
I compose it with the Vic 20 for you.
medley.zip
(4.42 KiB) Downloaded 219 times

Re: Music on VIC-Jukebox-

Posted: Sun Dec 17, 2017 7:24 am
by armypavarmy
Hello to all
my basic music program
called "Jukebox".
For the characters of the text I used
the "Fat Swedish" program by Boray.
Vic20 with 8k + Ram.
For file .d64 load "jbox",8 :Run
Note:
The zip file works "directly"
only with Winvice V 3.1
Armando
jukebox.d64.zip
(13.85 KiB) Downloaded 214 times

Re: Music on VIC

Posted: Mon Apr 01, 2019 3:45 am
by Forbidden64
srowe wrote:Here's something to annoy the neighbours with.
*types G1210 in monitor*

Crap! The neighbors called the cops after the 13th encore!

Re: Music on VIC

Posted: Sun Dec 15, 2019 3:50 am
by armypavarmy
For Christmas
Vic 20 Xylophone
"Jingle Bell Rock"
Merry Christmas to all
Armando --------------
jbrock.zip
(1.07 KiB) Downloaded 98 times