diff options
author | kleines Filmröllchen <filmroellchen@serenityos.org> | 2022-03-03 11:28:28 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-14 22:46:46 +0100 |
commit | 1088c2c71641e765d9eba9d18918b17718336d78 (patch) | |
tree | 024a3cb0a1b894aebe0246ff7db964ea8c9e7316 /Userland | |
parent | d2510d0caa64d4deebdc1823189ce4dbf92b0c40 (diff) | |
download | serenity-1088c2c71641e765d9eba9d18918b17718336d78.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/Piano/Music.h | 2 | ||||
-rw-r--r-- | 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<i16>::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; |