UNIXcoffee928 Posted February 10, 2009 Share Posted February 10, 2009 An ADSR Envelope is a method of describing a sound's envelope characteristics, through the manipulation of four elements: 1. Attack 2. Decay 3. Sustain 4. Release This is the common way that sounds are described on synthesizers. I've been thinking about different ways to implement ADSR envelopes on the Atari (in Atari BASIC & Assembly Language), and no matter what, it seems to end up being a lot of nested loops. - Does anyone have a good algorithm for this already? - Is there a good mathematical formula that would simplify things? - Are there any good assembly tricks using timers to help to do the ADSR? I'd like to make each element of the ADSR envelope variable & tweakable via the paddles. Just figured that I'd ask... Quote Link to comment Share on other sites More sharing options...
Rybags Posted February 10, 2009 Share Posted February 10, 2009 (edited) There's a number of ways... table-based might be one, but possibly costly in memory use. How about something like: Attack- use an 8-bit accumulator, each step it gets added to the volume value. Upper 4 bits of volume value get converted into actual volume level (via shifting or table-lookup). Addition continues until peak target value is reached. For more precision, a 16 bit level could be used... upper 4 bits decide actual volume as before. Or maybe 12 bits, means upper 4 bits are readily ORed with the distortion value. Decay - same as Attack, except subtracting backwards toward a target Sustain level. Sustain - easy... just a selectable number of iterations where nothing changes. Release - as A/D, target level either zero or some specific volume level. Or, partially table based. You could pack values together, so maybe something like: Target volume level in bits 7-4. Attack "speed" in bits 3-0. Speed value used in a table lookup which gives 16 possible rates. Or, fully table based. The entire envelope is defined. Could also be done in a packed fashion where volume and duration of each step is contained within a single byte. Edited February 10, 2009 by Rybags Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.