jombo23 / N64-Tools

N64 Tools
The Unlicense
239 stars 113 forks source link

EAD Games Missing Release Rate #27

Closed L-Spiro closed 2 years ago

L-Spiro commented 2 years ago

I don’t believe this is a Seq64 issue because as far as I can tell Seq64 provides the release rates for games, they simply aren’t being used.

Taking Star Fox 64 as an example, bank 1D has the following release rates on instruments 0x00-0x05: 71, 133, 86, 29, 95, 48 And for 0x7F (percussion) it is: 53

But when we look inside ExtractedSoundbank_1D.dlsDebug.txt, all of the regular samples have a release of FB500000 and the percussion has F06DAFB6. I haven’t been able to get Seq64 to do anything useful and spit out the release rates, but it seems to acknowledge that they exist, so I am just assuming it is actually spitting these values out when someone actually knows how to use it, so I am currently under the assumption that this is an issue that needs to be addressed on this end. image

Since Seq64 V1 is no longer being updated, it really has to be handled on this end or else it just won’t be handled at all, in any case. Can this get fixed on this end?

SubDrag commented 2 years ago

Uhh Seq64 isn't my software. You have to get the author if need any fixes.

It's not used in any way. All dls exports are from code and ini configuration in soundbank tool. EAD games don't translate to dls release rates properly etc in my tool. Never really figured out and it was different per game or per cmds or something. Gave up and stopped on it.

L-Spiro commented 2 years ago

I e-mailed Sauraen before creating this issue. The point is, however, that I believe Seq64 is giving you the release rates and you are just not using them.

Just as I had requested the ADSR values be part of the debug export, can you add the release rates to the debug export? The DLS/SoundFont data is useless to me, and I don’t want to be missing out on release rates just because some other data I am not even using doesn’t support it correctly.

Also, I have decoded them, so if you would like to support them properly in DLS I can pass the information along. The values are simply the speeds at which the sound linearly decays upon release, so larger values equate to shorter release times.

Here is example code for Super Mario 64:

    double AdsrReleaseRateToTime( uint8_t _ui8Rate, uint32_t _ui32Hz ) {
        const int32_t gAiFrequency = _ui32Hz;
        const int32_t gSamplesPerFrameTarget = ((gAiFrequency / 60) + 0xF) & ~0xF;
        const int32_t updatesPerFrame = gSamplesPerFrameTarget / 160 + 1;
        double dTime = 0x8000 / (((_ui8Rate * 24.0)) * updatesPerFrame) / 60.0;
        return dTime;
    }
    …
double dTime = AdsrReleaseRateToTime( RELEASERATE, SAMPLERATE /* Usually 32000. */ );
const double dSlowSpeed = 3.0;
const double dFastSpeed = 5.0;
const double dSlowPoint = 10.0;
const double dFastPoint = 208.0;
const double dDiff = (dFastPoint - dSlowPoint);
const double dFinal = ((RELEASERATE - dSlowPoint) / dDiff)  * (dFastSpeed - dSlowSpeed) + dSlowSpeed;

dFinal is the release time in seconds. Multiply by 3.5 for other EAD games.

I would like to request that the debug TXT files contain the proper release rates, just as they contain the ADSR data.

// EDIT: It should be mentioned that because the rates change depending on the frequency, the release time cannot be exported unless the frequency never changes within the game. Wave Race 64 swaps between 32000 Hz and 26900 Hz, for example. The Hz is always the same for each song, so you could export the times rather than the rates, but you would have to know the Hz for each song (title is 32000, in-game music is 26900). But I just need the rate, not the time. I can figure out the Hz myself.

SubDrag commented 2 years ago

Not sure where that code is to be applied, and looks to be SM64 only? I seem to be outputting in debug the 8 ADSR 16-bit constants. They are not uint8s. That must be an input to a tool of yours which could apply a formula. Not really sure what you are asking for. Please adapt the code below. https://github.com/jombo23/N64-Tools/blob/master/N64%20Soundbank%20Tool/N64SoundbankToolDlg.cpp#L1074

L-Spiro commented 2 years ago

As an example, this is what is currently output for Star Fox 64 bank 1D inst 0: Attack 00000000 Decay 7FFFFFFF Sustain 03E80000 Release FB500000 - 0002 7FBC 0001 7FBC 7FBC 72F6 FFFF 0000 This is what would be orgasmic for it to output: Attack 00000000 Decay 7FFFFFFF Sustain 03E80000 Release FB500000 - 0002 7FBC 0001 7FBC 7FBC 72F6 FFFF 0000 71

