Banner
Views: 236,498,380
Time: 2013-05-24 03:21:06 AM
4 users online: cyphermur9t, MarioFan22, Pokeymeister80, Qwholl - Guests: 16 - Bots: 15Users: 22,875 (1,272 active)
Latest: ratchtet
Tip: Take advantage of easy to implement ASM hacks that can be found in the ROM map.
What exactly is 'Gain'...
Forum Index - SMW Hacking - General SMW Hacking Help - Custom Music Help - What exactly is 'Gain'...
Pages: « 1 »
...and how is it different from ADSR?
It's another type of sound enveloping method, and it has a slightly different set of parameters. This document probably explains it better than I could.
Ohhey I was about to make a thread about this! Thanks, I wanted to experiment with this on my next port.
Can anyone make an example and SPC? I wanna hear it, instead of reading.
Many songs use gain. I.e. all the FF4 songs.

Example from FF4
Any example using slides/changes?
Like:
*setsgain*
c8
*increasesgain*
c8
*increasesgain*
Etc.
Could someone give me like a graph demonstrating what 'Gain' is?

You know, like the one showing what ADSR is? That's what I'm most curious about.
So what I found out is this:
To set gain I use this command:
$ED $80 $x5 $00
in the beginning of the channel.
ALWAYS FIRST PUT GAIN ON, THEN DO THE REST!!!
x is your channel number, if I want it for #0 I use 0, #5-5, #7-7, etc.
There are 5 different values for GAIN:
Direct GAIN, this sets the envelope to the given parameter.
Increase GAIN (linear), makes the envelope go up in a straight line.
Increase GAIN (bent line), this makes the envelope go 3/4 up then slow down until at 1.
And 2 decrease values from what I didn't find out how to use them.
So here are the values:
Direct:
$ED $80 $x7 $yy
where x is your channel number and yy is the gain-value UNDER $80
Linear Increase:
$ED $80 $x7 $yy
where x is your channel number and yy is the value from the table+$C0
Bent Increase:
$ED $80 $x7 $yy
where x is your channel number and yy is the value from the table+E0
(yay for shameless copy-pasting!)

GO HERE FOR A TABLE AND FURTHER INFORMATION

Let's use an example:
Code
#0 v255 t50 @0 $ED $80 $05 $00 $ED $80 $07 $60 c4

This will play a note with the GAIN value 60 like you'd use $ED $7F $E0.

Another example:
Code
#0 v255 t50 @0 $ED $80 $05 $00 $ED $80 $07 $CA c4 $ED $80 $07 $F0 c4 #1 v255 @1 $ED $80 $15 $00 $ED $80 $17 $F2 f8f8 $ED $80 $17 $D0 f8f8

This will play note c4 linear with the given value and again but then bent.
On channel #1 it'll play note f8 two times in a row bent and then f8 two times in a row linear.

An example with ARAM:
Code
$ED $82 $61 $36 $00 $04 $01 $00 $00 $CA $04 ;This will do it linear with the given value $DA $13 #0 $DA $13 c1

Tada!

Well, I'm still trying to find out the other way.
Maybe SMW uses something with GAIN I don't know, like it does with volume.
Last edited on 2012-03-05 06:14:51 PM by Torchkas.
I think I got how to rip Gain from an SPC:

Let's rip one from mm7:


Ga A 0 1 18

- The first digit determines the type of Gain if it's not direct (bits 7,6 and 5). If Gain is direct (like in SMW) it'll show a D.
C ($C0) is Increase Linear
E ($E0) is Increase Bentline
8 ($80) is Decrease Linear
A ($A0) is Decrease Exponental (like in our case)

- I don't know what the second and the third digits are, but I'd assume they are two bits, since they can be either 0 or 1 (cleared or set).
You don't need them anyway [citation needed].

- The last two digit (18 in this case) is the Gain rate (or parameter), and represents bits 0,1,2,3 and 4.
Its value can go from 00 to 1F (5 bits).

-----------------------------------------------------------

So, all we need to do is (you might use an hex calculator, though the operations are pretty easy) get the first digit and multyply it by 10. In our case we'll get A0.
Then we get the last two digits, and add them together to our last result. In our case we'll get 18+A0=B8.

B8 is the value we need to write to the DSP register x7 (x is channel number).

So let's do it:

$ED $80 $x5 $00 ;this clears ADSR, otherwise GAIN will be ignored work
$ED $80 $x7 $B8 ;now we write the value we got, to the DSP register for GAIN

------------------------------------------------

This is what I've just got

EXAMPLE (531 bytes btw)

I mean, I just got bored =P
Well, according to how it looks to me in SPC700 Player. You aren't fading out the envelope, like you should with GAIN.

This is actually where I'm hanging, the GAIN get's enabled but the EX goes to zero immediately.
EDIT:Apparently it works like this:
D=Direct $Value
A 0 0=Linear Decrease $Value+80
A 0 1=Exponential Decrease $Value+A0
A 1 0=Linear Increase $Value+C0
A 1 1=Bent Line Increase $Value+E0
Last edited on 2012-10-25 05:09:03 PM by Torchkas.
Thanks, you're right, now I think I actually got it, except that I don't know how to prevent the EX from going immediately to 00.
From what I've experienced, Gain seems to be displayed on the SPC700 player when the notes go silent for most games. Capcom games are a good example of that. DKC songs display Gain before any channel plays any note. Other games like Jurassic Park though use only Gain for their songs. SNN actually ported that song using ADSR as opposed to Gain and it worked fine. I personally have no real use for Gain though honestly, I don't see how it would benefit me in the least.
Last edited on 2012-03-05 11:00:02 PM by Slash Man.
I know you dont know how to use it Torchas, but whats the command for decrease gain?
Decrease doesn't work properly, it probably has something to do with the way how SMW works with sound. (like crap)
But about the values, I already posted them above.
When I try using GAIN in AMM, it crashes (no Music Plays). Is there a Possibility for AMM?
Well, aparently a japanese guy with an odd name used gain command in his Plok Beach port, looking at the txt it was enabled with $ED $80 $XX, unfortunately I don't know what's $XX, maybe $YY value of the command for addmusic4? ($ED $80 $X7 $YY).

Also, you need to put the command on a channel, like ADSR.
thanks, I'll try it ^^

-- EDIT: Works =D
Last edited on 2012-03-24 03:59:54 AM by Darius.
Pages: « 1 »
Forum Index - SMW Hacking - General SMW Hacking Help - Custom Music Help - What exactly is 'Gain'...

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2013 - SMW Central
Legal Information - Link To Us


Total queries: 29

Menu