From c1e79c3ed85b958f1e44bc3366d67b86b6d5d34f Mon Sep 17 00:00:00 2001 From: Paci <89483951+PaciStardust@users.noreply.github.com> Date: Fri, 7 Jun 2024 23:13:48 +0200 Subject: [PATCH] Fixed volume not actually changing --- OscMultitool/Services/Speech/Synthesizing.cs | 6 +++--- OscMultitool/Ui/Pages/PageOutput.xaml | 2 +- OscMultitool/Ui/Pages/PageOutput.xaml.cs | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/OscMultitool/Services/Speech/Synthesizing.cs b/OscMultitool/Services/Speech/Synthesizing.cs index 2127bf2..775b529 100644 --- a/OscMultitool/Services/Speech/Synthesizing.cs +++ b/OscMultitool/Services/Speech/Synthesizing.cs @@ -103,13 +103,13 @@ internal static void ChangeVolume() try { var configVolume = Config.Speech.SpeakerVolumeInt / 100f; - var roundedWaveOutVolume = Math.Ceiling(_waveOut.Volume * 20) / 20f; + var roundedWaveOut = Math.Round(_waveOut.Volume*100, 2) / 100; //Floating points messed with this so its strings now - if (configVolume + string.Empty == roundedWaveOutVolume + string.Empty) + if (configVolume + string.Empty == roundedWaveOut + string.Empty) return; - _waveOut.Volume = Config.Speech.SpeakerVolumeInt; + _waveOut.Volume = configVolume; Logger.PInfo("Changed synthesizer volume: " + Config.Speech.SpeakerVolumeInt); } catch (Exception ex) diff --git a/OscMultitool/Ui/Pages/PageOutput.xaml b/OscMultitool/Ui/Pages/PageOutput.xaml index c3a2524..5664492 100644 --- a/OscMultitool/Ui/Pages/PageOutput.xaml +++ b/OscMultitool/Ui/Pages/PageOutput.xaml @@ -158,7 +158,7 @@ - + diff --git a/OscMultitool/Ui/Pages/PageOutput.xaml.cs b/OscMultitool/Ui/Pages/PageOutput.xaml.cs index f8dc387..6453978 100644 --- a/OscMultitool/Ui/Pages/PageOutput.xaml.cs +++ b/OscMultitool/Ui/Pages/PageOutput.xaml.cs @@ -136,6 +136,9 @@ private void SynthUseAzure_Checked(object sender, RoutedEventArgs e) private void SynthTextBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) => TryEnableChangeIndicatorSynth(); + + private void VolumeBox_TextChanged(object sender, TextChangedEventArgs e) + => Synthesizing.ChangeVolume(); #endregion } }