Music on VIC
Moderator: Moderators
Music on VIC
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.
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
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.
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
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
Why not?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.
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)
R'zo
I do not believe in obsolete...
I do not believe in obsolete...
Re: Music on VIC
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.
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.
R'zo
I do not believe in obsolete...
I do not believe in obsolete...
Re: Music on VIC
Here's something to annoy the neighbours with.
- Attachments
-
- tune.zip
- (3.57 KiB) Downloaded 2185 times
Re: Music on VIC
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.
gavotte.prg
It's in basic so list it to get an idea of how it works.
-
- Vic 20 Hobbyist
- Posts: 110
- Joined: Wed Oct 02, 2013 1:54 am
- Location: Italy
Re: Music on VIC
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
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
- Attachments
-
- Music-Vic.rar
- (7.37 KiB) Downloaded 2129 times
-
- Vic 20 Hobbyist
- Posts: 110
- Joined: Wed Oct 02, 2013 1:54 am
- Location: Italy
Re: Music on VIC
Success of the moment
"Havana" music in basic
for Vic20 Piano and xylophone
Armando --------------
"Havana" music in basic
for Vic20 Piano and xylophone
Armando --------------
-
- Vic 20 Hobbyist
- Posts: 110
- Joined: Wed Oct 02, 2013 1:54 am
- Location: Italy
Re: Music on VIC
For Christmas
Vic 20 piano
"What Christmas Mean To Me"
Merry Christmas to all
Armando --------------
Vic 20 piano
"What Christmas Mean To Me"
Merry Christmas to all
Armando --------------
-
- Vic 20 Hobbyist
- Posts: 110
- Joined: Wed Oct 02, 2013 1:54 am
- Location: Italy
Re: Music on VIC
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.
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.
-
- Vic 20 Hobbyist
- Posts: 110
- Joined: Wed Oct 02, 2013 1:54 am
- Location: Italy
Re: Music on VIC-Jukebox-
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
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
-
- Vic 20 Hobbyist
- Posts: 125
- Joined: Sun Feb 28, 2016 9:59 pm
- Location: CA USA
Re: Music on VIC
*types G1210 in monitor*srowe wrote:Here's something to annoy the neighbours with.
Crap! The neighbors called the cops after the 13th encore!
-
- Vic 20 Hobbyist
- Posts: 110
- Joined: Wed Oct 02, 2013 1:54 am
- Location: Italy
Re: Music on VIC
For Christmas
Vic 20 Xylophone
"Jingle Bell Rock"
Merry Christmas to all
Armando --------------
Vic 20 Xylophone
"Jingle Bell Rock"
Merry Christmas to all
Armando --------------