Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in 
CSDb User Forums


Forums > C64 Coding > Terrible Music Player, I could really use some help!
2018-03-26 15:47
jamiefuller

Registered: Mar 2018
Posts: 23
Terrible Music Player, I could really use some help!

Hi All,

I have never written anything to do with SID, all my demos and games, I just imported someone else's SID file and did music that way.

However I'm working on a 4K game (currently at 3,700 bytes) and so want to design my own music player for once, so here is my first attempt. I'm happy for it to only use one channel as I need the other for sound effects and the third channel for random number generation (can I do both so long as the waveform is based on noise?)

it's really quite bad but does make a series of beeps that kind of resembles music :)

I think I should be doing something with the gate on each note?

Any help/pointers would be fab!

*=$0801

        BYTE    $0B, $08, $0A, $00, $9E, $32, $30, $36, $34, $00, $00, $00


*=$0810

init    

        lda #$0f
        sta $d418

        lda #%01111111
        sta $DC0D
        and $D011
        sta $D011

        lda #$51         
        sta $D012

        lda #<irq_handler
        sta $0314
        lda #>irq_handler
        sta $0315


        lda #%00000001
        sta $D01A


@endloop
        jmp @endloop

irq_handler
        inc $d020

        jsr PlayMusic

        dec $d020
        asl $D019
        JMP $EA31


PlayMusic
        lda mdelay
        beq @play
        dec mdelay
        jmp @done

@play
        lda #$8
        sta mdelay
        inc mnote
        lda mnote
        and #$1f
        tax
        lda #$08
        sta $d40b
        lda #$10
        sta $d40C
        lda #$00
        sta $d40D
        lda music,x
        sta $d408
        lda #$b1
        sta $d407
        lda #$21
        sta $d40b
@done
        rts

music
        byte 28,49,26,156,25,30,23,181,22,96,29,223,28,49,26,156,28,49
        byte 26,156,25,30,23,181,22,96,23,181,25,30,26,156
mdelay byte 0
mnote byte 0
2018-03-26 16:31
Mixer

Registered: Apr 2008
Posts: 280
http://codebase64.org has a lot of useful stuff.

Regarding gate: I assume you know of ADSR aka. volume envelope. If not, then check the codebase or other source for register description. When gate is changed from 0 to 1 the ads phase of the sound envelope starts, when gate is changed from 1 to 0 the release phase starts. AD and SR register nybbles control the time of each phase and S the sustain level. Changing gate is somewhat same as pressing a synth key to activate a sound and releasing a synth key to end sound. One can program it many ways, for example combine waveform selection and gate toggling, or have constant gate on time or vary gate on time depending on instrument or note data.
2018-03-26 18:52
jamiefuller

Registered: Mar 2018
Posts: 23
Quote: http://codebase64.org has a lot of useful stuff.

Regarding gate: I assume you know of ADSR aka. volume envelope. If not, then check the codebase or other source for register description. When gate is changed from 0 to 1 the ads phase of the sound envelope starts, when gate is changed from 1 to 0 the release phase starts. AD and SR register nybbles control the time of each phase and S the sustain level. Changing gate is somewhat same as pressing a synth key to activate a sound and releasing a synth key to end sound. One can program it many ways, for example combine waveform selection and gate toggling, or have constant gate on time or vary gate on time depending on instrument or note data.


Thanks for the link, I have tried following some of those but they tend to get quite complicated, quite quickly and so have put me off.

I figured out the ADSR bit and I guessed the gate was the issue I hadn't figured, so I have tweaked my code to play a note every 8th frame (setting the gate hi) and then to drop the gate after 4 frames (halfway between next note)

This makes a much more pleasant music player but I still need to work on it A LOT! :)

Thanks again though.
2018-03-26 21:48
spider-j

Registered: Oct 2004
Posts: 173
You maybe also want to select a waveform ;-)
Imho AAY64 is a good source for finding out what each single bit in the SID registers actually means:
http://unusedino.de/ec64/technical/aay/c64/sidmain.htm
2018-03-26 22:45
jamiefuller

Registered: Mar 2018
Posts: 23
Quote: You maybe also want to select a waveform ;-)
Imho AAY64 is a good source for finding out what each single bit in the SID registers actually means:
http://unusedino.de/ec64/technical/aay/c64/sidmain.htm


Thanks for the site, I'll check it out.
But... I thought I was setting the waveform
        lda #$21
        sta $d40b

With Bit 5 being set, its choosing "Sawtooth" waveform no?
2018-03-27 05:46
spider-j

Registered: Oct 2004
Posts: 173
Whooops, yes, You're right. I only saw that
lda #$08
sta $d40b
part.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Mike
Karmic/HVSC/ONS
iceout/Avatar
Motion/ARTSTATE·HVSC
blendo75
Alakran_64
Dymo/G★P
T.M.R/Cosine
Guests online: 28
Top Demos
1 Uncensored  (9.7)
2 Comaland 100%  (9.7)
3 Unboxed  (9.7)
4 Edge of Disgrace  (9.7)
5 Coma Light 13  (9.6)
6 The Shores of Reflec..  (9.6)
7 Lunatico  (9.6)
8 Wonderland XII  (9.6)
9 X Marks the Spot  (9.6)
10 C=Bit 18  (9.6)
Top onefile Demos
1 Arok 20 Invitation  (9.6)
2 FMX Music Demo  (9.6)
3 Daah, Those Acid Pil..  (9.6)
4 Pandemoniac Part 2 o..  (9.5)
5 Rewind  (9.5)
6 Party Horse  (9.4)
7 Dawnfall V1.1  (9.4)
8 Crystal Gazer  (9.4)
9 Merry Xmas 2017  (9.4)
10 Dawnfall  (9.4)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Finnish Gold  (9.3)
5 The Transfer Team  (9.3)
Top Graphicians
1 Razorback  (9.8)
2 Mirage  (9.8)
3 Archmage  (9.7)
4 Veto  (9.7)
5 Duce  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2018
Page generated in: 0.067 sec.