TextToTalk icon indicating copy to clipboard operation
TextToTalk copied to clipboard

Scale TTS volume with in-game volume

Open Rukishou opened this issue 2 years ago • 3 comments

Would be nice to have an option that scales the spoken volume to your in-game master or voice volume

Rukishou avatar Oct 09 '23 11:10 Rukishou

I just had this idea as well when I decided to install the StanleyParableXiv plugin and saw that it had the configuration option to tie the narrator volume to the game volume.

I'll link it here as inspiration in case Karashiiro or maybe I feel like tackling this feature in the future.

https://github.com/rekyuu/StanleyParableXiv/blob/e14e7cd19e966a9f594abdb4d1ce2557eb2b4de2/StanleyParableXiv/Configuration.cs#L24

ryankhart avatar Jul 15 '24 23:07 ryankhart

Volume can easily be read by this:

public static unsafe float GetVoiceVolume(IGameConfig gameConfig)
{
    var voiceVolume = .5f;
    var masterVolume = .5f;
    var instance = Framework.Instance();
    if (instance != null && instance->SoundManager != null)
    {
        var soundManager = instance->SoundManager;
        masterVolume = soundManager->MasterVolume;
        voiceVolume = soundManager->GetEffectiveVolume(SoundManager.SoundChannel.Voice);
        var isMasterMuted = false;
        var isVoiceMuted = false;
        gameConfig.System.TryGetBool("IsSndMaster", out isMasterMuted);
        gameConfig.System.TryGetBool("IsSndVoice", out isVoiceMuted);

        if (isMasterMuted || isVoiceMuted)
            return 0f;
    }

    var volumeFloat = masterVolume * voiceVolume;
    return volumeFloat;
}

RenNagasaki avatar Jul 23 '24 09:07 RenNagasaki

Thank you! I may try that sometime and see how it goes, but I'll want to run it by Karashiiro before I merge anything into the main branch.

ryankhart avatar Jul 25 '24 06:07 ryankhart