mirror of https://github.com/PrimeDecomp/prime.git
Match and link synth_vsamples.c
Former-commit-id: 6817810884b70efe70d1c5633b4ac32af08e1816
This commit is contained in:
parent
48191b46b7
commit
e4d1a69518
|
@ -1177,7 +1177,7 @@ config.libs = [
|
||||||
Object(NonMatching, "musyx/runtime/synthvoice.c"),
|
Object(NonMatching, "musyx/runtime/synthvoice.c"),
|
||||||
Object(Matching, "musyx/runtime/synth_ac.c"),
|
Object(Matching, "musyx/runtime/synth_ac.c"),
|
||||||
Object(NonMatching, "musyx/runtime/synth_adsr.c"),
|
Object(NonMatching, "musyx/runtime/synth_adsr.c"),
|
||||||
Object(NonMatching, "musyx/runtime/synth_vsamples.c"),
|
Object(Matching, "musyx/runtime/synth_vsamples.c"),
|
||||||
Object(Matching, "musyx/runtime/synth_dbtab.c"),
|
Object(Matching, "musyx/runtime/synth_dbtab.c"),
|
||||||
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"),
|
||||||
|
|
|
@ -24,6 +24,11 @@ u32 hwGetVirtualSampleState(u32 voice);
|
||||||
bool hwVoiceInStartup(u32 v);
|
bool hwVoiceInStartup(u32 v);
|
||||||
void hwBreak(s32 vid);
|
void hwBreak(s32 vid);
|
||||||
u32 hwGetPos(u32 v);
|
u32 hwGetPos(u32 v);
|
||||||
|
void hwInitSampleMem(u32 baseAddr, u32 length);
|
||||||
|
void hwExitSampleMem();
|
||||||
|
void hwSetVirtualSampleLoopBuffer(u32 voice, void* addr, u32 len);
|
||||||
|
u16 hwGetSampleID(u32 voice);
|
||||||
|
u8 hwGetSampleType(u32 voice);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ u32 vsSampleStartNotify(unsigned char voice) {
|
||||||
sb = vs.voices[voice] = vsAllocateBuffer();
|
sb = vs.voices[voice] = vsAllocateBuffer();
|
||||||
if (sb != 0xFF) {
|
if (sb != 0xFF) {
|
||||||
addr = aramGetStreamBufferAddress(vs.voices[voice], 0);
|
addr = aramGetStreamBufferAddress(vs.voices[voice], 0);
|
||||||
hwSetVirtualSampleLoopBuffer(voice, addr, vs.bufferLength);
|
hwSetVirtualSampleLoopBuffer(voice, (void*)addr, vs.bufferLength);
|
||||||
vs.streamBuffer[sb].info.smpID = hwGetSampleID(voice);
|
vs.streamBuffer[sb].info.smpID = hwGetSampleID(voice);
|
||||||
vs.streamBuffer[sb].info.instID = vsNewInstanceID();
|
vs.streamBuffer[sb].info.instID = vsNewInstanceID();
|
||||||
vs.streamBuffer[sb].smpType = hwGetSampleType(voice);
|
vs.streamBuffer[sb].smpType = hwGetSampleType(voice);
|
||||||
|
@ -108,41 +108,49 @@ void vsUpdateBuffer(struct VS_BUFFER* sb, unsigned long cpos) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((s32)sb->last < cpos) {
|
if ((s32)sb->last < cpos) {
|
||||||
if ((s8)sb->smpType != 5) {
|
switch (sb->smpType) {
|
||||||
cpos = cpos;
|
case 5:
|
||||||
} else {
|
|
||||||
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
||||||
sb->info.data.update.len1 = cpos - sb->last;
|
sb->info.data.update.len1 = cpos - sb->last;
|
||||||
sb->info.data.update.off2 = 0;
|
sb->info.data.update.off2 = 0;
|
||||||
sb->info.data.update.len2 = 0;
|
sb->info.data.update.len2 = 0;
|
||||||
if ((len = vs.callback(1, &sb->info)) != 0) {
|
if ((len = vs.callback(1, &sb->info)) != 0) {
|
||||||
off = sb->last + len;
|
off = sb->last + len;
|
||||||
sb->last = off - (off / vs.bufferLength) * vs.bufferLength;
|
sb->last = off % vs.bufferLength;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (cpos == 0) {
|
} else if (cpos == 0) {
|
||||||
if ((s8)sb->smpType != 5) {
|
switch (sb->smpType) {
|
||||||
cpos = cpos;
|
case 5:
|
||||||
} else {
|
|
||||||
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
||||||
sb->info.data.update.len1 = vs.bufferLength - sb->last;
|
sb->info.data.update.len1 = vs.bufferLength - sb->last;
|
||||||
sb->info.data.update.off2 = 0;
|
sb->info.data.update.off2 = 0;
|
||||||
sb->info.data.update.len2 = 0;
|
sb->info.data.update.len2 = 0;
|
||||||
if ((len = vs.callback(1, &sb->info)) != 0) {
|
if ((len = vs.callback(1, &sb->info)) != 0) {
|
||||||
off = sb->last + len;
|
off = sb->last + len;
|
||||||
sb->last = off - (off / vs.bufferLength) * vs.bufferLength;
|
sb->last = off % vs.bufferLength;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if ((s8)sb->smpType != 5) {
|
|
||||||
cpos = cpos;
|
|
||||||
} else {
|
} else {
|
||||||
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
switch (sb->smpType) {
|
||||||
sb->info.data.update.len1 = vs.bufferLength - sb->last;
|
case 5:
|
||||||
sb->info.data.update.off2 = 0;
|
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
||||||
sb->info.data.update.len2 = cpos;
|
sb->info.data.update.len1 = vs.bufferLength - sb->last;
|
||||||
if ((len = vs.callback(1, &sb->info)) != 0) {
|
sb->info.data.update.off2 = 0;
|
||||||
off = sb->last + len;
|
sb->info.data.update.len2 = cpos;
|
||||||
sb->last = off - (off / vs.bufferLength) * vs.bufferLength;
|
if ((len = vs.callback(1, &sb->info)) != 0) {
|
||||||
|
off = sb->last + len;
|
||||||
|
sb->last = off % vs.bufferLength;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,12 +171,13 @@ void vsSampleUpdates() {
|
||||||
sb = &vs.streamBuffer[vs.voices[i]];
|
sb = &vs.streamBuffer[vs.voices[i]];
|
||||||
realCPos = hwGetPos(i);
|
realCPos = hwGetPos(i);
|
||||||
cpos = sb->smpType == 5 ? (realCPos / 14) * 14 : realCPos;
|
cpos = sb->smpType == 5 ? (realCPos / 14) * 14 : realCPos;
|
||||||
|
|
||||||
switch (sb->state) {
|
switch (sb->state) {
|
||||||
case 1:
|
case 1:
|
||||||
vsUpdateBuffer(sb, cpos);
|
vsUpdateBuffer(sb, cpos);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
case 3:
|
||||||
if (((sb->info.instID << 8) | sb->voice) == hwGetVirtualSampleID(sb->voice)) {
|
if (((sb->info.instID << 8) | sb->voice) == hwGetVirtualSampleID(sb->voice)) {
|
||||||
vsUpdateBuffer(sb, cpos);
|
vsUpdateBuffer(sb, cpos);
|
||||||
|
|
||||||
|
@ -179,7 +188,7 @@ void vsSampleUpdates() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sb->finalLast = realCPos;
|
sb->finalLast = realCPos;
|
||||||
nextSamples = (((synthVoice[sb->voice].curPitch * 160) + 0xFFF) >> 12);
|
nextSamples = (synthVoice[sb->voice].curPitch * 160 + 0xFFF) / 4096;
|
||||||
if ((s32)nextSamples > (s32)sb->finalGoodSamples) {
|
if ((s32)nextSamples > (s32)sb->finalGoodSamples) {
|
||||||
if (!hwVoiceInStartup(sb->voice)) {
|
if (!hwVoiceInStartup(sb->voice)) {
|
||||||
#if MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 4)
|
#if MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 4)
|
||||||
|
|
|
@ -280,9 +280,9 @@ bool dataRemoveSDir(struct SDIR_DATA* sdir) {
|
||||||
|
|
||||||
hwDisableIrq();
|
hwDisableIrq();
|
||||||
|
|
||||||
for (data = sdir; data->id != 0xFFFF;
|
for (data = sdir; data->id != 0xFFFF; ++data) {
|
||||||
++data) {
|
if (data->ref_cnt != 0xFFFF && data->ref_cnt != 0)
|
||||||
if (data->ref_cnt != 0xFFFF && data->ref_cnt != 0) break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->id == 0xFFFF) {
|
if (data->id == 0xFFFF) {
|
||||||
|
@ -290,35 +290,36 @@ bool dataRemoveSDir(struct SDIR_DATA* sdir) {
|
||||||
|
|
||||||
for (data = sdir; data->id != 0xFFFF; ++data) {
|
for (data = sdir; data->id != 0xFFFF; ++data) {
|
||||||
if (data->ref_cnt != 0xFFFF) {
|
if (data->ref_cnt != 0xFFFF) {
|
||||||
for (i = 0; i < dataSmpSDirNum; ++i) {
|
for (i = 0; i < dataSmpSDirNum; ++i) {
|
||||||
if (dataSmpSDirs[i].data == sdir) continue;
|
if (dataSmpSDirs[i].data == sdir)
|
||||||
for (j = 0; j < dataSmpSDirs[i].numSmp; ++j) {
|
continue;
|
||||||
if (data->id == dataSmpSDirs[i].data[j].id && dataSmpSDirs[i].data[j].ref_cnt == 0xFFFF) {
|
for (j = 0; j < dataSmpSDirs[i].numSmp; ++j) {
|
||||||
dataSmpSDirs[i].data[j].ref_cnt = 0;
|
if (data->id == dataSmpSDirs[i].data[j].id &&
|
||||||
break;
|
dataSmpSDirs[i].data[j].ref_cnt == 0xFFFF) {
|
||||||
}
|
dataSmpSDirs[i].data[j].ref_cnt = 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (j != dataSmpSDirs[i].numSmp) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (j != dataSmpSDirs[i].numSmp) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data = sdir;
|
data = sdir;
|
||||||
for (; data->id != 0xFFFF; ++data) {
|
for (; data->id != 0xFFFF; ++data) {
|
||||||
data->ref_cnt = 0;
|
data->ref_cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = index + 1; j < dataSmpSDirNum; ++j) {
|
for (j = index + 1; j < dataSmpSDirNum; ++j) {
|
||||||
dataSmpSDirs[j - 1] = dataSmpSDirs[j];
|
dataSmpSDirs[j - 1] = dataSmpSDirs[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
--dataSmpSDirNum;
|
--dataSmpSDirNum;
|
||||||
hwEnableIrq();
|
hwEnableIrq();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwEnableIrq();
|
hwEnableIrq();
|
||||||
|
@ -344,7 +345,8 @@ bool dataAddSampleReference(u16 sid) {
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
#line 542
|
#line 542
|
||||||
MUSY_ASSERT_MSG(sdir != NULL, "Sample ID to be inserted could not be found in any sample directory.\n");
|
MUSY_ASSERT_MSG(sdir != NULL,
|
||||||
|
"Sample ID to be inserted could not be found in any sample directory.\n");
|
||||||
|
|
||||||
if (sdir->ref_cnt == 0) {
|
if (sdir->ref_cnt == 0) {
|
||||||
sdir->addr = (void*)(sdir->offset + (s32)dataSmpSDirs[i].base);
|
sdir->addr = (void*)(sdir->offset + (s32)dataSmpSDirs[i].base);
|
||||||
|
@ -420,11 +422,11 @@ bool dataRemoveFX(u16 gid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dataInsertMacro(u16 mid, void* macroaddr) {
|
bool dataInsertMacro(u16 mid, void* macroaddr) {
|
||||||
long main; // r28
|
long main; // r28
|
||||||
long pos; // r29
|
long pos; // r29
|
||||||
long base; // r27
|
long base; // r27
|
||||||
long i; // r31
|
long i; // r31
|
||||||
|
|
||||||
hwDisableIrq();
|
hwDisableIrq();
|
||||||
|
|
||||||
main = (mid >> 6) & 0x3ff;
|
main = (mid >> 6) & 0x3ff;
|
||||||
|
@ -572,8 +574,8 @@ void* dataGetCurve(u16 cid) {
|
||||||
static DATA_TAB* result;
|
static DATA_TAB* result;
|
||||||
|
|
||||||
key.id = cid;
|
key.id = cid;
|
||||||
if (result =
|
if ((result =
|
||||||
(DATA_TAB*)sndBSearch(&key, dataCurveTab, dataCurveNum, sizeof(DATA_TAB), curvecmp)) {
|
(DATA_TAB*)sndBSearch(&key, dataCurveTab, dataCurveNum, sizeof(DATA_TAB), curvecmp))) {
|
||||||
return result->data;
|
return result->data;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -584,8 +586,8 @@ void* dataGetKeymap(u16 cid) {
|
||||||
static DATA_TAB* result;
|
static DATA_TAB* result;
|
||||||
|
|
||||||
key.id = cid;
|
key.id = cid;
|
||||||
if (result =
|
if ((result =
|
||||||
(DATA_TAB*)sndBSearch(&key, dataKeymapTab, dataKeymapNum, sizeof(DATA_TAB), curvecmp)) {
|
(DATA_TAB*)sndBSearch(&key, dataKeymapTab, dataKeymapNum, sizeof(DATA_TAB), curvecmp))) {
|
||||||
return result->data;
|
return result->data;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -598,8 +600,8 @@ void* dataGetLayer(u16 cid, u16* n) {
|
||||||
static LAYER_TAB* result;
|
static LAYER_TAB* result;
|
||||||
|
|
||||||
key.id = cid;
|
key.id = cid;
|
||||||
if (result =
|
if ((result =
|
||||||
(LAYER_TAB*)sndBSearch(&key, dataLayerTab, dataLayerNum, sizeof(LAYER_TAB), layercmp)) {
|
(LAYER_TAB*)sndBSearch(&key, dataLayerTab, dataLayerNum, sizeof(LAYER_TAB), layercmp))) {
|
||||||
*n = result->num;
|
*n = result->num;
|
||||||
return result->data;
|
return result->data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue