Skip to content

Commit

Permalink
Make AutoCue and ReplayGain mutually exclusive; add "High CPU" warnin…
Browse files Browse the repository at this point in the history
…g to some form items.
  • Loading branch information
BusterNeece committed Jun 5, 2024
1 parent 4cc26c5 commit 152b0b9
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 56 deletions.
64 changes: 32 additions & 32 deletions frontend/src/components/Admin/Stations/Form/BackendForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@
>{{ $gettext('Learn More about Post-processing CPU Impact') }}</a>
</template>

<div class="row g-3 mb-3">
<form-group-checkbox
id="edit_form_backend_config_enable_auto_cue"
class="col-md-12"
:field="v$.backend_config.enable_auto_cue"
:label="$gettext('Enable AutoCue (Beta)')"
:description="$gettext('AutoCue analyzes your music and automatically calculates cue points, fade points, and volume levels for a consistent listening experience.')"
high-cpu
/>

<form-group-checkbox
v-if="!isAutoCueEnabled"
id="edit_form_backend_enable_replaygain_metadata"
class="col-md-12"
:field="v$.backend_config.enable_replaygain_metadata"
:label="$gettext('Enable ReplayGain')"
high-cpu
>
<template #description>
{{
$gettext('Calculate and use normalized volume level metadata for each track.')
}}
</template>
</form-group-checkbox>
</div>

<div class="row g-3 mb-3">
<form-group-multi-check
id="edit_form_backend_config_audio_processing_method"
Expand All @@ -66,6 +92,7 @@
radio
:label="$gettext('Audio Post-processing Method')"
:description="$gettext('Select an option here to apply post-processing using an easy preset or tool. You can also manually apply post-processing by editing your Liquidsoap configuration manually.')"
high-cpu
/>

<template v-if="isPostProcessingEnabled">
Expand Down Expand Up @@ -169,16 +196,6 @@
</form-markup>
</div>
</template>

<div class="row g-3 mb-3">
<form-group-checkbox
id="edit_form_backend_config_enable_auto_cue"
class="col-md-12"
:field="v$.backend_config.enable_auto_cue"
:label="$gettext('Enable AutoCue Automatic Detection')"
:description="$gettext('AutoCue analyzes your music and automatically calculates cue points, fade points, and volume levels for a consistent listening experience.')"
/>
</div>
</form-fieldset>

<form-fieldset v-if="enableAdvancedFeatures">
Expand All @@ -192,7 +209,7 @@
<div class="row g-3">
<form-group-checkbox
id="edit_form_backend_use_manual_autodj"
class="col-md-6"
class="col-md-12"
:field="v$.backend_config.use_manual_autodj"
:label="$gettext('Manual AutoDJ Mode')"
>
Expand All @@ -203,23 +220,6 @@
</template>
</form-group-checkbox>

<form-group-checkbox
id="edit_form_backend_enable_replaygain_metadata"
class="col-md-6"
:field="v$.backend_config.enable_replaygain_metadata"
:label="$gettext('Use Replaygain Metadata')"
>
<template #description>
{{
$gettext('Instruct Liquidsoap to use any replaygain metadata associated with a song to control its volume level. This may increase CPU consumption.')
}}
<a
href="/docs/help/optimizing/#disable-replaygain-or-pre-calculate-replaygain-for-audio-files"
target="_blank"
>{{ $gettext('Learn More about Replaygain') }}</a>
</template>
</form-group-checkbox>

