feat(audio): add custom sound volume slider
This commit is contained in:
@@ -9,8 +9,9 @@ namespace HellionChat.Integrations;
|
||||
// WaveOutEvent/WinMM is the correct backend for FFXIV on Wine: it works
|
||||
// without Media Foundation (which Wine does not support for MP3/AAC).
|
||||
//
|
||||
// Volume is fixed at 0.8. No per-user slider in this iteration so we can
|
||||
// ship quickly and gather feedback before adding UX complexity.
|
||||
// Playback volume comes from Configuration.CustomSoundVolume via the Play
|
||||
// parameter, clamped to [0,1]. The 16 game sounds are unaffected — they go
|
||||
// through UIGlobals.PlaySoundEffect, which the plugin cannot scale.
|
||||
internal sealed class CustomAudioPlayer : IDisposable
|
||||
{
|
||||
// Sound bytes are read once at construction so each Play() wraps a fresh
|
||||
@@ -55,7 +56,7 @@ internal sealed class CustomAudioPlayer : IDisposable
|
||||
// customIndex is 1, 2, or 3, matching the sound file suffix.
|
||||
// Stops any currently playing sound before starting the new one.
|
||||
// NAudio playback runs on its own thread; this method returns immediately.
|
||||
public void Play(int customIndex)
|
||||
public void Play(int customIndex, float volume)
|
||||
{
|
||||
if (customIndex < 1 || customIndex > 3)
|
||||
{
|
||||
@@ -90,7 +91,10 @@ internal sealed class CustomAudioPlayer : IDisposable
|
||||
// must be set after Init, otherwise waveOutSetVolume fails with
|
||||
// InvalidHandle.
|
||||
_outputDevice.Init(_reader);
|
||||
_outputDevice.Volume = 0.8f;
|
||||
// AUDIO-1: volume comes from Configuration.CustomSoundVolume.
|
||||
// Clamp here too — a hand-edited config could carry an
|
||||
// out-of-range value, and WaveOutEvent.Volume rejects those.
|
||||
_outputDevice.Volume = Math.Clamp(volume, 0f, 1f);
|
||||
_outputDevice.Play();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user