mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
feat: configurable audio normalization switch
This commit is contained in:
parent
126d6017f2
commit
c325911c0d
@ -264,5 +264,6 @@
|
|||||||
"use_system_title_bar": "Use system title bar",
|
"use_system_title_bar": "Use system title bar",
|
||||||
"crunching_results": "Crunching results...",
|
"crunching_results": "Crunching results...",
|
||||||
"search_to_get_results": "Search to get results",
|
"search_to_get_results": "Search to get results",
|
||||||
"use_amoled_dark_theme": "Use AMOLED (Pitch Black) dark theme"
|
"use_amoled_dark_theme": "Use AMOLED (Pitch Black) dark theme",
|
||||||
|
"normalize_audio": "Normalize audio"
|
||||||
}
|
}
|
@ -448,6 +448,13 @@ class SettingsPage extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
trailing: const Icon(SpotubeIcons.angleRight),
|
trailing: const Icon(SpotubeIcons.angleRight),
|
||||||
),
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
secondary: const Icon(SpotubeIcons.playlistRemove),
|
||||||
|
title: Text(context.l10n.normalize_audio),
|
||||||
|
subtitle: Text(context.l10n.blacklist_description),
|
||||||
|
value: preferences.normalizeAudio,
|
||||||
|
onChanged: preferences.setNormalizeAudio,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SectionCardWithHeading(
|
SectionCardWithHeading(
|
||||||
|
@ -10,6 +10,7 @@ import 'package:spotube/components/settings/color_scheme_picker_dialog.dart';
|
|||||||
import 'package:spotube/models/matched_track.dart';
|
import 'package:spotube/models/matched_track.dart';
|
||||||
import 'package:spotube/provider/palette_provider.dart';
|
import 'package:spotube/provider/palette_provider.dart';
|
||||||
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
|
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
|
||||||
|
import 'package:spotube/services/audio_player/audio_player.dart';
|
||||||
|
|
||||||
import 'package:spotube/utils/persisted_change_notifier.dart';
|
import 'package:spotube/utils/persisted_change_notifier.dart';
|
||||||
import 'package:spotube/utils/platform.dart';
|
import 'package:spotube/utils/platform.dart';
|
||||||
@ -70,6 +71,8 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
|
|
||||||
bool amoledDarkTheme;
|
bool amoledDarkTheme;
|
||||||
|
|
||||||
|
bool normalizeAudio;
|
||||||
|
|
||||||
final Ref ref;
|
final Ref ref;
|
||||||
|
|
||||||
UserPreferences(
|
UserPreferences(
|
||||||
@ -92,6 +95,7 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
this.youtubeApiType = YoutubeApiType.youtube,
|
this.youtubeApiType = YoutubeApiType.youtube,
|
||||||
this.systemTitleBar = false,
|
this.systemTitleBar = false,
|
||||||
this.amoledDarkTheme = false,
|
this.amoledDarkTheme = false,
|
||||||
|
this.normalizeAudio = true,
|
||||||
}) : super() {
|
}) : super() {
|
||||||
if (downloadLocation.isEmpty && !kIsWeb) {
|
if (downloadLocation.isEmpty && !kIsWeb) {
|
||||||
_getDefaultDownloadDirectory().then(
|
_getDefaultDownloadDirectory().then(
|
||||||
@ -219,6 +223,13 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
updatePersistence();
|
updatePersistence();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setNormalizeAudio(bool normalize) {
|
||||||
|
normalizeAudio = normalize;
|
||||||
|
audioPlayer.setAudioNormalization(normalize);
|
||||||
|
notifyListeners();
|
||||||
|
updatePersistence();
|
||||||
|
}
|
||||||
|
|
||||||
Future<String> _getDefaultDownloadDirectory() async {
|
Future<String> _getDefaultDownloadDirectory() async {
|
||||||
if (kIsAndroid) return "/storage/emulated/0/Download/Spotube";
|
if (kIsAndroid) return "/storage/emulated/0/Download/Spotube";
|
||||||
|
|
||||||
@ -285,6 +296,9 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
setSystemTitleBar(systemTitleBar);
|
setSystemTitleBar(systemTitleBar);
|
||||||
|
|
||||||
amoledDarkTheme = map["amoledDarkTheme"] ?? amoledDarkTheme;
|
amoledDarkTheme = map["amoledDarkTheme"] ?? amoledDarkTheme;
|
||||||
|
|
||||||
|
normalizeAudio = map["normalizeAudio"] ?? normalizeAudio;
|
||||||
|
audioPlayer.setAudioNormalization(normalizeAudio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -309,6 +323,7 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
"youtubeApiType": youtubeApiType.name,
|
"youtubeApiType": youtubeApiType.name,
|
||||||
'systemTitleBar': systemTitleBar,
|
'systemTitleBar': systemTitleBar,
|
||||||
"amoledDarkTheme": amoledDarkTheme,
|
"amoledDarkTheme": amoledDarkTheme,
|
||||||
|
"normalizeAudio": normalizeAudio,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,6 @@ abstract class AudioPlayerInterface {
|
|||||||
)
|
)
|
||||||
// _justAudio = !_mkSupportedPlatform ? ja.AudioPlayer() : null
|
// _justAudio = !_mkSupportedPlatform ? ja.AudioPlayer() : null
|
||||||
{
|
{
|
||||||
//? Normalizing the audio
|
|
||||||
(_mkPlayer.platform as mk.NativePlayer)
|
|
||||||
.setProperty('af', 'dynaudnorm=g=5:f=250:r=0.9:p=0.5');
|
|
||||||
|
|
||||||
_mkPlayer.stream.error.listen((event) {
|
_mkPlayer.stream.error.listen((event) {
|
||||||
Catcher.reportCheckedError(event, StackTrace.current);
|
Catcher.reportCheckedError(event, StackTrace.current);
|
||||||
});
|
});
|
||||||
|
@ -312,4 +312,8 @@ class SpotubeAudioPlayer extends AudioPlayerInterface
|
|||||||
// await _justAudio!.setLoopMode(loop.toLoopMode());
|
// await _justAudio!.setLoopMode(loop.toLoopMode());
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> setAudioNormalization(bool normalize) async {
|
||||||
|
await _mkPlayer.setAudioNormalization(normalize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,4 +318,14 @@ class MkPlayerWithState extends Player {
|
|||||||
index: newMedias.indexOf(_playlist!.medias[_playlist!.index]),
|
index: newMedias.indexOf(_playlist!.medias[_playlist!.index]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NativePlayer get nativePlayer => platform as NativePlayer;
|
||||||
|
|
||||||
|
Future<void> setAudioNormalization(bool normalize) async {
|
||||||
|
if (normalize) {
|
||||||
|
await nativePlayer.setProperty('af', 'dynaudnorm=g=5:f=250:r=0.9:p=0.5');
|
||||||
|
} else {
|
||||||
|
await nativePlayer.setProperty('af', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,56 @@
|
|||||||
{
|
{
|
||||||
"bn": [
|
"bn": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"ca": [
|
"ca": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"de": [
|
"de": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"es": [
|
"es": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"fr": [
|
"fr": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"hi": [
|
"hi": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"ja": [
|
"ja": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"pl": [
|
"pl": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"pt": [
|
"pt": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"ru": [
|
"ru": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
],
|
],
|
||||||
|
|
||||||
"zh": [
|
"zh": [
|
||||||
"use_amoled_dark_theme"
|
"use_amoled_dark_theme",
|
||||||
|
"normalize_audio"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user