mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-30 01:01:21 +00:00
ngs2: patch to a rack handle connects to its voice 0
Co-authored-by: Phr3d13 <phr3d13@gmail.com>
This commit is contained in:
1 parent
3ad21e35cc
commit
67f8276751
2 files changed
+28
-1
No files matched your search
+12
-1
@@ -2339,6 +2339,17 @@ int KYTY_SYSV_ABI Ngs2RackGetVoiceHandle(uintptr_t rack_handle, uint32_t voice_i
|
||||
return OK;
|
||||
}
|
||||
|
||||
// A patch to a rack handle connects to voice #0 of that rack.
|
||||
static Ngs2VoiceInternal* Ngs2FindPatchDestination(uintptr_t handle) {
|
||||
Common::LockGuard racks_lock(g_racks_mutex);
|
||||
for (auto* rack = g_racks_list; rack != nullptr; rack = rack->next) {
|
||||
if (reinterpret_cast<uintptr_t>(rack) == handle) {
|
||||
return reinterpret_cast<Ngs2VoiceInternal*>(rack + 1);
|
||||
}
|
||||
}
|
||||
return reinterpret_cast<Ngs2VoiceInternal*>(handle);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||
int KYTY_SYSV_ABI Ngs2VoiceControl(uintptr_t voice_handle, const Ngs2VoiceParamHeader* param_list) {
|
||||
PRINT_NAME();
|
||||
@@ -2408,7 +2419,7 @@ int KYTY_SYSV_ABI Ngs2VoiceControl(uintptr_t voice_handle, const Ngs2VoiceParamH
|
||||
const auto* patch = reinterpret_cast<const Ngs2VoicePatchParam*>(param);
|
||||
EXIT_NOT_IMPLEMENTED(patch->port >= voice->ports.size());
|
||||
voice->ports[patch->port].dest =
|
||||
reinterpret_cast<Ngs2VoiceInternal*>(patch->dest_handle);
|
||||
Ngs2FindPatchDestination(patch->dest_handle);
|
||||
voice->ports[patch->port].input = patch->dest_input_id;
|
||||
LOGF("\t connect->port = %u\n"
|
||||
"\t connect->dest_input_id = %u\n"
|
||||
|
||||
@@ -807,6 +807,21 @@ void TestPcm16RenderOutput() {
|
||||
"PCM16 output retained samples from the previous render");
|
||||
}
|
||||
|
||||
void TestPatchToRackHandle() {
|
||||
Ngs2Internal system;
|
||||
Ngs2RackOptionUnion sampler_option {}, mastering_option {};
|
||||
Ngs2FillDefaultRackOption(0x1000, &sampler_option);
|
||||
Ngs2FillDefaultRackOption(0x3000, &mastering_option);
|
||||
sampler_option.common.max_voices = 1;
|
||||
RenderRack sampler(system, 0x1000, sampler_option.common);
|
||||
RenderRack master(system, 0x3000, mastering_option.common);
|
||||
auto& source = sampler.Voice();
|
||||
Ngs2VoicePatchParam patch {{24, 0, 5}, 0, 0, master.handle};
|
||||
Check(Ngs2VoiceControl(reinterpret_cast<uintptr_t>(&source), &patch.header) == OK &&
|
||||
source.ports[0].dest == &master.Voice(),
|
||||
"patch to a rack handle did not connect to its voice #0");
|
||||
}
|
||||
|
||||
void TestCustomMasteringChannelMixer() {
|
||||
Ngs2Internal system;
|
||||
system.option = Ngs2DefaultSystemOption();
|
||||
@@ -1803,6 +1818,7 @@ int main() {
|
||||
TestAtrac9Vibration();
|
||||
TestAtrac9Discrete();
|
||||
TestPcm16RenderOutput();
|
||||
TestPatchToRackHandle();
|
||||
TestCustomMasteringChannelMixer();
|
||||
TestCustomVoiceStateCapacity();
|
||||
TestSubmixerSetupAndRouting();
|
||||
|
||||
Reference in new issue
Block a user