Skip to content

Commit

Permalink
fix: gigantic artwork scale & waveform bars when bitrate is high
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Dec 21, 2023
1 parent d7797cc commit 8b27462
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions lib/controller/waveform_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,30 @@ class WaveformController {
}

static List<double> _calculateUIWaveformIsolate(({List<double> 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<int, List<double>> _downscaledWaveformLists(({List<int> original, List<int> targetSizes}) params) {
final newLists = <int, List<double>>{};
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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8b27462

Please sign in to comment.