From 1088c2c71641e765d9eba9d18918b17718336d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Thu, 3 Mar 2022 11:28:28 +0100 Subject: [PATCH] Piano: Decrease sample headroom Multiplying all samples by 0.1 was kind of silly. This also requires adjusting the wave visualizer so that the waves still fit. --- Userland/Applications/Piano/Music.h | 2 +- Userland/Applications/Piano/WaveWidget.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Applications/Piano/Music.h b/Userland/Applications/Piano/Music.h index c4b662db8b..5af0825baa 100644 --- a/Userland/Applications/Piano/Music.h +++ b/Userland/Applications/Piano/Music.h @@ -31,7 +31,7 @@ constexpr int buffer_size = sample_count * sizeof(Sample); constexpr double sample_rate = 44100; // Headroom for the synth -constexpr double volume_factor = 0.1; +constexpr double volume_factor = 0.8; enum Switch { Off, diff --git a/Userland/Applications/Piano/WaveWidget.cpp b/Userland/Applications/Piano/WaveWidget.cpp index e0c71163bc..25f1df548f 100644 --- a/Userland/Applications/Piano/WaveWidget.cpp +++ b/Userland/Applications/Piano/WaveWidget.cpp @@ -18,10 +18,10 @@ WaveWidget::WaveWidget(TrackManager& track_manager) int WaveWidget::sample_to_y(int sample) const { - constexpr int nice_scale_factor = 4; - sample *= nice_scale_factor; + // Sample scaling that looks good, experimentally determined. + constexpr double nice_scale_factor = 1.0; constexpr double sample_max = NumericLimits::max(); - double percentage = sample / sample_max; + double percentage = sample / sample_max * nice_scale_factor; double portion_of_half_height = percentage * ((frame_inner_rect().height() - 1) / 2.0); double y = (frame_inner_rect().height() / 2.0) + portion_of_half_height; return y;