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


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

Registered: Mar 2018
Posts: 25
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: 422
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
Account closed

Registered: Mar 2018
Posts: 25
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: 444
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
Account closed

Registered: Mar 2018
Posts: 25
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: 444
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
Fungus/Nostalgia
Zardax/Artline Designs
Guests online: 124
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Graphicians
1 Sulevi  (10)
2 Mirage  (9.8)
3 Lobo  (9.7)
4 Mikael  (9.7)
5 Archmage  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.046 sec.