Cleaner sndGetPitch

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

View File

@ -919,10 +919,10 @@ LIBS = [
},
{
"lib": "musyx",
#"mw_version": "1.2.5",
#"cflags": "-proc gecko -fp hard -nodefaults -nosyspath -i include -i libc -g -sym on -D_DEBUG=1 -enum int ",
"mw_version": "1.3.2",
"cflags": "$cflags_musyx",
"mw_version": "1.2.5",
"cflags": "-proc gecko -fp hard -nodefaults -nosyspath -i include -i libc -g -sym on -D_DEBUG=1 -enum int ",
#"mw_version": "1.3.2",
#"cflags": "$cflags_musyx",
"host": False,
"objects": [
"musyx/runtime/seq",
@ -956,6 +956,7 @@ LIBS = [
["musyx/runtime/StdReverb/reverb", False],
["musyx/runtime/Delay/delay_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) {

View File

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