mirror of https://github.com/PrimeDecomp/prime.git
Match and link snd3d.c
Former-commit-id: 0c0fecfb797ed42f5e50d43fd5149eff7d4bcba0
This commit is contained in:
parent
476175e460
commit
a29290780b
|
@ -1184,7 +1184,7 @@ config.libs = [
|
||||||
Object(Matching, "musyx/runtime/s_data.c"),
|
Object(Matching, "musyx/runtime/s_data.c"),
|
||||||
Object(NonMatching, "musyx/runtime/hw_dspctrl.c"),
|
Object(NonMatching, "musyx/runtime/hw_dspctrl.c"),
|
||||||
Object(Matching, "musyx/runtime/hw_volconv.c"),
|
Object(Matching, "musyx/runtime/hw_volconv.c"),
|
||||||
Object(NonMatching, "musyx/runtime/snd3d.c"),
|
Object(Matching, "musyx/runtime/snd3d.c"),
|
||||||
Object(Matching, "musyx/runtime/snd_init.c"),
|
Object(Matching, "musyx/runtime/snd_init.c"),
|
||||||
Object(Matching, "musyx/runtime/snd_math.c"),
|
Object(Matching, "musyx/runtime/snd_math.c"),
|
||||||
Object(NonMatching, "musyx/runtime/snd_midictrl.c"),
|
Object(NonMatching, "musyx/runtime/snd_midictrl.c"),
|
||||||
|
|
|
@ -30,6 +30,10 @@ void hwSetVirtualSampleLoopBuffer(u32 voice, void* addr, u32 len);
|
||||||
u16 hwGetSampleID(u32 voice);
|
u16 hwGetSampleID(u32 voice);
|
||||||
u8 hwGetSampleType(u32 voice);
|
u8 hwGetSampleType(u32 voice);
|
||||||
void hwChangeStudioMix(u8 studio, u32 isMaster);
|
void hwChangeStudioMix(u8 studio, u32 isMaster);
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
void hwSetFilter(unsigned long v, unsigned char mode, unsigned short coefA, unsigned short coefB);
|
||||||
|
void hwLowPassFrqToCoef(unsigned long frq, unsigned short* _a0, unsigned short* _b1);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,7 +513,11 @@ 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(2, 0, 0)
|
||||||
u16 allocId; // offset 0x100, size 0x2
|
u16 allocId; // offset 0x100, size 0x2
|
||||||
|
#else
|
||||||
|
u32 allocId;
|
||||||
|
#endif
|
||||||
u16 macroId; // offset 0x102, size 0x2
|
u16 macroId; // offset 0x102, size 0x2
|
||||||
u8 keyGroup; // offset 0x104, size 0x1
|
u8 keyGroup; // offset 0x104, size 0x1
|
||||||
u32 lastVID; // offset 0x108, size 0x4
|
u32 lastVID; // offset 0x108, size 0x4
|
||||||
|
@ -534,6 +538,9 @@ typedef struct SYNTH_VOICE {
|
||||||
#endif
|
#endif
|
||||||
u32 sInfo; // offset 0x124, size 0x4
|
u32 sInfo; // offset 0x124, size 0x4
|
||||||
u32 playFrq; // offset 0x128, size 0x4
|
u32 playFrq; // offset 0x128, size 0x4
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
u16 sampleId;
|
||||||
|
#endif
|
||||||
u16 curNote; // offset 0x12C, size 0x2
|
u16 curNote; // offset 0x12C, size 0x2
|
||||||
s8 curDetune; // offset 0x12E, size 0x1
|
s8 curDetune; // offset 0x12E, size 0x1
|
||||||
u8 orgNote; // offset 0x12F, size 0x1
|
u8 orgNote; // offset 0x12F, size 0x1
|
||||||
|
@ -577,6 +584,10 @@ typedef struct SYNTH_VOICE {
|
||||||
u8 pbLowerKeyRange; // offset 0x1D6, size 0x1
|
u8 pbLowerKeyRange; // offset 0x1D6, size 0x1
|
||||||
u8 pbUpperKeyRange; // offset 0x1D7, size 0x1
|
u8 pbUpperKeyRange; // offset 0x1D7, size 0x1
|
||||||
u16 pbLast; // offset 0x1D8, size 0x2
|
u16 pbLast; // offset 0x1D8, size 0x2
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
u32 lpfLowerFrqBoundary;
|
||||||
|
u32 lpfUpperFrqBoundary;
|
||||||
|
#endif
|
||||||
ADSR_VARS pitchADSR; // offset 0x1DC, size 0x28
|
ADSR_VARS pitchADSR; // offset 0x1DC, size 0x28
|
||||||
s16 pitchADSRRange; // offset 0x204, size 0x2
|
s16 pitchADSRRange; // offset 0x204, size 0x2
|
||||||
u16 curPitch; // offset 0x206, size 0x2
|
u16 curPitch; // offset 0x206, size 0x2
|
||||||
|
@ -606,6 +617,10 @@ typedef struct SYNTH_VOICE {
|
||||||
CTRL_DEST inpPreAuxB; // offset 0x380, size 0x24
|
CTRL_DEST inpPreAuxB; // offset 0x380, size 0x24
|
||||||
CTRL_DEST inpPostAuxB; // offset 0x3A4, size 0x24
|
CTRL_DEST inpPostAuxB; // offset 0x3A4, size 0x24
|
||||||
CTRL_DEST inpTremolo; // offset 0x3C8, size 0x24
|
CTRL_DEST inpTremolo; // offset 0x3C8, size 0x24
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
CTRL_DEST inpFilterSwitch; // offset 0x3F8, size 0x24
|
||||||
|
CTRL_DEST inpFilterParameter; // offset 0x41C, size 0x24
|
||||||
|
#endif
|
||||||
u8 mesgNum; // offset 0x3EC, size 0x1
|
u8 mesgNum; // offset 0x3EC, size 0x1
|
||||||
u8 mesgRead; // offset 0x3ED, size 0x1
|
u8 mesgRead; // offset 0x3ED, size 0x1
|
||||||
u8 mesgWrite; // offset 0x3EE, size 0x1
|
u8 mesgWrite; // offset 0x3EE, size 0x1
|
||||||
|
@ -855,7 +870,11 @@ typedef struct ADSR_INFO {
|
||||||
} ADSR_INFO;
|
} ADSR_INFO;
|
||||||
|
|
||||||
void dataInit(u32, u32); /* extern */
|
void dataInit(u32, u32); /* extern */
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
void dataInitStack(unsigned long aramBase, unsigned long aramSize);
|
||||||
|
#else
|
||||||
void dataInitStack(); /* extern */
|
void dataInitStack(); /* extern */
|
||||||
|
#endif
|
||||||
u32 dataInsertSDir(SDIR_DATA* sdir, void* smp_data);
|
u32 dataInsertSDir(SDIR_DATA* sdir, void* smp_data);
|
||||||
u32 dataRemoveSDir(SDIR_DATA* sdir);
|
u32 dataRemoveSDir(SDIR_DATA* sdir);
|
||||||
u32 dataInsertMacro(u16 mid, void* macroaddr);
|
u32 dataInsertMacro(u16 mid, void* macroaddr);
|
||||||
|
@ -1058,6 +1077,11 @@ void inpSetMidiCtrl(u8 ctrl, u8 channel, u8 set, u8 value);
|
||||||
void inpSetMidiCtrl14(u8 ctrl, u8 channel, u8 set, u16 value);
|
void inpSetMidiCtrl14(u8 ctrl, u8 channel, u8 set, u16 value);
|
||||||
void inpSetExCtrl(SYNTH_VOICE* svoice, u8 ctrl, s16 v);
|
void inpSetExCtrl(SYNTH_VOICE* svoice, u8 ctrl, s16 v);
|
||||||
CHANNEL_DEFAULTS* inpGetChannelDefaults(u8 midi, u8 midiSet);
|
CHANNEL_DEFAULTS* inpGetChannelDefaults(u8 midi, u8 midiSet);
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
unsigned short inpGetFilterSwitch(struct SYNTH_VOICE* svoice);
|
||||||
|
unsigned short inpGetFilterParameter(struct SYNTH_VOICE* svoice);
|
||||||
|
void inpSetLPFDefaultRange(u32 lowFrq, u32 highFrq);
|
||||||
|
#endif
|
||||||
extern CTRL_DEST inpAuxA[8][4];
|
extern CTRL_DEST inpAuxA[8][4];
|
||||||
extern CTRL_DEST inpAuxB[8][4];
|
extern CTRL_DEST inpAuxB[8][4];
|
||||||
void inpSetMidiLastNote(u8 midi, u8 midiSet, u8 key);
|
void inpSetMidiLastNote(u8 midi, u8 midiSet, u8 key);
|
||||||
|
|
|
@ -40,6 +40,11 @@ void hwSetAUXProcessingCallbacks(u8 studio, SND_AUX_CALLBACK auxA, void* userA,
|
||||||
MSTEP* dataGetMacro(u16 mid);
|
MSTEP* dataGetMacro(u16 mid);
|
||||||
|
|
||||||
u32 voiceAllocate(u8 priority, u8 maxVoices, u16 allocId, u8 fxFlag);
|
u32 voiceAllocate(u8 priority, u8 maxVoices, u16 allocId, u8 fxFlag);
|
||||||
|
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
int voiceAllocatePeek(u8 priority, u8 maxVoices, u32 allocId, u8 fxFlag, u32 * currentAllocId);
|
||||||
|
#endif
|
||||||
|
|
||||||
void voiceFree(SYNTH_VOICE* svoice);
|
void voiceFree(SYNTH_VOICE* svoice);
|
||||||
void synthActivateStudio(u8 studio, u32 isMaster, SND_STUDIO_TYPE type);
|
void synthActivateStudio(u8 studio, u32 isMaster, SND_STUDIO_TYPE type);
|
||||||
void synthDeactivateStudio(u8 studio);
|
void synthDeactivateStudio(u8 studio);
|
||||||
|
|
|
@ -125,7 +125,7 @@ static void CheckRoomStatus() {
|
||||||
room->distance = distance;
|
room->distance = distance;
|
||||||
room->curMVol = has_listener ? 0x7f0000 : 0;
|
room->curMVol = has_listener ? 0x7f0000 : 0;
|
||||||
|
|
||||||
if (room->curMVol * 1.201479e-07f >= 0.5) {
|
if (room->curMVol * 1.2014794e-07f >= 0.5) {
|
||||||
synthActivateStudio(room->studio, TRUE, SND_STUDIO_TYPE_STD);
|
synthActivateStudio(room->studio, TRUE, SND_STUDIO_TYPE_STD);
|
||||||
} else {
|
} else {
|
||||||
synthActivateStudio(room->studio, FALSE, SND_STUDIO_TYPE_STD);
|
synthActivateStudio(room->studio, FALSE, SND_STUDIO_TYPE_STD);
|
||||||
|
@ -142,7 +142,7 @@ static void CheckRoomStatus() {
|
||||||
room->flags &= ~0x80000000;
|
room->flags &= ~0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (room->curMVol * 1.201479e-07f >= 0.5) {
|
if (room->curMVol * 1.2014794e-07f >= 0.5) {
|
||||||
synthActivateStudio(room->studio, TRUE, SND_STUDIO_TYPE_STD);
|
synthActivateStudio(room->studio, TRUE, SND_STUDIO_TYPE_STD);
|
||||||
} else {
|
} else {
|
||||||
synthActivateStudio(room->studio, FALSE, SND_STUDIO_TYPE_STD);
|
synthActivateStudio(room->studio, FALSE, SND_STUDIO_TYPE_STD);
|
||||||
|
@ -155,7 +155,7 @@ static void CheckRoomStatus() {
|
||||||
room->curMVol = 0;
|
room->curMVol = 0;
|
||||||
room->flags &= ~0x40000000;
|
room->flags &= ~0x40000000;
|
||||||
}
|
}
|
||||||
if (room->curMVol * 1.201479e-07f >= 0.5) {
|
if (room->curMVol * 1.2014794e-07f >= 0.5) {
|
||||||
synthActivateStudio(room->studio, TRUE, SND_STUDIO_TYPE_STD);
|
synthActivateStudio(room->studio, TRUE, SND_STUDIO_TYPE_STD);
|
||||||
} else {
|
} else {
|
||||||
synthActivateStudio(room->studio, FALSE, SND_STUDIO_TYPE_STD);
|
synthActivateStudio(room->studio, FALSE, SND_STUDIO_TYPE_STD);
|
||||||
|
@ -444,7 +444,7 @@ static u16 clip3FFF(u32 v) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetFXParameters(SND_EMITTER* em, f32 vol, f32 xPan, f32 yPan, f32 zPan, f32 doppler) {
|
static void SetFXParameters(SND_EMITTER* const em, f32 vol, f32 xPan, f32 yPan, f32 zPan, f32 doppler) {
|
||||||
SND_VOICEID vid; // r30
|
SND_VOICEID vid; // r30
|
||||||
u8 i; // r28
|
u8 i; // r28
|
||||||
SND_PARAMETER* pPtr; // r31
|
SND_PARAMETER* pPtr; // r31
|
||||||
|
|
|
@ -26,21 +26,29 @@
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static s32 DoInit(u32 rate, u32 aramSize, u32 voices, u32 flags) {
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
long DoInit(u32 mixFrq, u32 numVoices, u32 flags, u32 aramBase, u32 aramSize)
|
||||||
|
#else
|
||||||
|
static s32 DoInit(u32 mixFrq, u32 aramSize, u32 numVoices, u32 flags)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
MUSY_DEBUG("\nMusyX software initialization...\nBuild Date: %s %s\n\n", __DATE__, __TIME__);
|
MUSY_DEBUG("\nMusyX software initialization...\nBuild Date: %s %s\n\n", "Dec 17 2003", "20:32:41");
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
|
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
dataInitStack(aramBase, aramGetUserBytes(aramSize));
|
||||||
|
#else
|
||||||
dataInitStack();
|
dataInitStack();
|
||||||
|
#endif
|
||||||
dataInit(0, aramSize);
|
dataInit(0, aramSize);
|
||||||
|
|
||||||
seqInit();
|
seqInit();
|
||||||
|
|
||||||
synthIdleWaitActive = 0;
|
synthIdleWaitActive = 0;
|
||||||
|
|
||||||
synthInit(rate, voices);
|
synthInit(mixFrq, numVoices);
|
||||||
|
|
||||||
streamInit();
|
streamInit();
|
||||||
|
|
||||||
|
@ -72,6 +80,7 @@ s32 sndInit(u8 voices, u8 music, u8 sfx, u8 studios, u32 flags, u32 aramSize) {
|
||||||
u32 frq; // r1+0x14
|
u32 frq; // r1+0x14
|
||||||
|
|
||||||
MUSY_DEBUG("Entering sndInit()\n\n");
|
MUSY_DEBUG("Entering sndInit()\n\n");
|
||||||
|
ret = 0;
|
||||||
sndActive = 0;
|
sndActive = 0;
|
||||||
if (voices <= 64) {
|
if (voices <= 64) {
|
||||||
synthInfo.voiceNum = voices;
|
synthInfo.voiceNum = voices;
|
||||||
|
@ -88,7 +97,11 @@ s32 sndInit(u8 voices, u8 music, u8 sfx, u8 studios, u32 flags, u32 aramSize) {
|
||||||
synthInfo.maxSFX = sfx;
|
synthInfo.maxSFX = sfx;
|
||||||
frq = 32000;
|
frq = 32000;
|
||||||
if ((ret = hwInit(&frq, synthInfo.voiceNum, synthInfo.studioNum, flags)) == 0) {
|
if ((ret = hwInit(&frq, synthInfo.voiceNum, synthInfo.studioNum, flags)) == 0) {
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
ret = DoInit(32000, synthInfo.voiceNum, flags, aramGetFirstUserAddress(), aramSize);
|
||||||
|
#else
|
||||||
ret = DoInit(32000, aramSize, synthInfo.voiceNum, flags);
|
ret = DoInit(32000, aramSize, synthInfo.voiceNum, flags);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MUSY_DEBUG("Leaving sndInit().\n\n");
|
MUSY_DEBUG("Leaving sndInit().\n\n");
|
||||||
|
@ -145,3 +158,9 @@ SND_PLAYBACKINFO* sndGetPlayBackInfo() {
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
void sndSetLowPassFilterDefaultRange(unsigned long lowFrq, unsigned long highFrq) {
|
||||||
|
inpSetLPFDefaultRange(lowFrq, highFrq);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
#include "musyx/synth.h"
|
#include "musyx/synth.h"
|
||||||
|
#include "musyx/hardware.h"
|
||||||
#include "musyx/musyx_priv.h"
|
#include "musyx/musyx_priv.h"
|
||||||
|
|
||||||
static u32 synthTicksPerSecond[9][16];
|
static u32 synthTicksPerSecond[9][16];
|
||||||
|
@ -315,7 +316,6 @@ static void unblockAllAllocatedVoices(u32 vid) {
|
||||||
u32 id; // r31
|
u32 id; // r31
|
||||||
|
|
||||||
id = vidGetInternalId(vid);
|
id = vidGetInternalId(vid);
|
||||||
#line 501
|
|
||||||
MUSY_ASSERT_MSG(id != SND_ID_ERROR, "*** Alloc unblock: ID is illegal");
|
MUSY_ASSERT_MSG(id != SND_ID_ERROR, "*** Alloc unblock: ID is illegal");
|
||||||
while (id != SND_ID_ERROR) {
|
while (id != SND_ID_ERROR) {
|
||||||
synthVoice[id & 0xff].block = 0;
|
synthVoice[id & 0xff].block = 0;
|
||||||
|
@ -393,7 +393,11 @@ static void UpdateTimeMIDICtrl(SYNTH_VOICE* sv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sv->timeUsedByInput = 0;
|
sv->timeUsedByInput = 0;
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
sv->midiDirtyFlags = 0x7fff;
|
||||||
|
#else
|
||||||
sv->midiDirtyFlags = 0x1fff;
|
sv->midiDirtyFlags = 0x1fff;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LowPrecisionHandler(u32 i) {
|
static void LowPrecisionHandler(u32 i) {
|
||||||
|
@ -430,7 +434,11 @@ static void LowPrecisionHandler(u32 i) {
|
||||||
sv->lfo[j].lastValue = sv->lfo[j].value;
|
sv->lfo[j].lastValue = sv->lfo[j].value;
|
||||||
if (sv->lfoUsedByInput[j]) {
|
if (sv->lfoUsedByInput[j]) {
|
||||||
sv->lfoUsedByInput[j] = 0;
|
sv->lfoUsedByInput[j] = 0;
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
sv->midiDirtyFlags |= 0x7fff;
|
||||||
|
#else
|
||||||
sv->midiDirtyFlags |= 0x1fff;
|
sv->midiDirtyFlags |= 0x1fff;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -441,8 +449,13 @@ static void LowPrecisionHandler(u32 i) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sv->sweepNum[0] | sv->sweepNum[1]) {
|
if (sv->sweepNum[0] | sv->sweepNum[1]) {
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
cntDelta = (lowDeltaTime << 8) >> 4;
|
||||||
|
addFactor = (lowDeltaTime << 4) >> 4;
|
||||||
|
#else
|
||||||
cntDelta = (lowDeltaTime & 0x00ffffff) << 4;
|
cntDelta = (lowDeltaTime & 0x00ffffff) << 4;
|
||||||
addFactor = lowDeltaTime & 0x0fffffff;
|
addFactor = lowDeltaTime & 0x0fffffff;
|
||||||
|
#endif
|
||||||
for (j = 0; j < 2; ++j) {
|
for (j = 0; j < 2; ++j) {
|
||||||
if (sv->sweepNum[j] == 0) {
|
if (sv->sweepNum[j] == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -508,14 +521,18 @@ static void LowPrecisionHandler(u32 i) {
|
||||||
Modulation = inpGetModulation(sv);
|
Modulation = inpGetModulation(sv);
|
||||||
vrange = sv->vibKeyRange * 256 + (sv->vibCentRange * 256) / 100;
|
vrange = sv->vibKeyRange * 256 + (sv->vibCentRange * 256) / 100;
|
||||||
if (sv->vibModAddScale != 0) {
|
if (sv->vibModAddScale != 0) {
|
||||||
#if MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 4)
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
vrange += (sv->vibModAddScale * (Modulation >> 7)) >> 7;
|
||||||
|
#elif MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 4)
|
||||||
vrange += (sv->vibModAddScale * ((Modulation & 0x1ffff) >> 7)) >> 7;
|
vrange += (sv->vibModAddScale * ((Modulation & 0x1ffff) >> 7)) >> 7;
|
||||||
#else
|
#else
|
||||||
vrange += (sv->vibModAddScale * ((Modulation >> 7) & 0x1ff)) >> 7;
|
vrange += (sv->vibModAddScale * ((Modulation >> 7) & 0x1ff)) >> 7;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if ((sv->cFlags & 0x4000) != 0) {
|
if ((sv->cFlags & 0x4000) != 0) {
|
||||||
#if MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 4)
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
voff = (sv->vibCurOffset * (Modulation >> 7)) >> 7;
|
||||||
|
#elif MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 4)
|
||||||
voff = (sv->vibCurOffset * ((Modulation & 0x1ffff) >> 7)) >> 7;
|
voff = (sv->vibCurOffset * ((Modulation & 0x1ffff) >> 7)) >> 7;
|
||||||
#else
|
#else
|
||||||
voff = (sv->vibCurOffset * ((Modulation >> 7) & 0x1ff)) >> 7;
|
voff = (sv->vibCurOffset * ((Modulation >> 7) & 0x1ff)) >> 7;
|
||||||
|
@ -575,6 +592,12 @@ static void ZeroOffsetHandler(u32 i) {
|
||||||
s32 pan; // r28
|
s32 pan; // r28
|
||||||
f32 preVol; // f26
|
f32 preVol; // f26
|
||||||
f32 postVol; // f29
|
f32 postVol; // f29
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
unsigned short para; // r22
|
||||||
|
unsigned short a0; // r1+0xA
|
||||||
|
unsigned short b0; // r1+0x8
|
||||||
|
unsigned long frq; // r21
|
||||||
|
#endif
|
||||||
|
|
||||||
sv = &synthVoice[i];
|
sv = &synthVoice[i];
|
||||||
if (!hwIsActive(i) && sv->addr == NULL) {
|
if (!hwIsActive(i) && sv->addr == NULL) {
|
||||||
|
@ -664,17 +687,28 @@ static void ZeroOffsetHandler(u32 i) {
|
||||||
|
|
||||||
if (volUpdate || (sv->midiDirtyFlags & 0xf01) != 0) {
|
if (volUpdate || (sv->midiDirtyFlags & 0xf01) != 0) {
|
||||||
preVol = voiceVol;
|
preVol = voiceVol;
|
||||||
postVol = voiceVol * vol * (f32)inpGetVolume(sv) * 0.00006103888f /* 1/16384? */;
|
postVol = voiceVol * vol * (f32)inpGetVolume(sv) * (1.f/16383.f) /* 1/16384? */;
|
||||||
auxa = ((f32)sv->revVolOffset * (1.f / 127.f)) +
|
auxa = ((f32)sv->revVolOffset * (1.f / 127.f)) +
|
||||||
((preVol * (f32)inpGetPreAuxA(sv) * 0.00006103888f /* 1/16384? */) +
|
((preVol * (f32)inpGetPreAuxA(sv) * (1.f/16383.f) /* 1/16384? */) +
|
||||||
((f32)sv->revVolScale *
|
((f32)sv->revVolScale *
|
||||||
(postVol * (f32)inpGetReverb(sv) * 0.00006103888f /* 1/16384? */) * (1.f / 127.f)));
|
(postVol * (f32)inpGetReverb(sv) * (1.f/16383.f) /* 1/16384? */) * (1.f / 127.f)));
|
||||||
auxb = (preVol * (f32)inpGetPreAuxB(sv) * 0.00006103888f /* 1/16384? */) +
|
auxb = (preVol * (f32)inpGetPreAuxB(sv) * (1.f/16383.f) /* 1/16384? */) +
|
||||||
(postVol * (f32)inpGetPostAuxB(sv) * 0.00006103888f /* 1/16384? */);
|
(postVol * (f32)inpGetPostAuxB(sv) * (1.f/16383.f) /* 1/16384? */);
|
||||||
sv->curOutputVolume = (u16)(postVol * 32767.f);
|
sv->curOutputVolume = (u16)(postVol * 32767.f);
|
||||||
hwSetVolume(i, sv->volTable, postVol, sv->lastPan, sv->lastSPan, auxa, auxb);
|
hwSetVolume(i, sv->volTable, postVol, sv->lastPan, sv->lastSPan, auxa, auxb);
|
||||||
}
|
}
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
if (sv->midiDirtyFlags & 0x6000) {
|
||||||
|
if (inpGetFilterSwitch(sv) > 0x1FFF) {
|
||||||
|
para = inpGetFilterParameter(sv);
|
||||||
|
frq = sv->lpfLowerFrqBoundary + (u32)((1.f - ((1.f/16383.f) * para)) * (sv->lpfUpperFrqBoundary - sv->lpfLowerFrqBoundary));
|
||||||
|
hwLowPassFrqToCoef(frq, &a0, &b0);
|
||||||
|
hwSetFilter(i, 1, a0, b0);
|
||||||
|
} else {
|
||||||
|
hwSetFilter(i, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (sv->age != 0) {
|
if (sv->age != 0) {
|
||||||
if ((s32)(sv->age -= sv->ageSpeed * lowDeltaTime) < 0) {
|
if ((s32)(sv->age -= sv->ageSpeed * lowDeltaTime) < 0) {
|
||||||
sv->age = 0;
|
sv->age = 0;
|
||||||
|
@ -943,6 +977,26 @@ u32 synthFXStart(u16 fid, u8 vol, u8 pan, u8 studio, u32 itd) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(2, 0, 3)
|
||||||
|
int synthCheckFXRealloc(unsigned short fid) {
|
||||||
|
struct FX_TAB* fx; // r31
|
||||||
|
unsigned long allocId; // r30
|
||||||
|
unsigned long currentAllocId; // r1+0x8
|
||||||
|
|
||||||
|
fx = dataGetFX(fid);
|
||||||
|
if (fx == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
allocId = fid | 0x80000000;
|
||||||
|
|
||||||
|
if (!voiceAllocatePeek(fx->priority, fx->maxVoices, allocId, TRUE, ¤tAllocId)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return allocId == currentAllocId;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool synthFXSetCtrl(u32 vid, u8 ctrl, u8 value) {
|
bool synthFXSetCtrl(u32 vid, u8 ctrl, u8 value) {
|
||||||
u32 i; // r31
|
u32 i; // r31
|
||||||
u32 ret; // r29
|
u32 ret; // r29
|
||||||
|
@ -1264,7 +1318,6 @@ static u32 synthHWMessageHandler(u32 mesg, u32 voiceID) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
#line 1975
|
|
||||||
MUSY_ASSERT(FALSE);
|
MUSY_ASSERT(FALSE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1283,7 +1336,6 @@ void synthInit(u32 mixFrq, u32 numVoices) {
|
||||||
|
|
||||||
synthVoice = salMalloc(numVoices * sizeof(SYNTH_VOICE));
|
synthVoice = salMalloc(numVoices * sizeof(SYNTH_VOICE));
|
||||||
if (synthVoice == NULL) {
|
if (synthVoice == NULL) {
|
||||||
#line 2135
|
|
||||||
MUSY_FATAL("Fatal: Could not allocate synthesizer voice array.");
|
MUSY_FATAL("Fatal: Could not allocate synthesizer voice array.");
|
||||||
}
|
}
|
||||||
memset(synthVoice, 0, numVoices * sizeof(SYNTH_VOICE));
|
memset(synthVoice, 0, numVoices * sizeof(SYNTH_VOICE));
|
||||||
|
|
Loading…
Reference in New Issue