From 8b27462b114fd8636ca1591b8d9513838c060a83 Mon Sep 17 00:00:00 2001 From: MSOB7YY Date: Thu, 21 Dec 2023 04:37:51 +0200 Subject: [PATCH] fix: gigantic artwork scale & waveform bars when bitrate is high --- lib/controller/waveform_controller.dart | 19 ++++++++++++++----- pubspec.yaml | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/controller/waveform_controller.dart b/lib/controller/waveform_controller.dart index 4191227f..03831895 100644 --- a/lib/controller/waveform_controller.dart +++ b/lib/controller/waveform_controller.dart @@ -64,21 +64,30 @@ class WaveformController { } static List _calculateUIWaveformIsolate(({List original, int targetSize}) params) { - final clamping = params.original.isEmpty ? null : 64.0; + const maxClamping = 64.0; + final clamping = params.original.isEmpty ? null : maxClamping; final downscaled = params.original.changeListSize( targetSize: params.targetSize, multiplier: 0.9, clampToMax: clamping, - enforceClampToMax: false, + enforceClampToMax: (minValue, maxValue) => false, ); return downscaled; } static Map> _downscaledWaveformLists(({List original, List targetSizes}) params) { final newLists = >{}; + const maxClamping = 64.0; params.targetSizes.loop((targetSize, index) { - final isLast = index == params.targetSizes.length - 1; - newLists[targetSize] = params.original.changeListSize(targetSize: targetSize, multiplier: isLast ? 0.003 : 1.0); + newLists[targetSize] = params.original.changeListSize( + targetSize: targetSize, + clampToMax: maxClamping, + enforceClampToMax: (minValue, maxValue) { + // -- checking if max value is greater than `maxClamping`; + // -- since clamping tries to normalize among all lists variations + return maxValue > maxClamping; + }, + ); }); return newLists; } @@ -91,7 +100,7 @@ class WaveformController { final posInMap = positionInMs ~/ 50; final dynamicScale = _currentScaleMap[posInMap] ?? 0.01; final intensity = settings.animatingThumbnailIntensity.value; - final finalScale = dynamicScale * intensity * 0.02; + final finalScale = dynamicScale * intensity * 0.00005; return finalScale.isNaN ? 0.01 : finalScale; } diff --git a/pubspec.yaml b/pubspec.yaml index d32f600c..be0d4a02 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ dependency_overrides: dart_extensions: git: url: https://github.com/MSOB7YY/dart_extensions - ref: 44c9ce41605203fd0da088d3968e258c4fe3e5ea + ref: 1de0a3d597a20f9464fa36740a76e8c534d2200f archive: ^3.3.8 intl: ^0.18.0