Skip to content

Commit

Permalink
Configurable crossfade duration for flow stream (#748)
Browse files Browse the repository at this point in the history
configurable crossfade duration for flow stream
  • Loading branch information
marcelveldt authored Jul 7, 2023
1 parent e4ac159 commit bbd6c6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion music_assistant/common/models/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,11 @@ class CoreConfig(Config):
CONF_ENTRY_CROSSFADE_DURATION = ConfigEntry(
key=CONF_CROSSFADE_DURATION,
type=ConfigEntryType.INTEGER,
range=(0, 12),
range=(1, 20),
default_value=8,
label="Crossfade duration",
description="Duration in seconds of the crossfade between tracks (if enabled)",
depends_on=CONF_FLOW_MODE,
advanced=True,
)

Expand Down Expand Up @@ -445,4 +446,5 @@ class CoreConfig(Config):
CONF_ENTRY_EQ_MID,
CONF_ENTRY_EQ_TREBLE,
CONF_ENTRY_OUTPUT_CHANNELS,
CONF_ENTRY_CROSSFADE_DURATION,
)
5 changes: 4 additions & 1 deletion music_assistant/server/controllers/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from music_assistant.constants import (
CONF_BIND_IP,
CONF_BIND_PORT,
CONF_CROSSFADE_DURATION,
CONF_EQ_BASS,
CONF_EQ_MID,
CONF_EQ_TREBLE,
Expand Down Expand Up @@ -802,7 +803,9 @@ async def get_flow_stream(

# set some basic vars
pcm_sample_size = int(pcm_format.sample_rate * (pcm_format.bit_depth / 8) * 2)
crossfade_duration = 10 # TODO: grab from config
crossfade_duration = self.mass.config.get_raw_player_config_value(
queue.queue_id, CONF_CROSSFADE_DURATION, 8
)
crossfade_size = int(pcm_sample_size * crossfade_duration)
queue_track.streamdetails.seconds_skipped = seek_position
buffer_size = crossfade_size if use_crossfade else int(pcm_sample_size * 2)
Expand Down
11 changes: 10 additions & 1 deletion music_assistant/server/providers/slimproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from aioslimproto.discovery import start_discovery

from music_assistant.common.models.config_entries import (
CONF_ENTRY_CROSSFADE_DURATION,
CONF_ENTRY_OUTPUT_CODEC,
ConfigEntry,
ConfigValueOption,
Expand Down Expand Up @@ -79,6 +78,16 @@ class SyncPlayPoint:
DEFAULT_PLAYER_VOLUME = 20
DEFAULT_SLIMPROTO_PORT = 3483

CONF_ENTRY_CROSSFADE_DURATION = ConfigEntry(
key=CONF_CROSSFADE_DURATION,
type=ConfigEntryType.INTEGER,
range=(1, 10),
default_value=8,
label="Crossfade duration",
description="Duration in seconds of the crossfade between tracks (if enabled)",
advanced=True,
)


async def setup(
mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
Expand Down

0 comments on commit bbd6c6a

Please sign in to comment.