Author
Topic: Sound effect information. (Read 1572 times)

I will add to this if I do more work on it. Suffice to say, this stuff is really irritating. As I mentioned before, the code is a joke. You have numerous functions doing mostly the same thing - calling one another after numerous checks to decide everything from loops to which channel to dump the effect on. The field module does this by script, which is fair enough, but the battle module doesn't have a set standard. Take a look at the following paths that the processor took to initiate a sound effect from dsound:

As you can see, this isn't a case of a sane, or rational, or well coded function. It's a giant mess. Some effects, like the sound used when characters disappear before a Summon, use a dedicated function, like 00748F8F. This function is ONLY called for this ONE effect. Despite the fact they could have just used 00745160 - or any other function that eventually calls 0074A795. And there's the first problem. Even if you do hijack the functions that do most of the work: 005BFFF3 and 0074580A , you are still left with these oddities. There are others out there too.

It's like the programmers lost track entirely of what was going on. There is a ton of duplicate checking code.

Yeah, you aren't going to believe how these silly ID numbers come into being either. They seem to be plucked from someone's brown end. When the function is called, it deducts 21 from the ID. So if the value is less than 21, you get 20 - 21 = -1 (sigh which is then seen as HIGHER than 10 using a "Ja" - so it ends up calling 745606. It also has a silly table to decide the jump positions and even that isn't logical. I have solved this above (as you can see).

2. L/R Balance of the sound effect (where 00 is left, 64 is centre and 127 is right).

3. Effect ID (0-750, but some of these don't even exist past a certain number). Note that a check is done in numerous functions to make sure that the range is correct.

So as you can see, 005BFFF3 doesn't know what to do until the programmer tells it. It is sent a balance value and the effect to play, but what path it takes from there depends on the stupid ID it is given.

0074580A: Haven't really gone into this one much but it ultimately ends up either playing the effect with centred panning on channel 5 (4) using 745160, or it calls 00745CF3 with the effect ID and does another raft of checking. It's bizarre.

Then we have akao/akao2 from field script. At least we know exactly how this works and it is guaranteed that one of these is going to be called in order to play an effect from the field. So, unlike battle, you aren't running around trying to disassemble the universe. The field code effects probably won't take me long to code. But the battle side of things is tougher if we want to completely replace the original engine. Unless someone can shed some light on how call 0074A795 actually uses all the data it is given to produce the effect using dsound.

Sounds like they didn't trust themselves if it needed that many backups. In case the first 5 failed lol.How do you even find out what each code does?

By going through the assembly line by line - Checking variables and so on - and following the branches while the game is playing using a debugger. Sometimes it's nice and logical and easy to suss and sometimes it's like this....

So work has begun on recording some sound effects and now I have a problem. I was certain that the effects were stereo, but recording them with a central balance, they are very close to mono if they aren't. I will need someone with a good ear and audio experience to tell me what is going on here.

The wave forms in the L and R channel are slightly different, but this could be because the balance isn't true-centre. It could also be that ff7 psx does a neat trick to change the L/R sound slightly to give it some ambiance.

Of course, looping effects will prove more difficult, since you cannot tell where the end point is.

Edit. Also, the effects ARE stereo. The megalixir waveform is unmistakably different with the L R. Some of them are probably mono, but some are definitely slightly different or significantly different.

So a TimeValue of 60 = 1 second. This is a very very shoddy system, because even 1 second isn't a good transition time - and values 1-59 are all less than a second. A maximum time of 4.25 seconds is pretty poor too.

The PC loop points are incorrect. After a lot of messing about (luksy also providing pc loop points and other info) it became clear that something was amiss. When I recorded the PSX sounds and tried to use the same loop position, it failed.

Here's how effects are supposed to be looped:

They use NTSC time. The alarm sound at the reactor (effect 60) is exactly 1 second long by NTSC standard (29.97 / 30) = 0.999s by adjusted time. The elevator sound (effect 42) is 3 seconds long by NTSC standard (29.97 / 30 / * 3)= 2.997s by adjusted time. The easiest way of doing this is just Adjusted time = 0.999 * seconds.

The porting team for FF7 PC didn't seem to understand this, and so loop points are frequently out. The elevator sound effect on PC is 3.899 seconds long, instead of 2.997). I'm not sure how they've come to that value to be honest. You can see it's meant to be 3 seconds by recording PSX version and looking at it in wave editor (the loop point lies in the middle - flat waveform)

ps4 version will have the same crappy adpcm compressed effects - which sound noticeably worse than what you hear coming out of a psx (psx uses adpcm samples - but the effect is constructed from them and has reverb and so on added) - plus they are mostly mono - when many more were stereo. And the loop points are wrong.

The swirl is not deactivated. It's simply the fact that the background is set to black - therefore it swirls a pure black background

The flag above is simply to stop the sound effect itself, which would otherwise still play. Really cheap fix they added just for this haha. Also a good job that there isn't some background effect playing, since that will not be disabled as it should be.

The swirl can be disabled by 40164E = C3 or 00409337 = C7 45 E8 00000000

which will skip the function that draws it and so on. Not sure if there are bad side effects to that. Seems to work.