SubDrag commented 2 years ago

Where is that 71 coming from?

L-Spiro commented 2 years ago

That is the release rate for bank 1D instrument 0x00 in Star Fox 64. I posted the table above:

Taking Star Fox 64 as an example, bank 1D has the following release rates on instruments 0x00-0x05:
71, 133, 86, 29, 95, 48
And for 0x7F (percussion) it is:
53

You have the release rate and you are discarding it, according to what you wrote above. I would like it not to be discarded. I don’t know how you are getting the ADSR values, but the R stands for Release, and that 71 is the Release part of that ADSR. However you are getting the other ADSR values is how you get that R value of 71; they should be right next to each other in memory.

By the way, 71 is base-10.

SubDrag commented 2 years ago

I don't know where he's getting those values from. This is how Star Fox is read. I'm not seeing how his structure lines up. https://github.com/jombo23/N64-Tools/blob/master/N64%20Sound%20Tool/N64SoundListToolUpdated/N64SoundLibrary/N64AIFCAudio.cpp#L17942

L-Spiro commented 2 years ago

Do you have release rates for Super Mario 64 or Mario Kart 64? Here is an example from Super Mario 64, bank 0B: 19, 208, 208, 0, 0, 0, 208, 208, 0, 0, 10, 208

This is bank 0D in Wave Race 64: 100, 100, 180, 208, 76, 53, 208, 0, 0, 0, 10, 10, 10

Can you find any of this data during your export?

SubDrag commented 2 years ago

Well my tool doesn't read structs, just reads off values at offsets. I don't see this data no, in what I read. Assuming it's there, it's something not read. If you could find it in the hex of ROM that would be helpful as his struct does not align to what I see, or I don't see the data.

L-Spiro commented 2 years ago

In Mario Kart 64 the release rate is right after the splits. Can you find this in whatever data you read? image

SubDrag commented 2 years ago

The real data doesn't look like that - splits are floating point?

For example, Star Fox 1.1, 0x0011BD10 is the first instrument. 0x20 bytes per.
image

8 bytes ASDR is at 0011BCD0 for instrument one (the 0x200 offset) at offset 4 in first 0x20 instrument data.
image

The splits are floating points...0xC, 0x14, 0x1C offsets. I don't know where he is pulling is data, you will have to find me the real data in ROM.

Wave table is at 0x00119910.

I'm not like reading data and throwing it away. This data was never read, can't go into output unless found. I do not see your values at all.

L-Spiro commented 2 years ago

N64-Tools-master\N64 Soundbank Tool\Release\romdesc\Mario Kart 64 (U).xml This file defines that structure. I don’t know how this file relates to your tool, but it should at least provide a hint, and it is included with your tool.

Splits are 3 floating-point values. That’s what ABSound splits[0x3]; is. That’s not “splitpoint1” and “splitpoint2.”

Look, you have the release rates right there: image See that “Splits/RelTime” value? (0x00007F64 & 0xFF) = 100 image (0x00007F35 & 0xFF) = 53 image (0x00007F64 & 0xFF) = 100 Bank 15 release rates are: 100, 53, XX, 100, 100, 95, 100, XX, 10, XX, 81, 62, 114, XX, 90, 142

That’s literally the data right there that I want to be exported into the debug TXT file!

So in Star Fox 64, bank 15, instrument 0: From this: Attack 00000000 Decay 7FFFFFFF Sustain 03E80000 Release FB500000 - 0002 7FBC 0001 7FBC 7FBC 72F6 FFFF 0000 To this: Attack 00000000 Decay 7FFFFFFF Sustain 03E80000 Release FB500000 - 0002 7FBC 0001 7FBC 7FBC 72F6 FFFF 0000 64

Instrument 1 from this: Attack 00000000 Decay 7FFFFFFF Sustain 03E80000 Release FB500000 - 0002 7FBC 0001 7FBC 7FBC 72F6 FFFF 0000 To this: Attack 00000000 Decay 7FFFFFFF Sustain 03E80000 Release FB500000 - 0002 7FBC 0001 7FBC 7FBC 72F6 FFFF 0000 35

Instrument 3 to this: Attack 00000000 Decay 7FFFFFFF Sustain 03E80000 Release FB500000 - 0002 7FBC 0001 7FBC 7FBC 72F6 FFFF 0000 64

SubDrag commented 2 years ago

It now just spits out after ADSR 8 values the 4-byte Splits/release time in hex.