Sound Sample Tuning (N64 Sound Tool)
#1
In SM64, each sound has some parameters attached to it. 
Some of these parameters are labelled "ADSR" under the sound tool.
More information on ADSR parameters are discussed in this thread.
Furthermore, there are parameters for base keys and instrument looping. Here, I'll discuss everything I know about the subject.
In most games, base key is given by a byte (0-127 or 0x00-0x7F) with a de-tune byte alongside.
In SM64, the base key is given by a float, in which one can assign a fractional key without using de-tune.
The following formula converts key to float: 

Code:
Float = 2^((60-key)/12)

Here is a graph of the function:

[Image: SM64KeyToFloat.png]

And here is an entire table of floats for each key:
Code:
Key: Float 0: 32 1: 30.20398 2: 28.50876 3: 26.90869 4: 25.39842 5: 23.97291 6: 22.62742 7: 21.35744 8: 20.15874 9: 19.02731 10: 17.95939 11: 16.95141 12: 16 13: 15.10199 14: 14.25438 15: 13.45434 16: 12.69921 17: 11.98646 18: 11.31371 19: 10.67872 20: 10.07937 21: 9.513657 22: 8.979696 23: 8.475705 24: 8 25: 7.550994 26: 7.12719 27: 6.727171 28: 6.349604 29: 5.993228 30: 5.656854 31: 5.339359 32: 5.039684 33: 4.756828 34: 4.489848 35: 4.237853 36: 4 37: 3.775497 38: 3.563595 39: 3.363586 40: 3.174802 41: 2.996614 42: 2.828427 43: 2.66968 44: 2.519842 45: 2.378414 46: 2.244924 47: 2.118926 48: 2 49: 1.887749 50: 1.781797 51: 1.681793 52: 1.587401 53: 1.498307 54: 1.414214 55: 1.33484 56: 1.259921 57: 1.189207 58: 1.122462 59: 1.059463 60: 1 61: 0.9438743 62: 0.8908987 63: 0.8408964 64: 0.7937005 65: 0.7491536 66: 0.7071068 67: 0.6674199 68: 0.6299605 69: 0.5946035 70: 0.561231 71: 0.5297316 72: 0.5 73: 0.4719371 74: 0.4454494 75: 0.4204482 76: 0.3968503 77: 0.3745768 78: 0.3535534 79: 0.33371 80: 0.3149803 81: 0.2973018 82: 0.2806155 83: 0.2648658 84: 0.25 85: 0.2359686 86: 0.2227247 87: 0.2102241 88: 0.1984251 89: 0.1872884 90: 0.1767767 91: 0.166855 92: 0.1574901 93: 0.1486509 94: 0.1403078 95: 0.1324329 96: 0.125 97: 0.1179843 98: 0.1113623 99: 0.1051121 100: 0.09921256 101: 0.09364419 102: 0.08838835 103: 0.08342749 104: 0.07874507 105: 0.07432544 106: 0.07015388 107: 0.06621645 108: 0.0625 109: 0.05899214 110: 0.05568117 111: 0.05255603 112: 0.04960628 113: 0.0468221 114: 0.04419417 115: 0.04171374 116: 0.03937253 117: 0.03716272 118: 0.03507694 119: 0.03310822 120: 0.03125 121: 0.02949607 122: 0.02784058 123: 0.02627801 124: 0.02480314 125: 0.02341105 126: 0.02209709 127: 0.02085687

So, if you wanted a 72-and-a-half key (mid-semitone), you would use 2^((60-72.5)/12) = 0.485766.

Now, there are optional previous and secondary samples for instruments. Using the "splits/release" value in the sound tool, you can choose the ranges for the primary sample before it splits to the previous or secondary sample (min/max keys before switch).

The value goes something like:
Code:
[00] [Min Key +- 0x15] [Max Key +- 0x15] [Release Time]

Where each value is a byte. I'm not sure why 0x15 is added or subtracted from each, but it's consistent, as in for 3 samples, it'll always be subtracted, and for previous-primary, it's always added. (More testing needed)

For instrument looping, having count set to 0x00000000 will DISABLE looping.
Having count set to 0xFFFFFFFF will ENABLE looping.
Loop start and end is used in cycles as measurement, in hex of course.
So having a larger value for end will wait longer for the loop.
Let me know if you discover any more information on sound data!
(Credit to shygoo for figuring out the float from key formula given correlated data)
Reply
#2
Figured out sample loop units: Samples.
So if your sample is 3.12 seconds long at 32KHz, you would calculate it as:
3.12 * 32,000 = 99,840 (0x18600)
So the end of your sample in the sound tool should be 00018600!
Reply
#3
I'm gonna add on to this, as I was experimenting with how the splits for the primary/previous/secondaries worked. And I was able to come up with this.

Quote:For samples that use Primary + Previous, you subtract 0x15.
For samples that use Primary + Previous + Secondary, you subtract 0x15.
For samples that use Primary + Secondary, you add 0x15.

I initially thought you had to add 0x15 to Primary + Previous, however that led to results that weren't accurate to how I wanted it laid out, but when I subtracted it, it worked perfectly. Turns out that it's Primary + Secondary you need to add 0x15 to.
Reply
#4
Another thing to add;
The difference between both sample rates 32000 and 22050 and converting between samples.
A sample with the pitch C in 22050 would be G in 32000, which would make sense it's 7 semitones apart(perfect 5th) and a common interval in music structure.
Reply
#5
May as well post this here, as this is Nutta's thread on the ADSR value, but it's now properly archived since it's on Skelux's old site, which who knows what will happen to it in the far future.

The ADSR Thread - Nutta (Archived)
Reply




Users browsing this thread: 1 Guest(s)