From e6f514ab34f3c0daed72f78eeb58485fedd76f0f Mon Sep 17 00:00:00 2001 From: Julian Xhokaxhiu Date: Tue, 21 May 2024 22:56:43 +0200 Subject: [PATCH] FF8: Add missing support for audio effects to be stopped in time --- Changelog.md | 1 + src/sfx.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 0e511620..74b4c658 100644 --- a/Changelog.md +++ b/Changelog.md @@ -19,6 +19,7 @@ - Rendering: Avoid texture reupload in case of palette swap ( https://github.com/julianxhokaxhiu/FFNx/pull/687 ) - Rendering: Fix texture unload when multiple palettes are written ( https://github.com/julianxhokaxhiu/FFNx/pull/687 ) - Rendering: Prevent the game from sending textures with half-alpha colors ( https://github.com/julianxhokaxhiu/FFNx/pull/687 ) +- SFX: Add missing support for audio effects to be stopped in time # 1.19.1 diff --git a/src/sfx.cpp b/src/sfx.cpp index 0f5a6c31..6f7bcfa4 100644 --- a/src/sfx.cpp +++ b/src/sfx.cpp @@ -54,13 +54,13 @@ void ff7_sfx_stop_channel(int channel, double time = 0) sfx_state[channel-1].is_looped = false; } -void ff8_sfx_stop_channel(int channel) +void ff8_sfx_stop_channel(int channel, double time = 0) { if (trace_all || trace_sfx) ffnx_trace("%s: channel=%d\n", __func__, channel); if (channel <= FF8_MAX_CHANNEL_NUMBER) { - nxAudioEngine.stopSFX(channel); + nxAudioEngine.stopSFX(channel, time); } } @@ -115,10 +115,10 @@ void ff8_sfx_set_volume(uint32_t channel, uint32_t volume, int32_t time) { if (trace_all || trace_sfx) ffnx_trace("%s: channel=%d, volume=%d, time=%d\n", __func__, channel, volume, time); - if (channel <= FF8_MAX_CHANNEL_NUMBER && volume <= 127) - { + if (volume == 0) + ff8_sfx_stop_channel(channel, time / 60.0f); + else if (channel <= FF8_MAX_CHANNEL_NUMBER && volume <= 127) nxAudioEngine.setSFXVolume(channel, volume / 127.0f, time / 60.0f); - } } void ff7_sfx_set_volume_trans_on_channel(byte volume, int channel, int time)