ADSR Envelope API
Posted: Thu Jan 27, 2022 7:34 am
I see your point, leaving decay away limits the musical use. So the question boils down to whether the intended use includes music or only simple sound effects.
On 1/26/2022 at 11:29 PM, kliepatsch said:
currently you cannot make a sound with a single line of code (or two). I may be wrong
On 1/27/2022 at 1:29 AM, kliepatsch said:
Well, rje has been talking about an ADSR manager for a while now, and I was interested in his wishes specifically. My impression was that he doesn't want a second Concerto, but rather address a simple problem: currently you cannot make a sound with a single line of code (or two). I may be wrong ...
On 1/28/2022 at 10:06 AM, rje said:
I have code that can set up a voice -- that's the easy part. What I lack is the thing that "curates" the sound through an envelope in a "fire and forget" manner.
The ADSR manager is the piece that requires working off of an interrupt to "curate" a played note, so to speak. In my mind, it would be handled by assembly code, since as an interrupt process it should be as efficient as possible.
Envelope_Manager: ; voice is in X?
load status, indexed by X
...dispatch based on state...
Attack:
increase volume by a_ratio,x
increment status if it's at max_vol and fall through
else rts
Decay:
decrement volume by b_ratio,x
increment status if it's at decay_vol and fall through
else rts
Sustain:
increment status if sustain is done and fall through
else rts
Release:
decrement volume by r_ratio,x
turn off voice and mark done if it's at zero_volume
rts
On 12/14/2021 at 7:02 PM, rje said:
... They're linear timeouts. So, not as versatile as the C64's envelopes. Still, 2^16 jiffies is... uh, I think it's 18 minutes.
65536 jiffies x 1 second / 60 jiffies x 1 minute / 60 seconds = 65536/3600 = 18 min.
On 1/28/2022 at 9:06 AM, rje said:
I have code that can set up a voice -- that's the easy part. What I lack is the thing that "curates" the sound through an envelope in a "fire and forget" manner.
The ADSR manager is the piece that requires working off of an interrupt to "curate" a played note, so to speak. In my mind, it would be handled by assembly code, since as an interrupt process it should be as efficient as possible.
On 1/28/2022 at 7:36 PM, TomXP411 said:
Attack would increment the volume by AttackRate each tick. So if AttackRate is 1, it takes 4.25 seconds to reach full volume. So higher values attack faster, with 255 being the shortest attack rate (one tick.)
Add Level and AttackRate
Is Volume < 255?
Yes, set Stage to Decay
Jump to SetNoteVolume
Decay subtracts DecayRate from volume. It then tests the volume against the SustainLevel, then jumps to SetNoteVolume
Sustain is just a test against "note on". When this changes to "note off", advance Stage to Release
Release is the same as Decay, except the final level is 0. When level is 0, you can set the stage back to 0.
Quote
Is Volume < 255?
Yes, set Stage to Decay
On 1/28/2022 at 4:31 PM, BruceMcF said:
Sustain volume can easily be a four bit value which is a fraction relative to maximum volume, as in the SID
On 1/28/2022 at 5:19 PM, BruceMcF said:
I presume that in
That either the "<" is an "=" or the if "Yes" is actually an "if no".
Note that linear attack settings can readily be "n+1" by simply using SEC rather than CLC when performing the addition, and then it is "Is volume = 256", which is BCS. Then the slowest attack is "0" rather than "1".
On 1/28/2022 at 5:36 PM, TomXP411 said:
LSR
BCS StartNote
LSR
BCS Attack
LSR
BCS Decay
LSR
BCS Sustain
LSR
BCS Release
JMP SetNoteVolume