Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user tubesockor ! (Registered 2024-05-12) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Fading out music
2007-07-26 10:57
Shadow
Account closed

Registered: Apr 2002
Posts: 355
Fading out music

OK, so my demo has reached the end and I want to fade out the music.
I had some very foggy memories of just ramping down $d418 from $0f to $00 like this:

jsr $1003 // music play
lda fadeoutval // $0f --> $00
sta $d418



But did not sound good when I tried it, lots of strange sparkling sounds.

So I said, screw the fadeout, I just want to stop playing the music. Then I just stopped calling the music play routine in my IRQ and did a lda #$00/sta $d418 (set volume to zero) to stop any playing sounds. But that did not work either, the last played note kind of went on playing for a while sounding very strange...


 
... 6 posts hidden. Click here to view all posts....
 
2007-07-27 07:40
Laxity

Registered: Aug 2005
Posts: 459
Finding the place where the music driver writes to d418, and having it write it to some other place in memory, will let you modify the thing real easy.

lda bufferedD418 ; Nicked from the music driver
and #$f0 ; Keep the filter settings intact.
ora myVolume
sta $d418

The gate-bit approach (for stopping the tune) is so-so. If you want that to work perfectly you'd also have to change the release nibble of the ADSR in all three voices, or you might have some voices hang longer than others.

Buffering the whole range of SID registers by masking out the I/O bank, is a bad idea. Mainly because this can change the write order of the SID registers, which are important for some drivers to sound as intended. Circumventing this problem is possible, ofcourse, by mimicing the write order of the driver (down to the last cycle).
2007-07-27 12:25
cadaver

Registered: Feb 2002
Posts: 1154
What about stopping tune by writing zero to all channels' frequencies and not calling the player anymore?
2007-07-27 12:38
Danzig

Registered: Jun 2002
Posts: 429
What about stopping tune by jmp$fce2? :D
2007-07-27 14:48
Dizzy Devil

Registered: Feb 2003
Posts: 11
Quoting Laxity
Buffering the whole range of SID registers by masking out the I/O bank, is a bad idea. Mainly because this can change the write order of the SID registers, which are important for some drivers to sound as intended.


That's right, but how common are drivers which write sid registers multiple times, or rely on a certain order? So far, we didn't have problems with the tunes used in the adventure engine.

The other methods described here require that you examine the tune, and either hack the driver or adapt your code to the driver, which isn't practical for a tool which lets you load any $1000/1003 tune.

Of course, I could just count $d418 down to 0 in a loop, but that would sound odd if the current volume at the start of fading is lower than 15, or if the music driver changes the volume during the fade.

Do you think using the ram-buffering method causes any effects which are audible for a longer time after fading a music in? (When you save the game in the adventure engine, the music is faded out, and faded in again after the save)
2007-07-27 19:09
Ninja

Registered: Jan 2002
Posts: 406
Guys, no need to argue too much, at least I don't think there is a generic solution anyway. And if, it's prolly not practical :) Dizzy, I made a music-player with debugging features which is also switching IO off. Try "Cyberdragon / Reed" for a tune that fails badly with this method - and be happy that it works for most tunes ;) Shadow, I suggest to examine the playercode, find the volume-variable and work with this one.
2007-07-27 23:21
Laxity

Registered: Aug 2005
Posts: 459
Quoting Dizzy Devil
Do you think using the ram-buffering method causes any effects which are audible for a longer time after fading a music in? (When you save the game in the adventure engine, the music is faded out, and faded in again after the save)


No.. When you switch back to normal playback (not using the SID I/O buffer), the inconsistency will be gone instantaneously.

Quote:
The other methods described here require that you examine the tune, and either hack the driver or adapt your code to the driver, which isn't practical for a tool which lets you load any $1000/1003 tune.


I agree. For a tool it's not practical at all. Also the buffering method would probably prove more robust for a tool than analysing and replacing d418 writes, if you disregard the tradeoffs mentioned.

I must admit that I didn't consider that one would only buffer the SID I/O while fading - that ofcouse means that the inconsistency would last for a quite short time indeed. /me slaps me. :)
2007-07-27 23:23
Laxity

Registered: Aug 2005
Posts: 459
Quote: What about stopping tune by writing zero to all channels' frequencies and not calling the player anymore?


Well... someone isn't thinking today.. and it's not you.

(Hey.. don't point that finger at me, mister!)
2007-07-28 00:25
Oswald

Registered: Apr 2002
Posts: 5025
*yawn*

peeps, it takes no time to find the d418 write in a player, just H 1000 2000 18 d4. then analyze the code modify it, or just write down on a paper the location of the volume variable, then use it from code. if you dont want bugs and volume artefacts due to your fading then do this way. secondly you might ask the author of the music, many players have own fade routines.

really nothing spectacular or hard here, anyone can do it with about 1-2 week of assembly learning.
2007-07-28 04:06
chatGPZ

Registered: Dec 2001
Posts: 11136
Quote:

anyone can do it with about 1-2 week of assembly learning.

tell it to tts! =D
2007-07-28 19:30
Laxity

Registered: Aug 2005
Posts: 459
Quote: *yawn*

peeps, it takes no time to find the d418 write in a player, just H 1000 2000 18 d4. then analyze the code modify it, or just write down on a paper the location of the volume variable, then use it from code. if you dont want bugs and volume artefacts due to your fading then do this way. secondly you might ask the author of the music, many players have own fade routines.

really nothing spectacular or hard here, anyone can do it with about 1-2 week of assembly learning.


Great form dude.!
Previous - 1 | 2 - Next
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
Mr. SID
aegis/ascraeus/r3turn
Genius/Xenon
CA$H/TRiAD
Higgie/Kraze/Slacker..
Visage/Lethargy
Scrap/Genesis Project
Krill/Plush
Mythus/Delysid
psych
Jetboy/Elysium
A3/AFL
Youth
tubesockor
Bob/Censor Design
Rock/Finnish Gold
grip
𝘁𝗡𝗚/FairLight
Guests online: 99
Top Demos
1 13:37  (9.8)
2 Next Level  (9.8)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Layers  (9.6)
5 Copper Booze  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Booze Design  (9.3)
3 Nostalgia  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

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