diff --git a/soh/soh/Enhancements/accessible-actors/SfxExtractor.cpp b/soh/soh/Enhancements/accessible-actors/SfxExtractor.cpp index 95cfc1cb8..ab57e1003 100644 --- a/soh/soh/Enhancements/accessible-actors/SfxExtractor.cpp +++ b/soh/soh/Enhancements/accessible-actors/SfxExtractor.cpp @@ -15,20 +15,20 @@ extern bool freezeGame; bool SfxExtractor::isAllSilence(int16_t* buffer, size_t count) { for (size_t i = 0; i < count; i++) { - if (!isSilentSample(buffer[i]))//Tolerance for low-amplitude dither noise. + if (!isSilentSample(buffer[i])) // Tolerance for low-amplitude dither noise. return false; } return true; } bool SfxExtractor::isSilentSample(int16_t sample) { return abs(sample) <= SFX_EXTRACTION_SILENCE_THRESHOLD; - } // Find the beginning of a captured signal. size_t SfxExtractor::adjustedStartOfInput() { size_t startOfInput = 0; - while (startOfInput + 2 < SFX_EXTRACTION_BUFFER_SIZE * 2 && isSilentSample(tempBuffer[startOfInput]) && isSilentSample(tempBuffer[startOfInput + 1])) { + while (startOfInput + 2 < SFX_EXTRACTION_BUFFER_SIZE * 2 && isSilentSample(tempBuffer[startOfInput]) && + isSilentSample(tempBuffer[startOfInput + 1])) { startOfInput += 2; } return startOfInput; @@ -93,11 +93,11 @@ void SfxExtractor::setup() { } void SfxExtractor::ripNextSfx() { - //This entire method is expected to be atomic; Don't try to narrow the scope of this lock please! - //Todo: remove the thread altogether as we don't actually need or want parallelism here. -auto lock = OTRAudio_Lock(); - if (captureThreadState == CT_READY || captureThreadState == CT_PRIMING) - return; // Keep going. + // This entire method is expected to be atomic; Don't try to narrow the scope of this lock please! + // Todo: remove the thread altogether as we don't actually need or want parallelism here. + auto lock = OTRAudio_Lock(); + if (captureThreadState == CT_READY || captureThreadState == CT_PRIMING) + return; // Keep going. // Was the last sfx a loop? If so then we need to stop it, and then we need to run audio out to nowhere for as long // as it takes to get back to a blank slate. if (currentSfx != -1) { @@ -115,7 +115,7 @@ auto lock = OTRAudio_Lock(); currentSfx = sfxTable[sfxToRip++]; Audio_PlaySoundGeneral(currentSfx, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - captureThreadState = CT_READY; + captureThreadState = CT_READY; maybeGiveProgressReport(); } void SfxExtractor::finished() { @@ -168,10 +168,11 @@ void SfxExtractor::frameCallback() { } void SfxExtractor::prime() { - int frameLimit = 0;//A couple of sounds don't come to a full stop until another sound is loaded, but should be effectively silent after a couple of seconds. + int frameLimit = 0; // A couple of sounds don't come to a full stop until another sound is loaded, but should be + // effectively silent after a couple of seconds. do { AudioMgr_CreateNextAudioBuffer(tempBuffer + 0, SFX_EXTRACTION_ONE_FRAME); - } while (frameLimit ++ < 200 && !isAllSilence(tempBuffer + 0, SFX_EXTRACTION_ONE_FRAME * 2)); + } while (frameLimit++ < 200 && !isAllSilence(tempBuffer + 0, SFX_EXTRACTION_ONE_FRAME * 2)); captureThreadState = CT_FINISHED; } diff --git a/soh/soh/Enhancements/accessible-actors/SfxExtractor.h b/soh/soh/Enhancements/accessible-actors/SfxExtractor.h index 6fad365ef..daa3cb78d 100644 --- a/soh/soh/Enhancements/accessible-actors/SfxExtractor.h +++ b/soh/soh/Enhancements/accessible-actors/SfxExtractor.h @@ -3,8 +3,7 @@ #define SFX_EXTRACTION_BUFFER_SIZE 32000 * 15 #define SFX_EXTRACTION_ONE_FRAME 560 -#define SFX_EXTRACTION_SILENCE_THRESHOLD 6//Corresponds to an amplitude of -75dB. - +#define SFX_EXTRACTION_SILENCE_THRESHOLD 6 // Corresponds to an amplitude of -75dB. enum CaptureThreadStates { CT_WAITING, // for a sound to start ripping. diff --git a/soh/soh/Enhancements/accessible-actors/SfxTable.h b/soh/soh/Enhancements/accessible-actors/SfxTable.h index a9678d277..8f32b861b 100644 --- a/soh/soh/Enhancements/accessible-actors/SfxTable.h +++ b/soh/soh/Enhancements/accessible-actors/SfxTable.h @@ -1092,7 +1092,7 @@ const s16 sfxTable[] = { NA_SE_OC_SECRET_WARP_OUT, NA_SE_OC_SECRET_HOLE_OUT, NA_SE_OC_REVENGE, - NA_SE_OC_HINT_MOVIE, + NA_SE_OC_HINT_MOVIE, NA_SE_OC_HINT_MOVIE2_WHITE, NA_SE_OC_HINT_MOVIE_ZOOMIN, NA_SE_OC_HIBIKI_ISHI, diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 1c4201140..bf5d5e58b 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -2631,13 +2631,13 @@ void OTRAudio_SfxCaptureThread() { // This entire body is expected to be atomic; Don't try to narrow the scope of this lock please! // Todo: remove the thread altogether as we don't actually need or want parallelism here. std::unique_lock Lock(audio.mutex); - while (!audio.processing && audio.running) { - audio.cv_to_thread.wait(Lock); - } + while (!audio.processing && audio.running) { + audio.cv_to_thread.wait(Lock); + } - if (!audio.running) { - break; - } + if (!audio.running) { + break; + } #if !defined(__SWITCH__) && !defined(__WIIU__) ActorAccessibility_DoSoundExtractionStep(); #endif