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 Composing > ADSR delay bug
2006-12-14 07:02
ChristopherJam

Registered: Aug 2004
Posts: 1424
ADSR delay bug

I've been looking through the source code for the envelope generator in reSid, as it seems the best repository of experimental SID knowledge. Now I think I understand why my instruments were broken when I was only gating for a single frame. (well, broken on real c64 - seemed to work under Power64's emulation where I'd been composing, more fool me..)

Just checking that I understand the consequences correctly:
Is it really the case that whenever you have a release value greater (slower) than your attack that the start of your next note can be randomly delayed by up to 1.5 frames!?

How do other composers deal with this? Does everyone just always gate for a minimum of two frames, and cross fingers that the delay doesn't break the timing too badly, or do people just keep their attack value at least equal to their release value?

(I'm ignoring the effect of long decay values for the moment - my head is hurting enough already!)
2006-12-14 07:25
ChristopherJam

Registered: Aug 2004
Posts: 1424
Of course, now I see the earlier post (Sid ADSR problem / hardrestart) that covers some of this ground - and I can see why holding a voice muted with a decay of zero for 40ms before you need it would work. (well, actually anything over 32768 cycles will do - but that's why one frame is not enough).

FWIW, if reSid's model of the bug is correct, then it implies that if you have an instrument where A=D=R and always use the same settings for that voice, you will never have the ADSR problem.

In other words, any XXYX should also be fine as long as you are consistent for that voice for the entire tune (or at least, do a 32ms restart before changing to a lower value of X =).
2006-12-14 08:04
Frantic

Registered: Mar 2003
Posts: 1661
Another way to deal with it, I think, is to write the values to the sid first thing you do in the player and use a stable interrupt to call it, to make sure the same thing will happen each time you play the tune, and then you would have to tweak it to make sure it sounds good.

May be a good alternative, or complement, or not... I mean, the "randomness" is not always bad. Sometimes it stays within an acceptable range. At least it doesn't really cost much to set up such a stable interrupt for this use and there's no real drawback as far as I see it, at least if you player uses buffered values for writing already (otherwise the situation is different of course).
2006-12-14 15:56
cadaver

Registered: Feb 2002
Posts: 1163
Most players today actually deliberately induce a delay bug for each note, by gating two frames and using ADSR values & SID register write order that guarantee the bug. But to answer your original question, in my games I've actually always used 1-frame gating for raw feeling, works nicely although a bit randomly.

Then there are various bastard methods to use, like hiding the delay bug inconsistency by using a silent gated on first frame together with 1-frame gateoff or even no gating at all :) Works nice in John Player for example.
2006-12-14 23:19
Frantic

Registered: Mar 2003
Posts: 1661
@Cadaver: What would you consider a register write order that would not induce any potential for an ADSR bug whatsoever? (in the case where the gate bit have been off for 2 frames at least.)
2006-12-15 02:04
cadaver

Registered: Feb 2002
Posts: 1163
Please refer to my article in the recently released HVSC collection, it summarizes most if not all the methods with their relative advantages/disadvantages.

But to never induce delaybug (actually this may not be the sound you want, it's like oldschool Hubbard), write new instrument values in order: AD, Wave, SR. SR must have been $00 for the 2 gateoff frames before.

Wave, AD, SR is also OK most of the time but the first variation is theoretically most correct.
2006-12-15 02:50
ChristopherJam

Registered: Aug 2004
Posts: 1424
Well, if you write wave before AD, you will have a number of cycles using the old attack value before you write the new one. If the new attack value is lower, the internal counter may already have surpassed the new limit, so the envelope will get stuck again.

AD,gate,SR makes sense, as that way you are only changing the envelope rate once.

I would be surprised if the limitation on SR for the preceding two frames is anything other than 'R must be less than or equal to the next A' - enforcing zero seems overkill to me. And with a 2x player, you could just force it to the lower value for 1.5 frames rather than 2 :)
2006-12-15 02:56
cadaver

Registered: Feb 2002
Posts: 1163
Actually, release 0 is required because you want the rate counter circling the smallest possible cycle, otherwise attack 0 may bug, and attack 0 is nice & useful, right?
2006-12-15 03:54
ChristopherJam

Registered: Aug 2004
Posts: 1424
Sure, if you don't know what the next A will be. My point was if you know that the next note will have an attack of (say) 3, then decay can be any of 0,1,2 or 3, which gives you a little more flexibility in how sharply you kill the current note.
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
Martin Piper
Guests online: 527
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Codeboys & Endians  (9.7)
4 Mojo  (9.6)
5 Coma Light 13  (9.6)
6 Edge of Disgrace  (9.6)
7 Signal Carnival  (9.6)
8 Wonderland XIV  (9.5)
9 Uncensored  (9.5)
10 Comaland 100%  (9.5)
Top onefile Demos
1 Nine  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.5)
6 Scan and Spin  (9.5)
7 Onscreen 5k  (9.5)
8 Grey  (9.5)
9 Dawnfall V1.1  (9.5)
10 Rainbow Connection  (9.5)
Top Groups
1 Artline Designs  (9.3)
2 Booze Design  (9.3)
3 Performers  (9.3)
4 Oxyron  (9.3)
5 Censor Design  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 OTD  (9.8)
3 Antitrack  (9.8)
4 Fungus  (9.8)
5 S!R  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.061 sec.