mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-02 07:10:13 +08:00
feat: loudnorm (#1358)
* feat: loudnorm * fix * fix: android only * fix: toString
This commit is contained in:
committed by
GitHub
parent
046412b709
commit
22c57bf468
@@ -2,9 +2,24 @@ enum AudioNormalization {
|
||||
disable('禁用'),
|
||||
// ref https://github.com/KRTirtho/spotube/commit/da10ab2e291d4ba4d3082b9a6ae535639fb8f1b7
|
||||
dynaudnorm('预设 dynaudnorm', 'dynaudnorm=g=5:f=250:r=0.9:p=0.5'),
|
||||
loudnorm('预设 loudnorm', 'loudnorm=I=-16:LRA=11:TP=-1.5'),
|
||||
custom('自定义参数');
|
||||
|
||||
final String title;
|
||||
final String param;
|
||||
const AudioNormalization(this.title, [this.param = '']);
|
||||
|
||||
static String getTitleFromConfig(String config) => switch (config) {
|
||||
'0' => disable.title,
|
||||
'1' => dynaudnorm.title,
|
||||
'2' => loudnorm.title,
|
||||
_ => config,
|
||||
};
|
||||
|
||||
static String getParamFromConfig(String config) => switch (config) {
|
||||
'0' => disable.param,
|
||||
'1' => dynaudnorm.param,
|
||||
'2' => loudnorm.param,
|
||||
_ => config,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ class PlayUrlModel {
|
||||
Dash? dash;
|
||||
List<Durl>? durl;
|
||||
List<FormatItem>? supportFormats;
|
||||
Volume? volume;
|
||||
int? lastPlayTime;
|
||||
int? lastPlayCid;
|
||||
String? curLanguage;
|
||||
@@ -62,6 +63,7 @@ class PlayUrlModel {
|
||||
supportFormats = (json['support_formats'] as List?)
|
||||
?.map<FormatItem>((e) => FormatItem.fromJson(e))
|
||||
.toList();
|
||||
volume = json['volume'] == null ? null : Volume.fromJson(json['volume']);
|
||||
lastPlayTime = json['last_play_time'];
|
||||
lastPlayCid = json['last_play_cid'];
|
||||
curLanguage = json['cur_language'];
|
||||
@@ -304,3 +306,48 @@ class FormatItem {
|
||||
codecs = (json['codecs'] as List?)?.fromCast<String>();
|
||||
}
|
||||
}
|
||||
|
||||
class Volume {
|
||||
Volume({
|
||||
required this.measuredI,
|
||||
required this.measuredLra,
|
||||
required this.measuredTp,
|
||||
required this.measuredThreshold,
|
||||
required this.targetOffset,
|
||||
required this.targetI,
|
||||
required this.targetTp,
|
||||
// required this.multiSceneArgs,
|
||||
});
|
||||
|
||||
final num measuredI;
|
||||
final num measuredLra;
|
||||
final num measuredTp;
|
||||
final num measuredThreshold;
|
||||
final num targetOffset;
|
||||
final num targetI;
|
||||
final num targetTp;
|
||||
// final MultiSceneArgs? multiSceneArgs;
|
||||
|
||||
factory Volume.fromJson(Map<String, dynamic> json) {
|
||||
return Volume(
|
||||
measuredI: json["measured_i"] ?? 0,
|
||||
measuredLra: json["measured_lra"] ?? 0,
|
||||
measuredTp: json["measured_tp"] ?? 0,
|
||||
measuredThreshold: json["measured_threshold"] ?? 0,
|
||||
targetOffset: json["target_offset"] ?? 0,
|
||||
targetI: json["target_i"] ?? 0,
|
||||
targetTp: json["target_tp"] ?? 0,
|
||||
// multiSceneArgs: json["multi_scene_args"] == null ? null : MultiSceneArgs.fromJson(json["multi_scene_args"]),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'measured_I=$measuredI:measured_LRA=$measuredLra:measured_TP=$measuredTp:measured_thresh=$measuredThreshold';
|
||||
|
||||
bool get isNotEmpty =>
|
||||
measuredI != 0 ||
|
||||
measuredLra != 0 ||
|
||||
measuredTp != 0 ||
|
||||
measuredThreshold != 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user