Match adsrHandle

Former-commit-id: 3cd23e9ab856d3b4ef139eb432adeb23d723632f
This commit is contained in:
Phillip Stephens 2023-10-26 18:49:24 -07:00
parent c712d523b3
commit 7d74b1f127
3 changed files with 62 additions and 6 deletions

View File

@ -1172,11 +1172,11 @@ config.libs = [
], ],
}, },
MusyX( MusyX(
# debug=True, debug=True,
# mw_version="GC/1.2.5", mw_version="GC/1.2.5",
# major=2, major=1,
# minor=0, minor=5,
# patch=0, patch=3,
objects=[ objects=[
Object(Matching, "musyx/runtime/seq.c"), Object(Matching, "musyx/runtime/seq.c"),
Object(Matching, "musyx/runtime/synth.c"), Object(Matching, "musyx/runtime/synth.c"),

View File

@ -513,7 +513,7 @@ typedef struct SYNTH_VOICE {
u32 id; // offset 0xF4, size 0x4 u32 id; // offset 0xF4, size 0x4
VID_LIST* vidList; // offset 0xF8, size 0x4 VID_LIST* vidList; // offset 0xF8, size 0x4
VID_LIST* vidMasterList; // offset 0xFC, size 0x4 VID_LIST* vidMasterList; // offset 0xFC, size 0x4
#if MUSY_VERSION > MUSY_VERSION_CHECK(1, 5, 3) && MUSY_VERSION <= MUSY_VERSION_CHECK(2, 0, 0) #if MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 0) && MUSY_VERSION <= MUSY_VERSION_CHECK(2, 0, 0)
u16 allocId; // offset 0x100, size 0x2 u16 allocId; // offset 0x100, size 0x2
#else #else
u32 allocId; u32 allocId;

View File

@ -13,9 +13,14 @@ static u32 adsrGetIndex(ADSR_VARS* adsr) {
u32 adsrConvertTimeCents(long tc) { return 1000.f * powf(2.f, 1.2715658e-08f * tc); } u32 adsrConvertTimeCents(long tc) { return 1000.f * powf(2.f, 1.2715658e-08f * tc); }
#pragma dont_inline on
u32 salChangeADSRState(ADSR_VARS* adsr) { u32 salChangeADSRState(ADSR_VARS* adsr) {
u32 VoiceDone; // r30 u32 VoiceDone; // r30
VoiceDone = FALSE;
return VoiceDone;
} }
#pragma dont_inline reset
u32 adsrSetup(ADSR_VARS* adsr) { u32 adsrSetup(ADSR_VARS* adsr) {
adsr->state = 0; adsr->state = 0;
@ -68,6 +73,57 @@ u32 adsrHandle(ADSR_VARS* adsr, u16* adsr_start, u16* adsr_delta) {
s32 old_volume; // r29 s32 old_volume; // r29
bool VoiceDone; // r28 bool VoiceDone; // r28
s32 vDelta; // r27 s32 vDelta; // r27
VoiceDone = FALSE;
switch (adsr->mode) {
case 0:
if (adsr->state != 3) {
old_volume = adsr->currentVolume;
adsr->currentVolume += adsr->currentDelta;
*adsr_start = old_volume >> 16;
if (adsr->currentDelta >= 0) {
*adsr_delta = adsr->currentDelta >> 21;
} else {
*adsr_delta = -(-adsr->currentDelta >> 21);
}
if (--adsr->cnt == 0) {
VoiceDone = salChangeADSRState(adsr);
}
} else {
*adsr_start = adsr->currentVolume >> 16;
*adsr_delta = 0;
}
break;
case 1:
if (adsr->state != 3) {
old_volume = adsr->currentVolume;
if (adsr->data.dls.aMode == 0 && adsr->state == 1) {
adsr->currentVolume += adsr->currentDelta;
} else {
adsr->currentIndex += adsr->currentDelta;
adsr->currentVolume = dspAttenuationTab[adsrGetIndex(adsr)] << 16;
}
*adsr_start = old_volume >> 16;
vDelta = adsr->currentVolume - old_volume;
if (vDelta >= 0) {
*adsr_delta = vDelta >> 21;
} else {
*adsr_delta = -(-vDelta >> 21);
}
if (--adsr->cnt == 0) {
VoiceDone = salChangeADSRState(adsr);
}
} else {
*adsr_start = adsr->currentVolume >> 16;
*adsr_delta = 0;
}
break;
}
return VoiceDone;
} }
u32 adsrHandleLowPrecision(ADSR_VARS* adsr, u16* adsr_start, u16* adsr_delta) { u32 adsrHandleLowPrecision(ADSR_VARS* adsr, u16* adsr_start, u16* adsr_delta) {
u8 i; // r31 u8 i; // r31