<form-group-field
id="edit_form_backend_telnet_port"
class="col-md-6"
Expand Down Expand Up @@ -326,7 +326,8 @@ const {v$, tabClass} = useVuelidateOnFormTab(
master_me_preset: {},
master_me_loudness_target: {},
stereo_tool_license_key: {},
enable_auto_cue: {}
enable_auto_cue: {},
enable_replaygain_metadata: {}
},
};
Expand All @@ -336,7 +337,6 @@ const {v$, tabClass} = useVuelidateOnFormTab(
backend_config: {
...validations.backend_config,
telnet_port: {numeric},
enable_replaygain_metadata: {},
autodj_queue_length: {},
use_manual_autodj: {},
charset: {},
Expand All @@ -362,7 +362,8 @@ const {v$, tabClass} = useVuelidateOnFormTab(
master_me_preset: MasterMePreset.MusicGeneral,
master_me_loudness_target: -16,
stereo_tool_license_key: '',
enable_auto_cue: false
enable_auto_cue: false,
enable_replaygain_metadata: false
},
};
Expand All @@ -372,7 +373,6 @@ const {v$, tabClass} = useVuelidateOnFormTab(
backend_config: {
...blankForm.backend_config,
telnet_port: '',
enable_replaygain_metadata: false,
autodj_queue_length: 3,
use_manual_autodj: false,
charset: 'UTF-8',
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/Form/FormGroupCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
>
<form-label
:is-required="isRequired"
:advanced="advanced"
v-bind="pickProps(props, formLabelProps)"
>
<slot name="label">{{ label }}</slot>
</form-label>
Expand Down Expand Up @@ -57,9 +57,12 @@ import FormGroup from "~/components/Form/FormGroup.vue";
import {formFieldProps, useFormField} from "~/components/Form/useFormField";
import {useSlots} from "vue";
import FormCheckbox from "~/components/Form/FormCheckbox.vue";
import formLabelProps from "~/components/Form/formLabelProps.ts";
import {pickProps} from "~/functions/pickProps.ts";
const props = defineProps({
...formFieldProps,
...formLabelProps,
id: {
type: String,
required: true
Expand All @@ -82,10 +85,6 @@ const props = defineProps({
return {};
}
},
advanced: {
type: Boolean,
default: false
}
});
const slots = useSlots();
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/Form/FormGroupField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
>
<form-label
:is-required="isRequired"
:advanced="advanced"
v-bind="pickProps(props, formLabelProps)"
>
<slot
name="label"
Expand Down Expand Up @@ -89,9 +89,12 @@ import {computed, nextTick, onMounted, ref, useSlots} from "vue";
import FormGroup from "~/components/Form/FormGroup.vue";
import FormLabel from "~/components/Form/FormLabel.vue";
import {formFieldProps, useFormField} from "~/components/Form/useFormField";
import formLabelProps from "~/components/Form/formLabelProps.ts";
import {pickProps} from "~/functions/pickProps.ts";
const props = defineProps({
...formFieldProps,
...formLabelProps,
id: {
type: String,
required: true
Expand Down Expand Up @@ -137,10 +140,6 @@ const props = defineProps({
clearable: {
type: Boolean,
default: false
},
advanced: {
type: Boolean,
default: false
}
});
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/Form/FormGroupMultiCheck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
>
<form-label
:is-required="isRequired"
:advanced="advanced"
v-bind="pickProps(props, formLabelProps)"
>
<slot
name="label"
Expand Down Expand Up @@ -73,9 +73,12 @@ import FormMultiCheck from "~/components/Form/FormMultiCheck.vue";
import useSlotsExcept from "~/functions/useSlotsExcept";
import {formFieldProps, useFormField} from "~/components/Form/useFormField";
import {useSlots} from "vue";
import formLabelProps from "~/components/Form/formLabelProps.ts";
import {pickProps} from "~/functions/pickProps.ts";
const props = defineProps({
...formFieldProps,
...formLabelProps,
id: {
type: String,
required: true
Expand Down Expand Up @@ -103,10 +106,6 @@ const props = defineProps({
stacked: {
type: Boolean,
default: false
},
advanced: {
type: Boolean,
default: false
}
});
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/Form/FormGroupSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
>
<form-label
:is-required="isRequired"
:advanced="advanced"
v-bind="pickProps(props, formLabelProps)"
>
<slot
name="label"
Expand Down Expand Up @@ -63,9 +63,12 @@ import FormGroup from "~/components/Form/FormGroup.vue";
import {formFieldProps, useFormField} from "~/components/Form/useFormField";
import SelectOptions from "~/components/Form/SelectOptions.vue";
import {useSlots} from "vue";
import formLabelProps from "~/components/Form/formLabelProps.ts";
import {pickProps} from "~/functions/pickProps.ts";
const props = defineProps({
...formFieldProps,
...formLabelProps,
id: {
type: String,
required: true
Expand All @@ -90,10 +93,6 @@ const props = defineProps({
type: Boolean,
default: false
},
advanced: {
type: Boolean,
default: false
}
});
const slots = useSlots();
Expand Down
15 changes: 11 additions & 4 deletions frontend/src/components/Form/FormLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@
>
{{ $gettext('Advanced') }}
</span>

<span
v-if="highCpu"
class="badge small text-bg-warning ms-2"
:title="$gettext('This setting can result in excessive CPU consumption and should be used with caution.')"
>
{{ $gettext('High CPU') }}
</span>
</template>

<script setup lang="ts">
import formLabelProps from "~/components/Form/formLabelProps.ts";
const props = defineProps({
isRequired: {
type: Boolean,
default: false
},
advanced: {
type: Boolean,
default: false
}
...formLabelProps
});
</script>
10 changes: 10 additions & 0 deletions frontend/src/components/Form/formLabelProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
advanced: {
type: Boolean,
default: false
},
highCpu: {
type: Boolean,
default: false
}
}
10 changes: 10 additions & 0 deletions src/Entity/StationBackendConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ public function setMasterMeLoudnessTarget(?int $masterMeLoudnessTarget): void

public function useReplayGain(): bool
{
// AutoCue overrides this functionality.
if ($this->getEnableAutoCue()) {
return false;
}

return Types::boolOrNull($this->get(self::USE_REPLAYGAIN)) ?? false;
}

Expand All @@ -280,6 +285,11 @@ public function setUseReplayGain(?bool $useReplayGain): void

public function getCrossfadeTypeEnum(): CrossfadeModes
{
// AutoCue overrides this functionality.
if ($this->getEnableAutoCue()) {
return CrossfadeModes::Disabled;
}

return CrossfadeModes::tryFrom(
Types::stringOrNull($this->get(self::CROSSFADE_TYPE)) ?? ''
) ?? CrossfadeModes::default();
Expand Down

0 comments on commit 152b0b9

Please sign in to comment.