Cleaner sndGetPitch

Former-commit-id: 82e0878653
This commit is contained in:
Phillip Stephens 2023-02-24 18:34:38 -08:00
parent dd529d8018
commit 5d2693e5c9
3 changed files with 23 additions and 18 deletions

View File

@ -919,10 +919,10 @@ LIBS = [
}, },
{ {
"lib": "musyx", "lib": "musyx",
#"mw_version": "1.2.5", "mw_version": "1.2.5",
#"cflags": "-proc gecko -fp hard -nodefaults -nosyspath -i include -i libc -g -sym on -D_DEBUG=1 -enum int ", "cflags": "-proc gecko -fp hard -nodefaults -nosyspath -i include -i libc -g -sym on -D_DEBUG=1 -enum int ",
"mw_version": "1.3.2", #"mw_version": "1.3.2",
"cflags": "$cflags_musyx", #"cflags": "$cflags_musyx",
"host": False, "host": False,
"objects": [ "objects": [
"musyx/runtime/seq", "musyx/runtime/seq",
@ -956,6 +956,7 @@ LIBS = [
["musyx/runtime/StdReverb/reverb", False], ["musyx/runtime/StdReverb/reverb", False],
["musyx/runtime/Delay/delay_fx", True], ["musyx/runtime/Delay/delay_fx", True],
["musyx/runtime/Chorus/chorus_fx", True], ["musyx/runtime/Chorus/chorus_fx", True],
["musyx/runtime/profile", True],
], ],
}, },
{ {

View File

@ -271,6 +271,7 @@ unsigned long sndPopGroup() {
*/ */
u32 seqPlaySong(u16 sgid, u16 sid, void* arrfile, SND_PLAYPARA* para, u8 irq_call, u8 studio) { u32 seqPlaySong(u16 sgid, u16 sid, void* arrfile, SND_PLAYPARA* para, u8 irq_call, u8 studio) {

View File

@ -52,19 +52,22 @@ float tonedown_tab[128] = {
s32 sndPitchUpOne(u16 note) { return note * 1.0594631f; } s32 sndPitchUpOne(u16 note) { return note * 1.0594631f; }
u32 sndGetPitch(u8 arg0, u32 arg1) { u32 sndGetPitch(u8 key, u32 sInfo) {
f32 pitch; u8 okey; // r31
double tmp; float frq; // r63
u32 temp_r6; if (sInfo == 0xffffffff) {
sInfo = 0x40005622;
if (arg1 == 0xFFFFFFFF) {
arg1 = 0x40005622;
} }
pitch = 4096.f;
temp_r6 = (arg1 >> 24); okey = sInfo >> 24;
pitch *= (f32)(arg0 != temp_r6
? (f32)((arg1 & 0xFFFFFF) * (temp_r6 < arg0 ? toneup_tab[(arg0 - temp_r6)] if (key != okey) {
: tonedown_tab[temp_r6 - arg0])) frq = (float)(sInfo & 0xFFFFFF) *
: (f32)(arg1 & 0xFFFFFF)); (okey < key ? toneup_tab[key - okey] : tonedown_tab[okey - key]);
return pitch / synthInfo.mixFrq;
} else {
frq = sInfo & 0xFFFFFF;
}
return (4096.f * frq) / synthInfo.mixFrq;
} }