Language…
15 users online: AGRMaster, androovanhelsing,  Anorakun, autisticsceptile1993, Burning Loaf, drkrdnk, Erik, JPhanto, Knetog, Nowieso, ShirleyVAga, TheBourgyman, Tulip Time Scholarship Games, wye, Zatara - Guests: 109 - Bots: 157
Users: 67,566 (2,006 active)
Latest user: Baschfire

How to use GAIN & GAIN diagram.

Custom Music

Well since I've been seeing more people trying to use GAIN now, I thought I'd make a diagram/thread.






Gain commands in AMK:
$ED $80 $XX - set gain. (also turns off ADSR)
$FA $01 $XX - set gain. (also turns off ADSR)
$FA $05 $XX - gain to use for rests. (AMK 1 only)
$FC $XX $YY - set gain # of ticks before note ends. $XX = ticks, $YY = gain value. (AMK 1 only)

You can also use the DSP write command ($F6 $XX $YY) to set/turn on gain. $XX = DSP address, $YY = value to write.

Note: Exponential decrease gain is the same as release of ADSR.

As well as some values of increase gain are the same as attack in ADSR:

$C1 = $ED $70 $E0 (F0 E0)
$C3 = $ED $71 $E0 (F1 E0)
$C5 = $ED $72 $E0 (F2 E0)
$C7 = $ED $73 $E0 (F3 E0)
$C9 = $ED $74 $E0 (F4 E0)
$CB = $ED $75 $E0 (F5 E0)
$CD = $ED $76 $E0 (F6 E0)
$CF = $ED $77 $E0 (F7 E0)
$D1 = $ED $78 $E0 (F8 E0)
$D3 = $ED $79 $E0 (F9 E0)
$D5 = $ED $7A $E0 (FA E0)
$D7 = $ED $7B $E0 (FB E0)
$D9 = $ED $7C $E0 (FC E0)
$DB = $ED $7D $E0 (FD E0)
$DD = $ED $7E $E0 (FE E0)
$7F(Direct gain) = $ED $7F $E0 (FF E0)

-------------------------------------------------------------------
If you think there is anything I should add to this or if you see an error, please let me know.
-------------------------------------------------------------------
________________________________________________________
Mario the Gaul
nice

also parameters is spelled wrong
soundcloud / bandcamp / twitter / youtube / vgm album
Fixed, thanks.
________________________________________________________
Mario the Gaul
Yay, no more horror!
ofcourse you'd be the one to create this


Nice though, definitely useful for those that want to use GAIN.
also holy shit i never bothered to find out what the exact lengths were but hell this is useful
lol yeah, knowing the lengths of each can be useful.
________________________________________________________
Mario the Gaul
Now, this tutorial is a bit old since it describes the beta version of AMK (described as AMK 1 here) when modern AMK uses remote commands, though their use should be quite easy: Just define remote command -1 to restore the envelope and use commands 1 to 3 to apply them.

However, there is small pitfall with GAIN and that's the instrument definition. If you have the problem that when you switch to GAIN, the instrument immediately stops playing or is replayed or something, make sure the GAIN byte is set to an envelope GAIN i.e. at least $80. This is because the music engine first disables ADSR / enables GAIN and the music chip will read from the current value in GAIN and apply the changes immediately before the new value gets stored.

Consider this:
Code
@0 $FD $E0 $00 $03 $00

versus
Code
@0 $FD $E0 $B8 $03 $00


If you play it with the note data
Code
c2 $FA $01 $89 ^2

using the first instrument, the note stops playing halfway through while the latter instrument releases as expected.

Custom Music