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

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Sound effect information.
« on: 2016-12-13 00:29:50 »
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:

Path for enemy attack (just one I chose at random)
call 005BFFF3 
call 00745606
call 00745160
call 0074A795

Path for menu cursor (menu outside of battle also)
call 0074580A
call 00745160
call 0074A795

Path for Summon effects
call 005BFFF3
call 00749404
call 00748D69
call 0074A795

path for disappearing characters
call 00748F8F
call 0074A795

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.

005BFFF3: This has 3 parameters.

1: Pushes identification to decide how to proceed.
Code: [Select]
21 to 23: Calls 00749404
24 to 27: call 745606 and let it decide the channel.
28:Channel 1, call 745160
29:Channel 2, call 745160
30:Channel 3, call 745160
31:Channel 4, call 745160
Else call 745606 and let's it decide the channel.

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.

But even then it may still need multiple changes elsewhere.




« Last Edit: 2016-12-13 00:47:02 by DLPB »

Tsuna

  • Global moderator
  • *
  • Posts: 823
  • Working together to create awesome things!
    • View Profile
    • The home of Tsunamods
Re: Sound effect information.
« Reply #1 on: 2016-12-13 00:45:14 »
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?

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #2 on: 2016-12-13 00:48:27 »
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....

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #3 on: 2016-12-13 22:09:41 »
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.

Tsuna

  • Global moderator
  • *
  • Posts: 823
  • Working together to create awesome things!
    • View Profile
    • The home of Tsunamods
Re: Sound effect information.
« Reply #4 on: 2016-12-13 22:31:10 »
Only way i would know is if Audacity told me it was stereo or not

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #5 on: 2016-12-13 22:39:30 »
Only way i would know is if Audacity told me it was stereo or not

That won't tell you anything.  I k now there are 2 channels, but that isn't the question ;)

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #6 on: 2016-12-13 23:12:29 »
How to record the sound effects from PSX game :P

https://drive.google.com/open?id=0B3Kl04es5qkqMy1PdHEtR00xbGc

Left/right: choose ID
Circle: Execute sound
Square: Play sound 1 (cursor effect / end current sound)

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.

« Last Edit: 2016-12-13 23:45:25 by DLPB »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #7 on: 2016-12-24 07:59:24 »
I have uploaded farm.dat for anyone out there that ever wants to do a sound test. Just import the main code to farm using Makou Reactor.  Then walk into Chocobo farm.

https://drive.google.com/open?id=0B3Kl04es5qkqbUZhVVUyNUoyVTQ

KnifeTheSky77

  • *
  • Posts: 548
  • Somnambulistic Paraphile
    • View Profile
Re: Sound effect information.
« Reply #8 on: 2016-12-24 20:16:02 »
Any straightforward way to get this data into a form that could be used in a DAW/synthesizer?

Very cool stuff, psx sounds were fantastic

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #9 on: 2016-12-24 20:31:39 »
They used their own method of creating the sounds...  basically, you'd have to recreate their tool.  Good luck :P  I think recording the sounds from psx is only good way.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #10 on: 2017-01-18 09:01:04 »
Just noting that because I am making a replacement for FF7 sound, I have been forced to go into the inner workings a bit more. I'll put any info I find here. 

Transition times:  Music, Effect, Balance, tempo transitions will transition to the target volume / balance / tempo in TimeValue / 60 seconds.

So, with Akao 8 bit, the maximum transition time is 255 / 60 = 4.25 seconds.

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.

Luckily, Akao2 should allow for 65535 / 60 = 1092 seconds.  I haven't checked Akao2 yet.
« Last Edit: 2017-01-18 09:56:36 by DLPB »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #11 on: 2017-01-20 04:58:02 »
Looping data:

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)


« Last Edit: 2017-01-20 05:15:16 by DLPB »

Roden

  • *
  • Posts: 125
    • View Profile
Re: Sound effect information.
« Reply #12 on: 2017-01-20 12:39:59 »
Hmm, is this why the PS4 version seems a bit off to me? (based on PC version?) Ugh, I should I just to stick to PS1 version..

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #13 on: 2017-01-20 12:50:09 »
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.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #14 on: 2017-02-11 19:05:13 »
There is actually a flag in FF7 to allow sound effects to continue during battle - and to disable the battle swirl sound.  But I think it's unused.

xor eax,eax
mov al,[00DC0C3D]
00DC0C3D
and eax,30

Plus the game uses the 4 channels in battle, so they's be terminated anyway.  I can add this function back in - but by a user set flag and by using different channels.

Meta

  • *
  • Posts: 6
  • Professional Forum Lurker
    • View Profile
    • Steam
Re: Sound effect information.
« Reply #15 on: 2017-02-12 02:40:20 »
There is actually a flag in FF7 to allow sound effects to continue during battle - and to disable the battle swirl sound.  But I think it's unused.

I'm not 100% sure, but I believe that the disable swirl sound flag is used in the lasts 3 battles: https://youtu.be/rz6YYuEyqpw?t=102

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #16 on: 2017-02-12 03:34:16 »
I'm not 100% sure, but I believe that the disable swirl sound flag is used in the lasts 3 battles: https://youtu.be/rz6YYuEyqpw?t=102

It turns out you're half right.  It is used to turn off the battle swirl sound effect at that part in the game. 00DC0C3D is Var[13][97] field bank.

You can see it's being set on that very field.

But that flag does not disable the actual swirl.  I think I may know what does that now. I am going to check ;)

Edit.  I think it's hard coded to skip the swirl depending on battle ID.
« Last Edit: 2017-02-12 03:53:25 by DLPB »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Sound effect information.
« Reply #17 on: 2017-02-12 05:41:45 »
The swirl is not deactivated.  It's simply the fact that the background is set to black - therefore it swirls a pure black background :P

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.             
« Last Edit: 2017-02-12 06:03:42 by DLPB »