Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display the used volume normalization mode/values instead of target #651

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions src/components/QualityDetailsBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</div>

<div
v-if="streamDetails.target_loudness"
v-if="loudness"
style="height: 50px; display: flex; align-items: center"
>
<img
Expand All @@ -73,7 +73,7 @@
: 'object-fit: contain;filter: invert(100%);'
"
/>
{{ streamDetails.target_loudness }} dB
{{ loudness }}
</div>
</v-list>
</v-card>
Expand All @@ -85,12 +85,44 @@ import { computed } from 'vue';
import ProviderIcon from '@/components/ProviderIcon.vue';
import api from '@/plugins/api';
import { store } from '@/plugins/store';
import { ContentType } from '@/plugins/api/interfaces';
import { ContentType, VolumeNormalizationMode } from '@/plugins/api/interfaces';
import { $t } from '@/plugins/i18n';

// computed properties
const streamDetails = computed(() => {
return store.activePlayerQueue?.current_item?.streamdetails;
});
const loudness = computed(() => {
let sd = streamDetails.value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let sd = streamDetails.value;
const sd = streamDetails.value;

if (!sd) return null;

if (
(sd.volume_normalization_mode == VolumeNormalizationMode.MEASUREMENT_ONLY ||
sd.volume_normalization_mode ==
VolumeNormalizationMode.FALLBACK_FIXED_GAIN ||
sd.volume_normalization_mode ==
VolumeNormalizationMode.FALLBACK_DYNAMIC) &&
sd.loudness !== null
) {
if (sd.prefer_album_loudness && sd.loudness_album !== null) {
return $t('loudness_measurement_album', [sd.loudness_album?.toFixed(2)]);
} else {
return $t('loudness_measurement', [sd.loudness?.toFixed(2)]);
}
} else if (
sd.volume_normalization_mode == VolumeNormalizationMode.DYNAMIC ||
sd.volume_normalization_mode == VolumeNormalizationMode.FALLBACK_DYNAMIC
) {
return $t('loudness_dynamic');
} else if (
sd.volume_normalization_mode == VolumeNormalizationMode.FIXED_GAIN ||
sd.volume_normalization_mode == VolumeNormalizationMode.FALLBACK_FIXED_GAIN
) {
return $t('loudness_fixed');
} else {
return null;
}
});
const getContentTypeIcon = function (contentType: ContentType) {
if (contentType == ContentType.AAC) return iconAac;
if (contentType == ContentType.FLAC) return iconFlac;
Expand Down
24 changes: 14 additions & 10 deletions src/plugins/api/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ export enum ConfigEntryType {
ALERT = 'alert',
}

export enum VolumeNormalizationMode {
DISABLED = 'disabled',
DYNAMIC = 'dynamic', // Force dynamic
MEASUREMENT_ONLY = 'measurement_only', // Measurement only (no fallback)
FALLBACK_FIXED_GAIN = 'fallback_fixed_gain', // Fallback to gain correction
FIXED_GAIN = 'fixed_gain', // Fixed gain correction
FALLBACK_DYNAMIC = 'fallback_dynamic', // Fallback to dynamic
}

//// api

export interface CommandMessage {
Expand Down Expand Up @@ -479,25 +488,20 @@ export interface AudioFormat {
bit_rate: number;
}

export interface LoudnessMeasurement {
integrated: number;
true_peak: number;
lra: number;
threshold: number;
target_offset: number;
}

export interface StreamDetails {
provider: string;
item_id: string;
audio_format: AudioFormat;
media_type: MediaType;
stream_title?: string;
duration?: number;
loudness?: number;
loudness_album?: number;
prefer_album_loudness?: boolean;
volume_normalization_mode?: VolumeNormalizationMode;
target_loudness?: number;

queue_id?: string;
loudness?: LoudnessMeasurement;
target_loudness?: number;
}

// queue_item
Expand Down
6 changes: 5 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,5 +525,9 @@
"image_make_primary": "Make primary",
"update_metadata": "Update metadata",
"cancel": "Cancel",
"transfer_queue": "Transfer queue to another player"
"transfer_queue": "Transfer queue to another player",
"loudness_measurement": "{0} LUFS",
"loudness_measurement_album": "{0} LUFS (album)",
"loudness_dynamic": "Dynamic volume normalization",
"loudness_fixed": "Fixed gain correction"
}
Loading