Author Topic: Audio effect flags - example: when to loop.  (Read 243 times)

DLPB

  • No life
  • *
  • Posts: 8399
  • Karma: 225
  • ‘You know who I am,’ he said.
    • View Profile
Audio effect flags - example: when to loop.
« on: 2016-12-12 04:39:45 »
I am not going to go into this in any detail. Firstly, because I haven't myself that much; secondly, because it's boring. But a no-frills explanation is this:

There are numerous and chaotic functions that make the simplest idea the most convoluted. Functions calling functions where, if proper communication, time, and better coding had been deployed, much of the bloat would not exist.  But, hey ho... that's where we are. I'd love to tell you that one function takes in a few parameters and then just works with them... but no. Some effects, like the Summon effects use a completely different function to set audio compared to the field version. And there are others.  In fact, I think it's even possible to call the main function (74A795)  directly, which I am sure a few areas do. 

But let's keep it simple.  The field module, as some will know, uses akao and akao2. The difference between these is that akao is 8 bit and akao2 is 16 bit.  These field functions then call another function... which passes on to another function (745160).

Most normal menu and field effects use 745160 eventually. I haven't checked if any of the other functions do this, but 745160 does:

All audio effects have an associated record of 28 bytes. I don't know what all of them do, but the only thing I needed to know was - how does the game know when to loop sounds and when to play once?

In code you can see at 7452EA, the "does this sound effect loop" flag (where 00 = no).

To work out where in memory the "loop flag" for each effect is, you just do this:

( (EffectID - 1) * 1C) + 00DE0E8C.  For example, the cursor ID is 01, so:

( (1 - 1) * 1C) +  00DE0E8C = 00DE0E8C :P  [Well, it's the first effect and the minus above makes it 0].

So look at 00DE0E8C and set it to 01. You should then get a looping cursor.

And that's how it's done.


Edit.

The mov eax,[edx+00DE0E9C] at 745479 is actually retrieving an address for sample rate for the effect.  In this case, 44100.
« Last Edit: 2016-12-12 19:03:32 by DLPB »

Tsunamix

  • Freak
  • *
  • Posts: 547
  • Karma: 10
  • Check out my work - https://goo.gl/m4NFlm
    • View Profile
    • The home of Tsunamods
Re: Audio effect flags - example: when to loop.
« Reply #1 on: 2016-12-12 09:15:03 »
So theoretically you could increase the quality it reads?

DLPB

  • No life
  • *
  • Posts: 8399
  • Karma: 225
  • ‘You know who I am,’ he said.
    • View Profile
Re: Audio effect flags - example: when to loop.
« Reply #2 on: 2016-12-12 15:54:47 »
Not really no. It would be a hard task. Changing the sample rate of the effect simply changes the pitch.
 Plus 44100 is sufficient anyway.