News:

11 March 2016 - Forum Rules

Main Menu

How does FF7 PSX generate sound effects?

Started by DLPB, December 13, 2016, 01:06:59 AM

Previous topic - Next topic

DLPB

I asked this same question in 2002 - and still the answer is evading me. All that exists on the discs is a single file "effect.all", which would appear to hold some samples.  But at 50KB that seems far fetched, especially since no extractor has ever been able to find anything aside from BGM instrument samples from instr.all and instr2.all.

So - any PSX programmers out there... HOW does FF7 PSX do it?  I was told that the PSX doesn't have  dedicated chip to generate sounds from data, so there must be some sort of streamed data samples on the discs, no?


Bregalad

#1
I am not a PSX programmer but I can tell you this : It generate sounds effect in exactly the same way as the SNES games (in particular the SNES Final Fantasy games) does, and do not do them the "PSX" way. In other words, sound effects are synthesized on the live using a simple set of sounds and changing their pitch/volume in real time as needed, combined with hardware effects such as volume enveloppe, noise and pitch modulation.

QuoteI was told that the PSX doesn't have  dedicated chip to generate sounds from data, so there must be some sort of streamed data samples on the discs, no?
No. This means that the PlayStation does not have the equivalent of a SPC700, a dedicated processor solely to handle sound, instead the sound is handled directly by the main processor. However it does have a dedicated DSP, which happens to be very similar to the SNES' exept it handles 24 channels instead of 8, and that there is added feature, and the BRR compression scheme was slightly modified - there is blocks of 28 samples coded in 16 bytes instead of blocks of 16 samples coded in 9 bytes, but the principle is exactly the same.

Also, I'll add that it seem many PlayStation games by 3rd party companies seems to use a "standardised" sound engine made by Sony (or maybe by Psy-Q ?), FF7 definitely does not uses it, it seems to use a somewhat direct port/evolution of the SNES Squaresoft sound engines coded by Minoru Akao. (This apply to other Squaresoft Playstation games too).

From what research I have done, Final Fantasy VII seems to use the first 24 instruments of INSTR.ALL for it's sound effects, those are used for music as well. combined with the other remaining instruments.

DLPB

#2
Thanks for that. It's really helpful. I had an inkling that some of the instr.all files were being used to generate the sounds (if you play instrument 0001 on a loop, it sounds like the noise effect too - and 0005 sounds like gunfire)... But that leads to the final big problem:

A lot of (if not all) the effects are in stereo [edit.  I think... Might just be a trick to create ambient effect] - and there are almost 750 of them (many of these have a long length too).

Where is the data to play all this? You'd think with 750 effects, there would have to be more data than there appears to be. The only two candidates I can see are the PSX-EXE (a small file) and the effects.all file (at just 50KB)

Bregalad

Quote from: DLPB on December 13, 2016, 01:09:25 PM
Thanks for that. It's really helpful. I had an inkling that some of the instr.all files were being used to generate the sounds (if you play instrument 0001 on a loop, it sounds like the noise effect too - and 0005 sounds like gunfire)...
You're probably missing out the small tight waveform loops. Instrument 1 is some kind of sine wave, and instrument 5 some kind of hi-pass white noise. The gunfire samples are number 9 and 10 if I remember well.

I remember finding the file where sound effects are stored but I don't remember it by heart and I don't have a FF7 disc right there, I'll check again later and update this post (or make a new post if someone posts inbetween). It's quite possible it's effect.all, I'll just need to double check.

The reason the sound effects takes so few space is because it uses the exact same byte-code system used to store music since the SNES days. The byte code system itself is not SNES compatible, but it is really similar in concept, and is able to store music data in a very efficient way, because the SPC700 in the SNES had few dedicated RAM (the more data was taken for music and effects - the less space was left for actual sound samples, and thus impacting directly music quality). On the PlayStation such a system of storing music and effects efficiently was not needed by the hardware - a system that would take a lot of space to store them would have been just as appropriate given the large disc and memory sizes - however they continued to use it by pure tradition I guess.

DLPB

I understand the concept behind sequence data saving space, but 750 effects - a lot of them lengthy - is not a trivial amount of data.  The timing data has to be somewhere and I just don't know how they have made it so small.

Bregalad

Quote from: DLPB on December 14, 2016, 04:20:17 PM
I understand the concept behind sequence data saving space, but 750 effects - a lot of them lengthy - is not a trivial amount of data.  The timing data has to be somewhere and I just don't know how they have made it so small.
That makes it 68 bytes in average per effect, which is pretty reasonable and I'd even say large. Many effects are done in less than 20 bytes for example. Remember that for example in FF6 they had to store some 270 effects in only a few kilobytes, and they just kept using the same system.

DLPB

I've looked at this again and 50kb for all those effects, a lot of them well over 5 seconds long, is really pushing it. Akao did create his own program for creating sound effects from samples and if I had to guess I'd say that the data is in the FF7 executable.  I don't think 50KB could do it.

Bregalad

Well, I can assure you 50kB can do it. A long effect do not necessarily takes more bytes than a short effect. Remember - they aren't streamed sounds but sequenced sounds so it's basically like storing music.

DLPB

#8
Quote from: Bregalad on February 08, 2017, 07:16:18 AM
Well, I can assure you 50kB can do it. A long effect do not necessarily takes more bytes than a short effect. Remember - they aren't streamed sounds but sequenced sounds so it's basically like storing music.

And I am disagreeing with you based on actually looking at how Akao wrote his program - and how many different instruments are being changed - and how long the effects are.  I personally do not believe 50KB could do it for this particular game.  But I'd like a definitive answer on it; hopefully someone will find out exactly where the data is coming from and how large it is.

As it stands, either of us could be wrong, and we have no evidence that the data is in effect.all

I think, like the music, it's in the executable.

Bregalad

#9
Quote from: DLPB on February 11, 2017, 02:38:37 AMAnd I am disagreeing with you [...] I personally do not believe 50KB could do it for this particular game. [...] I think, like the music, it's in the executable.
I think I have not been clear enough : There is no belief nor areement nor thoughts going on, it's just a fact that EFFECTS.ALL contains all sound effect data from the game. Years ago I tried to reverse the FF7 sound engine bytecode by changing the hand cursor sound effect and it is located at 0x1000 in EFFECTS.ALL. The first 0x1000 bytes are pointers for each sound effects for the game, and then it is data. I failed to reverse the FF7 sound engine bytecode, however I succedded in locating the sound effects and affecting them somehow.

If you still do not believe me, just change the first pointer, not 0xFFFF but the one coming just after this, 0x0000 and 0x000b, each sound effect is 2 tracks, and use another pointer. You should be able to see other sound effects of the game playing when you move your cursor. You can also see the hand cursor sound effect is 0x16 or 22 bytes long - sure it's pretty short but it gives you an estimation to how many bytes are needed to store simple sound effects. Finally it seems there's 731 effects and not 750 as you claim.

DLPB

#10
750 is the value the game works with as an absolute (as in the game code itself limits to 750 by checking if an ID exceeds it). The number of effects used is less, as you noted.  Actually it's less than you posted, since a few are blank (including nearly all after 730). I did originally say "Almost 750".  I'll have to accept your response that all effects are there, despite the fact quite a few of the effects are minutes long, complex, and in stereo.  If that file does contain all effect data, it's remarkable how well they've utilized it.

Still, it would be nice if someone somewhere had more info on this than just "It's there".  It would be nice to see some reverse engineering of how it has been done.  Can you see from the data which adpcm instrument is being used?