From 2e9f7d8496ee7169ec981173293212944186f091 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Wed, 21 Oct 2026 20:30:51 +0300 Subject: [PATCH] Adds VU meter to the audio player bar Adds a segmented spectrum VU meter to the condensed player bar, fed by an analyser tapped after ReplayGain and before the volume, so the meter does not depend on the output volume. Adds per-user VU meter settings (orientation, segment count and gap, thresholds, peak marker, hold and falloff rates) across the domain, persistence, API contracts, validation and the settings page, with a migration and localized resources. Sizes the meter cells in whole pixels and keeps the frame clock steady on browsers that round timers. Updates the theming guide, API documentation, request samples and the user manual. --- docs/manual/using-lumina/index.md | 4 +- .../api/users-management/Api.Settings.md | 24 +- .../settings/UpdateUserSettings.http | 11 +- docs/technical/theming/Theming.md | 30 + .../UsersManagement/UserSettingsEntity.cs | 45 + .../Users/UpdateUserSettingsRequestMapping.cs | 11 +- .../Users/UserSettingsEntityMapping.cs | 20 +- .../Users/UserSettingsMapping.cs | 20 +- .../Common/Utilities/ValidatorUtilities.cs | 36 + .../UpdateUserSettingsCommand.cs | 20 +- .../UpdateUserSettingsCommandHandler.cs | 11 +- .../UpdateUserSettingsCommandValidator.cs | 73 + .../Settings/UpdateUserSettingsRequest.cs | 20 +- .../Settings/UserSettingsResponse.cs | 20 +- .../UserSettingsConfiguration.cs | 40 +- ...sVuMeterSettingsToUserSettings.Designer.cs | 3709 +++++++++++++++++ ...34714_AddsVuMeterSettingsToUserSettings.cs | 166 + .../LuminaDbContextModelSnapshot.cs | 38 +- .../Enums/Playback/VuMeterOrientation.cs | 18 + .../Common/Errors/Errors.UserSettings.cs | 18 + .../UserSettingsAggregate/UserSettings.cs | 201 +- .../GetUserSettingsEndpointSummary.cs | 47 +- .../UpdateUserSettingsEndpointSummary.cs | 52 +- .../DTO/UsersManagement/UserSettingsDto.cs | 45 + .../Enums/AudioLibrary/VuMeterOrientation.cs | 22 + .../ExceptionHandlingMiddleware.ar-SA.resx | 54 + .../ExceptionHandlingMiddleware.de-DE.resx | 54 + .../ExceptionHandlingMiddleware.en-US.resx | 54 + .../ExceptionHandlingMiddleware.es-ES.resx | 54 + .../ExceptionHandlingMiddleware.fr-FR.resx | 54 + .../ExceptionHandlingMiddleware.it-IT.resx | 54 + .../ExceptionHandlingMiddleware.ja-JP.resx | 54 + .../ExceptionHandlingMiddleware.resx | 54 + .../ExceptionHandlingMiddleware.ro-RO.resx | 54 + .../ExceptionHandlingMiddleware.uk-UA.resx | 54 + .../ExceptionHandlingMiddleware.zh-CN.resx | 54 + .../Resources/Views/Tools/Settings.ar-SA.resx | 63 + .../Resources/Views/Tools/Settings.de-DE.resx | 63 + .../Resources/Views/Tools/Settings.en-US.resx | 63 + .../Resources/Views/Tools/Settings.es-ES.resx | 63 + .../Resources/Views/Tools/Settings.fr-FR.resx | 63 + .../Resources/Views/Tools/Settings.it-IT.resx | 63 + .../Resources/Views/Tools/Settings.ja-JP.resx | 63 + .../Core/Resources/Views/Tools/Settings.resx | 63 + .../Resources/Views/Tools/Settings.ro-RO.resx | 63 + .../Resources/Views/Tools/Settings.uk-UA.resx | 63 + .../Resources/Views/Tools/Settings.zh-CN.resx | 63 + .../Core/Views/Shared/_AudioPlayer.cshtml | 12 +- .../Views/Shared/_ThemeLayoutScripts.cshtml | 1 + .../Core/Views/Tools/Settings.cshtml | 141 +- .../wwwroot/css/site.css | 122 +- .../js/audio-player/audio-player-engine.js | 6 + .../audio-player-pipeline-engine.js | 10 + .../js/audio-player/audio-player-render.js | 98 +- .../js/audio-player/audio-player-vu-meter.js | 1074 +++++ .../wwwroot/js/audio-player/audio-player.js | 149 +- .../UserSettingsEntityFixture.cs | 66 +- .../UpdateUserSettingsCommandFixture.cs | 35 +- .../UpdateUserSettingsRequestFixture.cs | 34 +- .../Settings/UserSettingsResponseFixture.cs | 34 +- .../UserSettingsFixture.cs | 27 + .../Users/UserSettingsEntityMappingTests.cs | 41 +- .../Users/UserSettingsMappingTests.cs | 43 +- .../UserSettingsConfigurationTests.cs | 18 + .../Common/Errors/ErrorsTests.cs | 20 +- .../UserSettingsTests.cs | 6 +- 66 files changed, 7844 insertions(+), 81 deletions(-) create mode 100644 src/Lumina.DataAccess/Common/Migrations/20261021134714_AddsVuMeterSettingsToUserSettings.Designer.cs create mode 100644 src/Lumina.DataAccess/Common/Migrations/20261021134714_AddsVuMeterSettingsToUserSettings.cs create mode 100644 src/Lumina.Domain.SharedKernel/Common/Enums/Playback/VuMeterOrientation.cs create mode 100644 src/Lumina.Presentation.Web/Common/Enums/AudioLibrary/VuMeterOrientation.cs create mode 100644 src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-vu-meter.js diff --git a/docs/manual/using-lumina/index.md b/docs/manual/using-lumina/index.md index 937a0c55..4859fc7c 100644 --- a/docs/manual/using-lumina/index.md +++ b/docs/manual/using-lumina/index.md @@ -73,7 +73,7 @@ Each artist is a card; selecting it opens the artist's page, and the card's acti The artist page is also where you edit the artist. It lists the artist's albums as cards, each leading to its own album page, followed by the artist's general information, contributors, ratings, genres, tags, aliases, areas and identifiers. The album page holds the album's information and its tracks, and the track page holds the track's details. The album page also shows the artwork Lumina stored for the album as a strip of thumbnails beside the main image, and selecting a thumbnail displays that image in place of the cover. Deleting an artist, album or track removes it from Lumina's catalogue; your files are not touched. -The music pages also play what they show. The artist page has a **Play all** control that plays the artist's releases in the order the page presents them, one release after another. The actions menu of a music library card on the home page, of an artist card, and of an album card offers **Play** and **Shuffle**. Play starts the library at its first artist and continues through the remaining artists in artist page order, starts the artist's discography in the order the artist page presents it, or starts the release in disc and track order. Shuffle starts the library, the artist's discography or the release with a list of up to 100 tracks sampled uniformly at random from every track of that scope, and continues in random order without repeating a track that is already queued. The album page has a **Play album** control that plays the release in disc and track order, and every track row has its own play control that plays just that track. The track page has a **Play track** control for the track it shows. Every track row on the album page also has an actions menu: **Add to playlist** opens the playlist picker for that track, **Add to play queue** appends it to the end of the player queue or starts it when the queue is empty, and **Play all from here** replaces the queue with that track and the rest of the album and starts playing. Starting playback opens the player bar at the bottom of the window. It keeps playing while you move between pages, and the bar shows the track name, with the album name underneath when the track belongs to a named album, the progress of the current track and the volume, together with previous, play or pause, stop, next and repeat controls. When you expand it, it also shows the cover art, the current track name, the release type, the release name and year, the artist name, and a carousel of the album's stored artwork, next to the queue, where every entry carries its album cover, including when only one track is queued. Selecting an artwork in the carousel shows it as the main cover. The expanded queue moves the current track to the top whenever playback advances, so it stays visible even in a long list. The double chevron at the right points up to expand the bar and down to collapse it. Stop is the square control next to play or pause; in the condensed bar it stops playback and slides the bar out of view. +The music pages also play what they show. The artist page has a **Play all** control that plays the artist's releases in the order the page presents them, one release after another. The actions menu of a music library card on the home page, of an artist card, and of an album card offers **Play** and **Shuffle**. Play starts the library at its first artist and continues through the remaining artists in artist page order, starts the artist's discography in the order the artist page presents it, or starts the release in disc and track order. Shuffle starts the library, the artist's discography or the release with a list of up to 100 tracks sampled uniformly at random from every track of that scope, and continues in random order without repeating a track that is already queued. The album page has a **Play album** control that plays the release in disc and track order, and every track row has its own play control that plays just that track. The track page has a **Play track** control for the track it shows. Every track row on the album page also has an actions menu: **Add to playlist** opens the playlist picker for that track, **Add to play queue** appends it to the end of the player queue or starts it when the queue is empty, and **Play all from here** replaces the queue with that track and the rest of the album and starts playing. Starting playback opens the player bar at the bottom of the window. It keeps playing while you move between pages, and the bar shows the track name, with the album name underneath when the track belongs to a named album, the progress of the current track, a segmented VU meter that follows the level of the track, and the volume, together with previous, play or pause, stop, next and repeat controls. When you expand it, it also shows the cover art, the current track name, the release type, the release name and year, the artist name, and a carousel of the album's stored artwork, next to the queue, where every entry carries its album cover, including when only one track is queued. Selecting an artwork in the carousel shows it as the main cover. The expanded queue moves the current track to the top whenever playback advances, so it stays visible even in a long list. The double chevron at the right points up to expand the bar and down to collapse it. Stop is the square control next to play or pause; in the condensed bar it stops playback and slides the bar out of view. ## Playlists @@ -106,4 +106,6 @@ The tools section holds your settings and the language picker. Your **settings** decide how lists and books behave for you. Enable pagination and the number of items per page control how browsing is split. The alpha picker option decides whether titles beginning with "The" are filed under the next word. Theme caching decides whether the theme is fetched fresh each time. Rendering PDFs as images and preserving book styles shape how books are shown, and the metadata and artwork aggregation options decide whether missing fields are completed from your other providers. A final group of options shapes playback: whether the player keeps downloading while it is paused (for a track the server has to normalize, this keeps its bounded one-segment lookahead filled rather than downloading the whole file), whether it continues automatically at the end of an album or artist, whether consecutive tracks play without a gap, how ReplayGain normalizes loudness, and the quality cap used when the server has to normalize a track. That cap applies only when the server re-encodes a track into a lossy format; a remux only repackages the stored audio, and a lossless delivery is not reduced. The ones that touch libraries are described in more detail in [Managing Libraries](../managing-libraries/index.md). +The **VU meter** group shapes the meter of the player bar. Orientation lays its channels out as columns that grow upwards or rows that grow to the right. Segments per channel sets how finely each channel is divided, and Segment gap sets the space between segments and channels. The medium and high thresholds decide the level at which a segment changes color; the high threshold cannot be lower than the medium one. Show peak keeps a mark at the loudest recent level of each channel. Peak hold is how long that mark stays in place before it falls, in milliseconds, and Level falloff and Peak falloff are how quickly the bars and the peak marks drop once the sound gets quieter, in level units per second. Larger falloff values drop faster. The meter follows the level of the track itself, so muting the player or moving the volume slider does not change the height of the bars, and saving these settings applies them to the player without reloading the page. + The **language** picker switches the interface between the languages Lumina ships with, and remembers your choice. diff --git a/docs/technical/api/users-management/Api.Settings.md b/docs/technical/api/users-management/Api.Settings.md index 0808961a..6dae4440 100644 --- a/docs/technical/api/users-management/Api.Settings.md +++ b/docs/technical/api/users-management/Api.Settings.md @@ -47,7 +47,16 @@ Returns the settings of the currently authenticated user. "shouldAutoplay": true, "isGaplessPlaybackEnabled": true, "replayGainMode": "Off", - "streamingQuality": "Auto" + "streamingQuality": "Auto", + "vuMeterOrientation": "Vertical", + "vuMeterSegmentCount": 12, + "vuMeterSegmentGap": 1, + "vuMeterMediumThreshold": 0.6, + "vuMeterHighThreshold": 0.8, + "vuMeterShowPeak": true, + "vuMeterPeakHoldDurationInMilliseconds": 650, + "vuMeterReleasePerSecond": 3, + "vuMeterPeakReleasePerSecond": 0.65 } ``` @@ -61,6 +70,8 @@ PUT api/v1/users/me/settings Updates the settings of the currently authenticated user. +The VU meter settings configure the segmented meter of the player bar: `vuMeterOrientation` is `Vertical` or `Horizontal`, `vuMeterSegmentCount` is between 1 and 128, `vuMeterSegmentGap` is between 0 and 32 pixels, `vuMeterMediumThreshold` and `vuMeterHighThreshold` are between 0 and 1 and the high threshold must not be lower than the medium one, `vuMeterPeakHoldDurationInMilliseconds` is between 0 and 10000, and `vuMeterReleasePerSecond` and `vuMeterPeakReleasePerSecond` are between 0 and 100 level units per second. All of them are required. + ```json { "isPaginationEnabled": true, @@ -74,7 +85,16 @@ Updates the settings of the currently authenticated user. "shouldAutoplay": true, "isGaplessPlaybackEnabled": true, "replayGainMode": "Off", - "streamingQuality": "Auto" + "streamingQuality": "Auto", + "vuMeterOrientation": "Vertical", + "vuMeterSegmentCount": 12, + "vuMeterSegmentGap": 1, + "vuMeterMediumThreshold": 0.6, + "vuMeterHighThreshold": 0.8, + "vuMeterShowPeak": true, + "vuMeterPeakHoldDurationInMilliseconds": 650, + "vuMeterReleasePerSecond": 3, + "vuMeterPeakReleasePerSecond": 0.65 } ``` diff --git a/docs/technical/requests/users-management/settings/UpdateUserSettings.http b/docs/technical/requests/users-management/settings/UpdateUserSettings.http index c65e30c9..22804ce0 100644 --- a/docs/technical/requests/users-management/settings/UpdateUserSettings.http +++ b/docs/technical/requests/users-management/settings/UpdateUserSettings.http @@ -14,5 +14,14 @@ Content-Type: application/json "shouldAutoplay": true, "isGaplessPlaybackEnabled": true, "replayGainMode": "Off", - "streamingQuality": "Auto" + "streamingQuality": "Auto", + "vuMeterOrientation": "Vertical", + "vuMeterSegmentCount": 12, + "vuMeterSegmentGap": 1, + "vuMeterMediumThreshold": 0.6, + "vuMeterHighThreshold": 0.8, + "vuMeterShowPeak": true, + "vuMeterPeakHoldDurationInMilliseconds": 650, + "vuMeterReleasePerSecond": 3, + "vuMeterPeakReleasePerSecond": 0.65 } diff --git a/docs/technical/theming/Theming.md b/docs/technical/theming/Theming.md index 7e105e7a..6d0bfb2e 100644 --- a/docs/technical/theming/Theming.md +++ b/docs/technical/theming/Theming.md @@ -14,6 +14,7 @@ The web client of Lumina is a themed shell: every page is rendered inside the te - [Template Resolution](#template-resolution) - [The Layout Template (shared/layout)](#the-layout-template-sharedlayout) - [The Audio Player Bar](#the-audio-player-bar) + - [The VU Meter](#the-vu-meter) - [Play Affordances on the Music Pages](#play-affordances-on-the-music-pages) - [The audio player sub templates](#the-audio-player-sub-templates) - [The Navigation Template (shared/nav-menu)](#the-navigation-template-sharednav-menu) @@ -306,6 +307,7 @@ The markup inside the bar exposes the hook attributes the audio player script bi | `data-audio-player-now-playing-artist` | The artist name of the current track's album in the expanded player. It is left empty until the album details are available. | | `data-audio-player-artwork-carousel` | The carousel of the stored artwork of the current track's album. The player appends one `button.artwork-carousel-item` per stored image, carrying `data-artwork-path`, and toggles the `selected` class and `aria-pressed` on the chosen item. The element is hidden with the `hidden` attribute while the album has no stored artwork. | | `data-audio-player-cover-thumbnail`, `data-audio-player-cover-image` | The cover art of the condensed bar and of the expanded bar. Choosing an album artwork in the carousel replaces both images until the next track. | +| `data-audio-player-vu-meter` | The root of the VU meter of the condensed bar, between the album art and the current time label. The player fills it with its channels, segments and peak markers, exactly as described in [The VU Meter](#the-vu-meter). A theme that does not render the hook gets the built-in meter inserted in that place. | | `data-audio-player-volume` | The volume slider, a `role="slider"` element with `tabindex="0"` that the player scrubs and whose ARIA value attributes it writes. The fill is published as `--audio-player-volume-start` and `--audio-player-volume-width`. | | `data-audio-player-volume-level` | The volume fill. It carries no geometry of its own: the stylesheet drives it from the custom properties above. | | `data-audio-player-mute` | The mute toggle. The player toggles the `is-muted` class and the `aria-pressed` state on it. | @@ -313,6 +315,34 @@ The markup inside the bar exposes the hook attributes the audio player script bi Each progress layer also carries `data-audio-player-progress-layer` (`played`, `downloaded` or `undownloaded`) in the markup, so a theme can select a layer by its state as well as by its class. The player writes no inline geometry on any of the bar elements: it publishes the geometry of each state as the custom properties above, which the application stylesheet consumes, so a theme restyles or reorients either bar by consuming the same properties. +#### The VU Meter + +The condensed bar shows a segmented VU meter that follows the level of the track itself. The renderer taps it after the track's ReplayGain normalization and before the output volume and mute stage, so lowering the volume or muting the player never changes the height of the meter for the same moment of audio. The meter is a spectrum meter with one channel per frequency band, with 24 logarithmically spaced bands between 40 Hz and 16 kHz, each drawn as a stack of segments. The number of segments, the gap between them, the two threshold zones, the peak marker and its hold and falloff times, and the orientation are per-user settings, so the meter reflects the values the user saved on the settings page. + +The meter is built from elements rather than a canvas, exactly like the three state progress bar, so a theme restyles every part of it. The root carries the `audio-player-vu-meter` class and the `data-audio-player-vu-meter` hook, and the player fills it with: + +| Element | Class and hook | State the player writes | +| --- | --- | --- | +| A channel, one per band | `audio-player-vu-channel`, `data-audio-player-vu-channel` (the zero based band index) | None. The channel is a layout container. | +| A segment, one per configured segment of a channel | `audio-player-vu-segment`, `data-audio-player-vu-segment` | `data-audio-player-vu-segment-state` (`active` or `inactive`) and `data-audio-player-vu-segment-zone` (`normal`, `medium` or `high`). The zone is derived from the position of the segment and the two thresholds of the settings. | +| A peak marker, one per channel | `audio-player-vu-peak`, `data-audio-player-vu-peak` | `data-audio-player-vu-peak-state` (`active` or `inactive`). The marker is removed with the `hidden` attribute while the show peak setting is off. | + +The segments are rendered in ascending level order, so the first segment of a channel is the quietest one. The root also carries `data-audio-player-vu-meter-orientation` (`vertical` or `horizontal`), `data-audio-player-vu-meter-segments` (the configured segment count) and `data-audio-player-vu-meter-show-peak` (`true` or `false`), so a theme can select a state or a layout from the root as well. + +The player publishes no geometry other than two custom properties, which a theme maps to whichever axis its own layout uses: + +| Custom property | Published on | Meaning | +| --- | --- | --- | +| `--audio-player-vu-segment-gap` | The meter root | The configured gap between segments and between channels, as a CSS length in pixels. | +| `--audio-player-vu-segment-count` | The meter root | The configured number of segments per channel, as a plain number, so a stylesheet can size the meter from it. | +| `--audio-player-vu-peak-position` | Each peak marker | The held peak of its channel, as a percentage of the channel axis, from `0%` at the quiet end to `100%` at the loud end. | + +The fallback stylesheet sizes the vertical meter from whole pixel square cells rather than stretching it over a box, because a box divided into rows gives fractional heights that browsers snap unevenly. The cell is the largest whole pixel size that fits the configured segments in `--audio-player-vu-extent` (48px by default), capped by `--audio-player-vu-max-cell` (4px), and a theme can override either property. With the default 12 segments and a 1px gap the cells are 3px squares. + +The application fallback stylesheet gives the meter its own default look: 24 columns of segments whose active state uses one of three colors, with the inactive segments transparent, and a peak line that spans the short axis of the channel. A theme can replace all of it. The colors are custom properties declared on the bar container (`--audio-player-vu-normal-color`, `--audio-player-vu-medium-color`, `--audio-player-vu-high-color`, `--audio-player-vu-inactive-color`, `--audio-player-vu-peak-color` and `--audio-player-vu-background-color`), so a theme recolors the meter without touching the markup, and it can give each zone, each state and each orientation its own shape, image or animation. + +The meter is decorative for assistive technology and carries `aria-hidden="true"`, because the same information is available through the now playing labels and the progress bar. It reads the analyzer that the player renderer taps after the track's ReplayGain normalization and before the output volume, so it needs no extra request and no extra decode, it is unaffected by the volume and mute controls, and it never affects playback. When the player is paused, stopped, ended or failed, the displayed levels fall to zero instead of freezing. + #### Play Affordances on the Music Pages The artist page, the album page and the track page render play triggers, and the card actions menus render play and shuffle triggers, all handled by the global audio player script through event delegation. The music library cards on the home page, the artist cards and the album cards offer both actions, so the whole library, an artist or a release can be started in order or shuffled. A theme template that replaces one of those pages or menus opts in by rendering the same trigger attributes: the player binds one listener on the document, so a trigger works anywhere in the swapped page content and the page needs no script of its own. diff --git a/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserSettingsEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserSettingsEntity.cs index cf6ed5a2..b472e933 100644 --- a/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserSettingsEntity.cs +++ b/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserSettingsEntity.cs @@ -91,6 +91,51 @@ public class UserSettingsEntity : IStorageEntity, IAuditableEntity /// public PlaybackStreamingQuality StreamingQuality { get; set; } + /// + /// Gets or sets the direction in which each channel of the VU meter of the audio player grows. + /// + public VuMeterOrientation VuMeterOrientation { get; set; } + + /// + /// Gets or sets the number of segments each channel of the VU meter is divided into. + /// + public int VuMeterSegmentCount { get; set; } = 12; + + /// + /// Gets or sets the gap, in pixels, between the segments and the channels of the VU meter. + /// + public int VuMeterSegmentGap { get; set; } = 1; + + /// + /// Gets or sets the level, between 0 and 1, above which a segment of the VU meter is drawn with its medium state. + /// + public double VuMeterMediumThreshold { get; set; } = 0.6; + + /// + /// Gets or sets the level, between 0 and 1, above which a segment of the VU meter is drawn with its high state. + /// + public double VuMeterHighThreshold { get; set; } = 0.8; + + /// + /// Gets or sets whether the VU meter holds the peak level of each channel after it falls, or not. + /// + public bool VuMeterShowPeak { get; set; } = true; + + /// + /// Gets or sets the time, in milliseconds, a peak of the VU meter is held before it starts falling. + /// + public int VuMeterPeakHoldDurationInMilliseconds { get; set; } = 650; + + /// + /// Gets or sets the number of level units the display of the VU meter falls per second when the input level drops. + /// + public double VuMeterReleasePerSecond { get; set; } = 3.0; + + /// + /// Gets or sets the number of level units the peak of the VU meter falls per second after its hold time elapsed. + /// + public double VuMeterPeakReleasePerSecond { get; set; } = 0.65; + /// /// Gets or sets the last volume the player reported for the user. Written automatically by the player, and not part of the settings the user edits. /// diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs index 6f6060af..098767b0 100644 --- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs +++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs @@ -30,7 +30,16 @@ public static class UpdateUserSettingsRequestMapping request.ShouldAutoplay, request.IsGaplessPlaybackEnabled, request.ReplayGainMode, - request.StreamingQuality + request.StreamingQuality, + request.VuMeterOrientation, + request.VuMeterSegmentCount, + request.VuMeterSegmentGap, + request.VuMeterMediumThreshold, + request.VuMeterHighThreshold, + request.VuMeterShowPeak, + request.VuMeterPeakHoldDurationInMilliseconds, + request.VuMeterReleasePerSecond, + request.VuMeterPeakReleasePerSecond ); } } diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs index d5e9da55..ab434cdd 100644 --- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs +++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs @@ -39,6 +39,15 @@ public static class UserSettingsEntityMapping repositoryEntity.IsGaplessPlaybackEnabled, repositoryEntity.ReplayGainMode, repositoryEntity.StreamingQuality, + repositoryEntity.VuMeterOrientation, + repositoryEntity.VuMeterSegmentCount, + repositoryEntity.VuMeterSegmentGap, + repositoryEntity.VuMeterMediumThreshold, + repositoryEntity.VuMeterHighThreshold, + repositoryEntity.VuMeterShowPeak, + repositoryEntity.VuMeterPeakHoldDurationInMilliseconds, + repositoryEntity.VuMeterReleasePerSecond, + repositoryEntity.VuMeterPeakReleasePerSecond, repositoryEntity.Volume, repositoryEntity.IsMuted ); @@ -65,7 +74,16 @@ public static class UserSettingsEntityMapping repositoryEntity.ShouldAutoplay, repositoryEntity.IsGaplessPlaybackEnabled, repositoryEntity.ReplayGainMode, - repositoryEntity.StreamingQuality + repositoryEntity.StreamingQuality, + repositoryEntity.VuMeterOrientation, + repositoryEntity.VuMeterSegmentCount, + repositoryEntity.VuMeterSegmentGap, + repositoryEntity.VuMeterMediumThreshold, + repositoryEntity.VuMeterHighThreshold, + repositoryEntity.VuMeterShowPeak, + repositoryEntity.VuMeterPeakHoldDurationInMilliseconds, + repositoryEntity.VuMeterReleasePerSecond, + repositoryEntity.VuMeterPeakReleasePerSecond ); } } diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs index edef94fc..5ad4a7d5 100644 --- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs +++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs @@ -35,6 +35,15 @@ public static class UserSettingsMapping IsGaplessPlaybackEnabled = domainEntity.IsGaplessPlaybackEnabled, ReplayGainMode = domainEntity.ReplayGainMode, StreamingQuality = domainEntity.StreamingQuality, + VuMeterOrientation = domainEntity.VuMeterOrientation, + VuMeterSegmentCount = domainEntity.VuMeterSegmentCount, + VuMeterSegmentGap = domainEntity.VuMeterSegmentGap, + VuMeterMediumThreshold = domainEntity.VuMeterMediumThreshold, + VuMeterHighThreshold = domainEntity.VuMeterHighThreshold, + VuMeterShowPeak = domainEntity.VuMeterShowPeak, + VuMeterPeakHoldDurationInMilliseconds = domainEntity.VuMeterPeakHoldDurationInMilliseconds, + VuMeterReleasePerSecond = domainEntity.VuMeterReleasePerSecond, + VuMeterPeakReleasePerSecond = domainEntity.VuMeterPeakReleasePerSecond, Volume = domainEntity.Volume, IsMuted = domainEntity.IsMuted }; @@ -61,7 +70,16 @@ public static class UserSettingsMapping domainEntity.ShouldAutoplay, domainEntity.IsGaplessPlaybackEnabled, domainEntity.ReplayGainMode, - domainEntity.StreamingQuality + domainEntity.StreamingQuality, + domainEntity.VuMeterOrientation, + domainEntity.VuMeterSegmentCount, + domainEntity.VuMeterSegmentGap, + domainEntity.VuMeterMediumThreshold, + domainEntity.VuMeterHighThreshold, + domainEntity.VuMeterShowPeak, + domainEntity.VuMeterPeakHoldDurationInMilliseconds, + domainEntity.VuMeterReleasePerSecond, + domainEntity.VuMeterPeakReleasePerSecond ); } } diff --git a/src/Lumina.Application/Common/Utilities/ValidatorUtilities.cs b/src/Lumina.Application/Common/Utilities/ValidatorUtilities.cs index c0c5d385..f4ffb337 100644 --- a/src/Lumina.Application/Common/Utilities/ValidatorUtilities.cs +++ b/src/Lumina.Application/Common/Utilities/ValidatorUtilities.cs @@ -174,6 +174,26 @@ public static class ValidatorUtilities return ruleBuilder.Must(value => !value.HasValue || value.Value >= valueToCompare); } + /// + /// Defines a validation rule that ensures the nullable double property is greater than or equal to the value another property of the request selects. + /// + /// + /// If either the property or the selected comparison value is , this rule passes (use + /// to check for missing values). + /// + /// The type of the request being validated. + /// The rule builder instance. + /// A function that selects the value the property must be greater than or equal to. + /// The current instance for method chaining. + public static IRuleBuilder GreaterThanOrEqualTo(this IRuleBuilder ruleBuilder, Func comparisonSelector) + { + return ruleBuilder.Must((request, value) => + { + double? comparisonValue = comparisonSelector(request); + return !value.HasValue || !comparisonValue.HasValue || value.Value >= comparisonValue.Value; + }); + } + /// /// Defines a validation rule that ensures the property is not . /// @@ -365,6 +385,22 @@ public static class ValidatorUtilities return ruleBuilder.Must(value => !value.HasValue || (value.Value >= minimumValue && value.Value <= maximumValue)); } + /// + /// Defines a validation rule that ensures the nullable double property is within the specified inclusive range. + /// + /// + /// If the property is , this rule passes (use to check for missing values). + /// + /// The type of the request being validated. + /// The rule builder instance. + /// The minimum allowed value of the property. + /// The maximum allowed value of the property. + /// The current instance for method chaining. + public static IRuleBuilder InclusiveBetween(this IRuleBuilder ruleBuilder, double minimumValue, double maximumValue) + { + return ruleBuilder.Must(value => !value.HasValue || (value.Value >= minimumValue && value.Value <= maximumValue)); + } + /// /// Defines a validation rule that ensures the property is equal to another property of the request. /// diff --git a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs index 8fccc1a4..23acd6bf 100644 --- a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs +++ b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs @@ -21,6 +21,15 @@ namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSe /// Whether the player transitions between consecutive tracks without a gap, or not. /// The way ReplayGain normalization is applied to the tracks the user plays. /// The quality cap applied to the audio the server normalizes for the user. +/// The direction in which each channel of the VU meter of the audio player grows. +/// The number of segments each channel of the VU meter is divided into. +/// The gap, in pixels, between the segments and the channels of the VU meter. +/// The level, between 0 and 1, above which a segment of the VU meter is drawn with its medium state. +/// The level, between 0 and 1, above which a segment of the VU meter is drawn with its high state. +/// Whether the VU meter holds the peak level of each channel after it falls, or not. +/// The time, in milliseconds, a peak of the VU meter is held before it starts falling. +/// The number of level units the display of the VU meter falls per second when the input level drops. +/// The number of level units the peak of the VU meter falls per second after its hold time elapsed. public record UpdateUserSettingsCommand( bool IsPaginationEnabled, int ItemsPerPage, @@ -34,5 +43,14 @@ public record UpdateUserSettingsCommand( bool? ShouldAutoplay, bool? IsGaplessPlaybackEnabled, ReplayGainMode? ReplayGainMode, - PlaybackStreamingQuality? StreamingQuality + PlaybackStreamingQuality? StreamingQuality, + VuMeterOrientation? VuMeterOrientation, + int? VuMeterSegmentCount, + int? VuMeterSegmentGap, + double? VuMeterMediumThreshold, + double? VuMeterHighThreshold, + bool? VuMeterShowPeak, + int? VuMeterPeakHoldDurationInMilliseconds, + double? VuMeterReleasePerSecond, + double? VuMeterPeakReleasePerSecond ) : ICommand; diff --git a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs index 9298f87a..402f31f2 100644 --- a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs +++ b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs @@ -124,6 +124,15 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler command.StreamingQuality is not null); + + RuleFor(command => command.VuMeterOrientation) + .NotNull() + .WithError(Errors.UserSettings.VuMeterOrientationCannotBeNull); + + RuleFor(command => command.VuMeterOrientation) + .IsInEnum() + .WithError(Errors.UserSettings.InvalidVuMeterOrientation) + .When(command => command.VuMeterOrientation is not null); + + RuleFor(command => command.VuMeterSegmentCount) + .NotNull() + .WithError(Errors.UserSettings.VuMeterSegmentCountCannotBeNull); + + RuleFor(command => command.VuMeterSegmentCount) + .InclusiveBetween(1, 128) + .WithError(Errors.UserSettings.VuMeterSegmentCountMustBeBetweenOneAndOneHundredTwentyEight); + + RuleFor(command => command.VuMeterSegmentGap) + .NotNull() + .WithError(Errors.UserSettings.VuMeterSegmentGapCannotBeNull); + + RuleFor(command => command.VuMeterSegmentGap) + .InclusiveBetween(0, 32) + .WithError(Errors.UserSettings.VuMeterSegmentGapMustBeBetweenZeroAndThirtyTwo); + + RuleFor(command => command.VuMeterMediumThreshold) + .NotNull() + .WithError(Errors.UserSettings.VuMeterMediumThresholdCannotBeNull); + + RuleFor(command => command.VuMeterMediumThreshold) + .InclusiveBetween(0d, 1d) + .WithError(Errors.UserSettings.VuMeterMediumThresholdMustBeBetweenZeroAndOne); + + RuleFor(command => command.VuMeterHighThreshold) + .NotNull() + .WithError(Errors.UserSettings.VuMeterHighThresholdCannotBeNull); + + RuleFor(command => command.VuMeterHighThreshold) + .InclusiveBetween(0d, 1d) + .WithError(Errors.UserSettings.VuMeterHighThresholdMustBeBetweenZeroAndOne); + + RuleFor(command => command.VuMeterHighThreshold) + .GreaterThanOrEqualTo(command => command.VuMeterMediumThreshold) + .WithError(Errors.UserSettings.VuMeterHighThresholdMustBeGreaterThanOrEqualToMediumThreshold); + + RuleFor(command => command.VuMeterShowPeak) + .NotNull() + .WithError(Errors.UserSettings.VuMeterShowPeakCannotBeNull); + + RuleFor(command => command.VuMeterPeakHoldDurationInMilliseconds) + .NotNull() + .WithError(Errors.UserSettings.VuMeterPeakHoldDurationCannotBeNull); + + RuleFor(command => command.VuMeterPeakHoldDurationInMilliseconds) + .InclusiveBetween(0, 10000) + .WithError(Errors.UserSettings.VuMeterPeakHoldDurationMustBeBetweenZeroAndTenThousandMilliseconds); + + RuleFor(command => command.VuMeterReleasePerSecond) + .NotNull() + .WithError(Errors.UserSettings.VuMeterReleasePerSecondCannotBeNull); + + RuleFor(command => command.VuMeterReleasePerSecond) + .InclusiveBetween(0d, 100d) + .WithError(Errors.UserSettings.VuMeterReleasePerSecondMustBeBetweenZeroAndOneHundred); + + RuleFor(command => command.VuMeterPeakReleasePerSecond) + .NotNull() + .WithError(Errors.UserSettings.VuMeterPeakReleasePerSecondCannotBeNull); + + RuleFor(command => command.VuMeterPeakReleasePerSecond) + .InclusiveBetween(0d, 100d) + .WithError(Errors.UserSettings.VuMeterPeakReleasePerSecondMustBeBetweenZeroAndOneHundred); } } diff --git a/src/Lumina.Contracts/Requests/UsersManagement/Settings/UpdateUserSettingsRequest.cs b/src/Lumina.Contracts/Requests/UsersManagement/Settings/UpdateUserSettingsRequest.cs index 53c5ec79..44ad87c3 100644 --- a/src/Lumina.Contracts/Requests/UsersManagement/Settings/UpdateUserSettingsRequest.cs +++ b/src/Lumina.Contracts/Requests/UsersManagement/Settings/UpdateUserSettingsRequest.cs @@ -21,6 +21,15 @@ namespace Lumina.Contracts.Requests.UsersManagement.Settings; /// Whether the player transitions between consecutive tracks without a gap, or not. Required. /// The way ReplayGain normalization is applied to the tracks the user plays. Required. /// The quality cap applied to the audio the server normalizes for the user. Required. +/// The direction in which each channel of the VU meter of the audio player grows. Required. +/// The number of segments each channel of the VU meter is divided into. Required. +/// The gap, in pixels, between the segments and the channels of the VU meter. Required. +/// The level, between 0 and 1, above which a segment of the VU meter is drawn with its medium state. Required. +/// The level, between 0 and 1, above which a segment of the VU meter is drawn with its high state. Required. +/// Whether the VU meter holds the peak level of each channel after it falls, or not. Required. +/// The time, in milliseconds, a peak of the VU meter is held before it starts falling. Required. +/// The number of level units the display of the VU meter falls per second when the input level drops. Required. +/// The number of level units the peak of the VU meter falls per second after its hold time elapsed. Required. [DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")] public sealed record UpdateUserSettingsRequest( bool IsPaginationEnabled, @@ -35,5 +44,14 @@ public sealed record UpdateUserSettingsRequest( bool? ShouldAutoplay, bool? IsGaplessPlaybackEnabled, ReplayGainMode? ReplayGainMode, - PlaybackStreamingQuality? StreamingQuality + PlaybackStreamingQuality? StreamingQuality, + VuMeterOrientation? VuMeterOrientation, + int? VuMeterSegmentCount, + int? VuMeterSegmentGap, + double? VuMeterMediumThreshold, + double? VuMeterHighThreshold, + bool? VuMeterShowPeak, + int? VuMeterPeakHoldDurationInMilliseconds, + double? VuMeterReleasePerSecond, + double? VuMeterPeakReleasePerSecond ); diff --git a/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs b/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs index c4ea9fad..93c5da77 100644 --- a/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs +++ b/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs @@ -23,6 +23,15 @@ namespace Lumina.Contracts.Responses.UsersManagement.Settings; /// Whether the player transitions between consecutive tracks without a gap, or not. /// The way ReplayGain normalization is applied to the tracks the user plays. /// The quality cap applied to the audio the server normalizes for the user. +/// The direction in which each channel of the VU meter of the audio player grows. +/// The number of segments each channel of the VU meter is divided into. +/// The gap, in pixels, between the segments and the channels of the VU meter. +/// The level, between 0 and 1, above which a segment of the VU meter is drawn with its medium state. +/// The level, between 0 and 1, above which a segment of the VU meter is drawn with its high state. +/// Whether the VU meter holds the peak level of each channel after it falls, or not. +/// The time, in milliseconds, a peak of the VU meter is held before it starts falling. +/// The number of level units the display of the VU meter falls per second when the input level drops. +/// The number of level units the peak of the VU meter falls per second after its hold time elapsed. [DebuggerDisplay("UserId: {UserId}")] public sealed record UserSettingsResponse( Guid UserId, @@ -38,5 +47,14 @@ public sealed record UserSettingsResponse( bool ShouldAutoplay, bool IsGaplessPlaybackEnabled, ReplayGainMode ReplayGainMode, - PlaybackStreamingQuality StreamingQuality + PlaybackStreamingQuality StreamingQuality, + VuMeterOrientation VuMeterOrientation, + int VuMeterSegmentCount, + int VuMeterSegmentGap, + double VuMeterMediumThreshold, + double VuMeterHighThreshold, + bool VuMeterShowPeak, + int VuMeterPeakHoldDurationInMilliseconds, + double VuMeterReleasePerSecond, + double VuMeterPeakReleasePerSecond ); diff --git a/src/Lumina.DataAccess/Common/Configuration/UserSettingsConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/UserSettingsConfiguration.cs index c60b07e8..864b310d 100644 --- a/src/Lumina.DataAccess/Common/Configuration/UserSettingsConfiguration.cs +++ b/src/Lumina.DataAccess/Common/Configuration/UserSettingsConfiguration.cs @@ -86,14 +86,50 @@ public class UserSettingsConfiguration : IEntityTypeConfiguration settings.Volume) + builder.Property(settings => settings.VuMeterOrientation) .IsRequired() .HasColumnOrder(19); - builder.Property(settings => settings.IsMuted) + builder.Property(settings => settings.VuMeterSegmentCount) .IsRequired() .HasColumnOrder(20); + builder.Property(settings => settings.VuMeterSegmentGap) + .IsRequired() + .HasColumnOrder(21); + + builder.Property(settings => settings.VuMeterMediumThreshold) + .IsRequired() + .HasColumnOrder(22); + + builder.Property(settings => settings.VuMeterHighThreshold) + .IsRequired() + .HasColumnOrder(23); + + builder.Property(settings => settings.VuMeterShowPeak) + .IsRequired() + .HasColumnOrder(24); + + builder.Property(settings => settings.VuMeterPeakHoldDurationInMilliseconds) + .IsRequired() + .HasColumnOrder(25); + + builder.Property(settings => settings.VuMeterReleasePerSecond) + .IsRequired() + .HasColumnOrder(26); + + builder.Property(settings => settings.VuMeterPeakReleasePerSecond) + .IsRequired() + .HasColumnOrder(27); + + builder.Property(settings => settings.Volume) + .IsRequired() + .HasColumnOrder(28); + + builder.Property(settings => settings.IsMuted) + .IsRequired() + .HasColumnOrder(29); + // audit builder.Property(settings => settings.CreatedOnUtc) .IsRequired() diff --git a/src/Lumina.DataAccess/Common/Migrations/20261021134714_AddsVuMeterSettingsToUserSettings.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20261021134714_AddsVuMeterSettingsToUserSettings.Designer.cs new file mode 100644 index 00000000..d2cbd08c --- /dev/null +++ b/src/Lumina.DataAccess/Common/Migrations/20261021134714_AddsVuMeterSettingsToUserSettings.Designer.cs @@ -0,0 +1,3709 @@ +// +using System; +using Lumina.DataAccess.Core.UoW; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Lumina.DataAccess.Common.Migrations +{ + [DbContext(typeof(LuminaDbContext))] + [Migration("20261021134714_AddsVuMeterSettingsToUserSettings")] + partial class AddsVuMeterSettingsToUserSettings + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "10.0.11"); + + modelBuilder.Entity("AlbumGenres", b => + { + b.Property("AlbumId") + .HasColumnType("TEXT"); + + b.Property("GenreId") + .HasColumnType("TEXT"); + + b.HasKey("AlbumId", "GenreId"); + + b.HasIndex("GenreId"); + + b.ToTable("AlbumGenres", (string)null); + }); + + modelBuilder.Entity("AlbumTags", b => + { + b.Property("AlbumId") + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("TEXT"); + + b.HasKey("AlbumId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("AlbumTags", (string)null); + }); + + modelBuilder.Entity("ArtistGenres", b => + { + b.Property("ArtistId") + .HasColumnType("TEXT"); + + b.Property("GenreId") + .HasColumnType("TEXT"); + + b.HasKey("ArtistId", "GenreId"); + + b.HasIndex("GenreId"); + + b.ToTable("ArtistGenres", (string)null); + }); + + modelBuilder.Entity("ArtistTags", b => + { + b.Property("ArtistId") + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("TEXT"); + + b.HasKey("ArtistId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("ArtistTags", (string)null); + }); + + modelBuilder.Entity("BookGenres", b => + { + b.Property("BookId") + .HasColumnType("TEXT"); + + b.Property("GenreId") + .HasColumnType("TEXT"); + + b.HasKey("BookId", "GenreId"); + + b.HasIndex("GenreId"); + + b.ToTable("BookGenres", (string)null); + }); + + modelBuilder.Entity("BookTags", b => + { + b.Property("BookId") + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("TEXT"); + + b.HasKey("BookId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("BookTags", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("PermissionName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.HasKey("Id"); + + b.ToTable("Permissions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.HasKey("Id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b => + { + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.Property("PermissionId") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("RoleId", "PermissionId"); + + b.HasIndex("PermissionId"); + + b.HasIndex("RoleId", "PermissionId") + .IsUnique(); + + b.ToTable("RolePermissions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("PermissionId") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("UserId", "PermissionId"); + + b.HasIndex("PermissionId"); + + b.HasIndex("UserId", "PermissionId") + .IsUnique(); + + b.ToTable("UserPermissions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("UserId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId", "RoleId") + .IsUnique(); + + b.ToTable("UserRoles", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b => + { + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Genres", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b => + { + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Tags", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaContributors.MediaContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Biography") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("DateOfBirth") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("DateOfDeath") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1) + .UseCollation("NOCASE"); + + b.Property("LegalName") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.HasKey("Id"); + + b.HasIndex("DisplayName") + .IsUnique(); + + b.ToTable("MediaContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("AlbumId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaContributorId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Role") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("MediaContributorId"); + + b.HasIndex("AlbumId", "MediaContributorId", "Role") + .IsUnique(); + + b.ToTable("AlbumContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ASIN") + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(28); + + b.Property("ArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Barcode") + .HasMaxLength(13) + .HasColumnType("TEXT") + .HasColumnOrder(25); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(33); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(32); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Disambiguation") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("Label") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(27); + + b.Property("LanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("LanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("LanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("LastMetadataUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(37); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MediaFormat") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(23); + + b.Property("MetadataProvider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(38); + + b.Property("MetadataStatus") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasDefaultValue("Pending") + .HasColumnOrder(36); + + b.Property("MusicBrainzReleaseArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(31); + + b.Property("MusicBrainzReleaseGroupId") + .HasColumnType("TEXT") + .HasColumnOrder(30); + + b.Property("MusicBrainzReleaseId") + .HasColumnType("TEXT") + .HasColumnOrder(29); + + b.Property("OriginalLanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("OriginalLanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(17); + + b.Property("OriginalLanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("OriginalReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("OriginalReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(8); + + b.Property("OriginalTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("Packaging") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(24); + + b.Property("ReReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("ReReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.Property("ReleaseCountry") + .HasMaxLength(2) + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("ReleaseStatus") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(20); + + b.Property("ReleaseTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(26); + + b.Property("ReleaseVersion") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("Script") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("TotalDiscs") + .HasColumnType("INTEGER") + .HasColumnOrder(21); + + b.Property("TotalTracks") + .HasColumnType("INTEGER") + .HasColumnOrder(22); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(35); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(34); + + b.HasKey("Id"); + + b.HasIndex("ArtistId", "Title"); + + b.HasIndex("LibraryId", "Title"); + + b.ToTable("Albums", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaContributorId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Role") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("MediaContributorId"); + + b.HasIndex("ArtistId", "MediaContributorId", "Role") + .IsUnique(); + + b.ToTable("ArtistContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Country") + .HasMaxLength(2) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("Disambiguation") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("Gender") + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("IsEnded") + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.Property("LastMetadataUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("LifeSpanBegin") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("LifeSpanEnd") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("MetadataProvider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("MetadataStatus") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasDefaultValue("Pending") + .HasColumnOrder(17); + + b.Property("MusicBrainzArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("SortName") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("Type") + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("Website") + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "Name") + .IsUnique(); + + b.ToTable("Artists", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicArtworkEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ArtworkType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("ContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("FileName") + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("LastUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("Ordinal") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("OwnerId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("OwnerType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Provider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.HasIndex("OwnerType", "OwnerId", "ArtworkType", "Ordinal") + .IsUnique(); + + b.ToTable("MusicArtwork", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicLibraryScanItemMetadataEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("AcoustId") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(25); + + b.Property("ArtistName") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("AudioCodec") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("BitDepth") + .HasColumnType("INTEGER") + .HasColumnOrder(14); + + b.Property("Bitrate") + .HasColumnType("INTEGER") + .HasColumnOrder(16); + + b.Property("Channels") + .HasColumnType("INTEGER") + .HasColumnOrder(13); + + b.Property("Container") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(31); + + b.Property("DiscNumber") + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.Property("DurationInSeconds") + .HasColumnType("INTEGER") + .HasColumnOrder(11); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("LibraryScanId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.PrimitiveCollection("Moods") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(30); + + b.Property("MusicBrainzArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(17); + + b.Property("MusicBrainzRecordingId") + .HasColumnType("TEXT") + .HasColumnOrder(21); + + b.Property("MusicBrainzReleaseArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("MusicBrainzReleaseGroupId") + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("MusicBrainzReleaseId") + .HasColumnType("TEXT") + .HasColumnOrder(20); + + b.Property("MusicBrainzTrackId") + .HasColumnType("TEXT") + .HasColumnOrder(22); + + b.Property("MusicBrainzWorkId") + .HasColumnType("TEXT") + .HasColumnOrder(23); + + b.Property("Path") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("ReleaseName") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("ReleaseType") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("ReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.Property("ReplayGainAlbumGain") + .HasColumnType("decimal(8,2)") + .HasColumnOrder(28); + + b.Property("ReplayGainAlbumPeak") + .HasColumnType("decimal(8,6)") + .HasColumnOrder(29); + + b.Property("ReplayGainTrackGain") + .HasColumnType("decimal(8,2)") + .HasColumnOrder(26); + + b.Property("ReplayGainTrackPeak") + .HasColumnType("decimal(8,6)") + .HasColumnOrder(27); + + b.Property("SampleRate") + .HasColumnType("INTEGER") + .HasColumnOrder(12); + + b.Property("TrackNumber") + .HasColumnType("INTEGER") + .HasColumnOrder(9); + + b.Property("TrackTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("WorkTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(24); + + b.HasKey("Id"); + + b.HasIndex("LibraryScanId", "Path") + .IsUnique(); + + b.ToTable("MusicLibraryScanItemMetadata", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicPlayRecordEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("AlbumId") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("ArtistId") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("EndedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("LastPositionMilliseconds") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("ListenedDurationMilliseconds") + .HasColumnType("INTEGER") + .HasColumnOrder(8); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("TrackId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Version") + .IsConcurrencyToken() + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.HasKey("Id"); + + b.HasIndex("TrackId"); + + b.HasIndex("UserId", "CreatedOnUtc"); + + b.ToTable("MusicPlayRecords", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaContributorId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Role") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("TrackId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("MediaContributorId"); + + b.HasIndex("TrackId", "MediaContributorId", "Role") + .IsUnique(); + + b.ToTable("TrackContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("AcoustId") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(44); + + b.Property("AlbumId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("AudioCodec") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(24); + + b.Property("BitDepth") + .HasColumnType("INTEGER") + .HasColumnOrder(23); + + b.Property("Bitrate") + .HasColumnType("INTEGER") + .HasColumnOrder(25); + + b.Property("Bpm") + .HasColumnType("INTEGER") + .HasColumnOrder(30); + + b.Property("Channels") + .HasColumnType("INTEGER") + .HasColumnOrder(22); + + b.Property("Container") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(49); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(38); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(37); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("Disambiguation") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("DiscNumber") + .HasColumnType("INTEGER") + .HasColumnOrder(27); + + b.Property("DurationInSeconds") + .HasColumnType("INTEGER") + .HasColumnOrder(20); + + b.Property("IsVideo") + .HasColumnType("INTEGER") + .HasColumnOrder(31); + + b.Property("Key") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(29); + + b.Property("LanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("LanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("LanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("LastMetadataUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(42); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MetadataProvider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(43); + + b.Property("MetadataStatus") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasDefaultValue("Pending") + .HasColumnOrder(41); + + b.Property("MusicBrainzRecordingId") + .HasColumnType("TEXT") + .HasColumnOrder(34); + + b.Property("MusicBrainzTrackId") + .HasColumnType("TEXT") + .HasColumnOrder(35); + + b.Property("MusicBrainzWorkId") + .HasColumnType("TEXT") + .HasColumnOrder(36); + + b.Property("OriginalLanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(17); + + b.Property("OriginalLanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("OriginalLanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("OriginalReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("OriginalReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(9); + + b.Property("OriginalTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Path") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("ReReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("ReReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(11); + + b.Property("ReleaseCountry") + .HasMaxLength(2) + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("ReleaseVersion") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("ReplayGainAlbumGain") + .HasColumnType("decimal(8,2)") + .HasColumnOrder(47); + + b.Property("ReplayGainAlbumPeak") + .HasColumnType("decimal(8,6)") + .HasColumnOrder(48); + + b.Property("ReplayGainTrackGain") + .HasColumnType("decimal(8,2)") + .HasColumnOrder(45); + + b.Property("ReplayGainTrackPeak") + .HasColumnType("decimal(8,6)") + .HasColumnOrder(46); + + b.Property("SampleRate") + .HasColumnType("INTEGER") + .HasColumnOrder(21); + + b.Property("Script") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(28); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("TrackNumber") + .HasColumnType("INTEGER") + .HasColumnOrder(26); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(40); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(39); + + b.Property("WorkTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(32); + + b.Property("WorkType") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(33); + + b.HasKey("Id"); + + b.HasIndex("AlbumId", "TrackNumber"); + + b.HasIndex("LibraryId", "Path") + .IsUnique(); + + b.ToTable("Tracks", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.DirectoryScanFingerprintEntity", b => + { + b.Property("LibraryId") + .HasColumnType("TEXT"); + + b.Property("Path") + .HasMaxLength(1024) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("LastWriteTimeUtc") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.HasKey("LibraryId", "Path"); + + b.HasIndex("LibraryId"); + + b.ToTable("DirectoryScanFingerprints", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ArtworkProvidersConfigurationFingerprint") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("CanDownloadMetadataFromWeb") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnOrder(6); + + b.Property("CoverImage") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("IsEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnOrder(4); + + b.Property("IsLocked") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("LibraryType") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MetadataProvidersConfigurationFingerprint") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("PathTemplateFingerprint") + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("ShouldSaveMetadataInMediaDirectories") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + + b.Property("ShouldSkipUnchangedDirectoriesDuringScan") + .HasColumnType("INTEGER") + .HasColumnOrder(8); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Libraries", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("LibraryId") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("LibraryId", "Status", "CreatedOnUtc") + .IsDescending(true, false, true); + + b.ToTable("LibraryScans", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b => + { + b.Property("LibraryScanId") + .HasColumnType("TEXT"); + + b.Property("Path") + .HasMaxLength(1024) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("ContentHash") + .HasMaxLength(24) + .HasColumnType("INTEGER") + .HasColumnOrder(2); + + b.Property("FileSize") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Status") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Ticks") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.HasKey("LibraryScanId", "Path"); + + b.HasIndex("Path"); + + b.HasIndex("ContentHash", "FileSize", "Path"); + + b.ToTable("LibraryScanResults", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanSnapshotEntity", b => + { + b.Property("LibraryId") + .HasColumnType("TEXT"); + + b.Property("Path") + .HasMaxLength(1024) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("ContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(2); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("FileSize") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Ticks") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.HasKey("LibraryId", "Path"); + + b.HasIndex("LibraryId"); + + b.ToTable("LibraryScanSnapshots", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanStagingResultsEntity", b => + { + b.Property("LibraryScanId") + .HasColumnType("TEXT"); + + b.Property("Path") + .HasMaxLength(1024) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("ContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("IsNew") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + + b.Property("NeedsRehash") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.Property("PreviousContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("Size") + .HasColumnType("INTEGER") + .HasColumnOrder(2); + + b.Property("Ticks") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.HasKey("LibraryScanId", "Path"); + + b.HasIndex("LibraryScanId", "NeedsRehash"); + + b.ToTable("LibraryScanStagingResults", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookArtworkEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ArtworkType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("BookId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("ContentHash") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("FileName") + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("LastUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("Ordinal") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("Provider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.HasIndex("BookId", "ArtworkType", "Ordinal") + .IsUnique(); + + b.ToTable("BookArtwork", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookContributorEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("BookId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("MediaContributorId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Role") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("MediaContributorId"); + + b.HasIndex("BookId", "MediaContributorId", "Role") + .IsUnique(); + + b.ToTable("BookContributors", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ASIN") + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnOrder(21); + + b.Property("AppleBooksId") + .HasColumnType("TEXT") + .HasColumnOrder(29); + + b.Property("BarnesAndNobleId") + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnOrder(28); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(33); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(32); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("Edition") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("Format") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("GoodreadsId") + .HasColumnType("TEXT") + .HasColumnOrder(22); + + b.Property("GoogleBooksId") + .HasMaxLength(12) + .HasColumnType("TEXT") + .HasColumnOrder(27); + + b.Property("LCCN") + .HasColumnType("TEXT") + .HasColumnOrder(23); + + b.Property("LanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("LanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("LanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("LastMetadataUpdateUtc") + .HasColumnType("TEXT") + .HasColumnOrder(39); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(36); + + b.Property("LibraryThingId") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(26); + + b.Property("MetadataProvider") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(40); + + b.Property("MetadataStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(38); + + b.Property("OCLCNumber") + .HasColumnType("TEXT") + .HasColumnOrder(24); + + b.Property("OpenLibraryId") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(25); + + b.Property("OriginalLanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("OriginalLanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("OriginalLanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("OriginalReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("OriginalReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("OriginalTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("PageCount") + .HasColumnType("INTEGER") + .HasColumnOrder(17); + + b.Property("Path") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("TEXT") + .HasColumnOrder(37); + + b.Property("Publisher") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("ReReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("ReReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + + b.Property("ReleaseCountry") + .HasMaxLength(2) + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("ReleaseVersion") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(35); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(34); + + b.Property("VolumeNumber") + .HasColumnType("REAL") + .HasColumnOrder(20); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "MetadataStatus"); + + b.HasIndex("LibraryId", "Path") + .IsUnique(); + + b.ToTable("Books", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("EntryCount") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0) + .HasColumnOrder(10); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Type") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0L) + .HasColumnOrder(9); + + b.HasKey("Id"); + + b.HasIndex("UserId", "UpdatedOnUtc"); + + b.ToTable("Playlists", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntryEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("MediaItemId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("MediaItemType") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("PlaylistId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Position") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.HasKey("Id"); + + b.HasIndex("MediaItemId"); + + b.HasIndex("PlaylistId", "Position") + .IsUnique(); + + b.ToTable("PlaylistEntries", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.LibraryArtworkProviderConfigurationEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("IsEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("PluginId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Rank") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "PluginId"); + + b.ToTable("LibraryArtworkProviderConfigurations", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.LibraryBookReaderConfigurationEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("IsEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("PluginId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "PluginId") + .IsUnique(); + + b.ToTable("LibraryBookReaderConfigurations", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.LibraryMetadataProviderConfigurationEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("IsEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("LibraryId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("PluginId") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("Rank") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.HasKey("Id"); + + b.HasIndex("LibraryId", "PluginId"); + + b.ToTable("LibraryMetadataProviderConfigurations", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.PluginEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Author") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("LoadError") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("LoadStatus") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("SettingsJson") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("Version") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("Id"); + + b.ToTable("Plugins", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Scheduling.ScheduledJobEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("Hour") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("IntervalMinutes") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("LastCompletedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("LastStartedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("Minute") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("OwnerUserId") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("ScheduleType") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("Status") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("TaskType") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.ToTable("ScheduledJobs", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Scheduling.ScheduledJobExecutionEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CompletedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("IsCycleRun") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("ScheduledJobId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("StartedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("TaskType") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("WasCycleActive") + .HasColumnType("INTEGER") + .HasColumnOrder(6); + + b.HasKey("Id"); + + b.HasIndex("ScheduledJobId"); + + b.HasIndex("StartedOnUtc", "ScheduledJobId"); + + b.ToTable("ScheduledJobExecutions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Scheduling.SchedulerDisplayPreferencesEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("DisplayTimeSpan") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("DisplayTimeUnit") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("JobTypeFilter") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("SchedulerDisplayPreferences", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Themes.ThemeEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("Author") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("Description") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("InstallSource") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("InstalledAtUtc") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("IsCurrent") + .HasColumnType("INTEGER") + .HasColumnOrder(8); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(false) + .HasColumnOrder(9); + + b.Property("Name") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("PreviewPath") + .HasMaxLength(240) + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("ThemeId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("Version") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.HasKey("Id"); + + b.HasIndex("IsCurrent") + .IsUnique() + .HasFilter("IsCurrent = 1"); + + b.HasIndex("ThemeId") + .IsUnique(); + + b.ToTable("Themes", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("TempPassword") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("TempPasswordCreated") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("TotpSecret") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("Username") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.HasKey("Id"); + + b.HasIndex("Username") + .IsUnique(); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserSettingsEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("IsGaplessPlaybackEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(16); + + b.Property("IsMuted") + .HasColumnType("INTEGER") + .HasColumnOrder(29); + + b.Property("IsPaginationEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(2); + + b.Property("IsThemeCachingEnabled") + .HasColumnType("INTEGER") + .HasColumnOrder(9); + + b.Property("ItemsPerPage") + .HasColumnType("INTEGER") + .HasColumnOrder(3); + + b.Property("ReplayGainMode") + .HasColumnType("INTEGER") + .HasColumnOrder(17); + + b.Property("ShouldAggregateArtworkWhenMissing") + .HasColumnType("INTEGER") + .HasColumnOrder(13); + + b.Property("ShouldAggregateMetadataWhenMissing") + .HasColumnType("INTEGER") + .HasColumnOrder(10); + + b.Property("ShouldAutoplay") + .HasColumnType("INTEGER") + .HasColumnOrder(15); + + b.Property("ShouldIgnoreThePrefixForAlphaPicker") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("ShouldKeepDownloadingWhilePaused") + .HasColumnType("INTEGER") + .HasColumnOrder(14); + + b.Property("ShouldPreserveBookStyles") + .HasColumnType("INTEGER") + .HasColumnOrder(12); + + b.Property("ShouldRenderPdfAsImages") + .HasColumnType("INTEGER") + .HasColumnOrder(11); + + b.Property("StreamingQuality") + .HasColumnType("INTEGER") + .HasColumnOrder(18); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("UserId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("Volume") + .HasColumnType("REAL") + .HasColumnOrder(28); + + b.Property("VuMeterHighThreshold") + .HasColumnType("REAL") + .HasColumnOrder(23); + + b.Property("VuMeterMediumThreshold") + .HasColumnType("REAL") + .HasColumnOrder(22); + + b.Property("VuMeterOrientation") + .HasColumnType("INTEGER") + .HasColumnOrder(19); + + b.Property("VuMeterPeakHoldDurationInMilliseconds") + .HasColumnType("INTEGER") + .HasColumnOrder(25); + + b.Property("VuMeterPeakReleasePerSecond") + .HasColumnType("REAL") + .HasColumnOrder(27); + + b.Property("VuMeterReleasePerSecond") + .HasColumnType("REAL") + .HasColumnOrder(26); + + b.Property("VuMeterSegmentCount") + .HasColumnType("INTEGER") + .HasColumnOrder(20); + + b.Property("VuMeterSegmentGap") + .HasColumnType("INTEGER") + .HasColumnOrder(21); + + b.Property("VuMeterShowPeak") + .HasColumnType("INTEGER") + .HasColumnOrder(24); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("UserSettings", (string)null); + }); + + modelBuilder.Entity("TrackGenres", b => + { + b.Property("TrackId") + .HasColumnType("TEXT"); + + b.Property("GenreId") + .HasColumnType("TEXT"); + + b.HasKey("TrackId", "GenreId"); + + b.HasIndex("GenreId"); + + b.ToTable("TrackGenres", (string)null); + }); + + modelBuilder.Entity("TrackTags", b => + { + b.Property("TrackId") + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("TEXT"); + + b.HasKey("TrackId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("TrackTags", (string)null); + }); + + modelBuilder.Entity("AlbumGenres", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", null) + .WithMany() + .HasForeignKey("AlbumId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null) + .WithMany() + .HasForeignKey("GenreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AlbumTags", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", null) + .WithMany() + .HasForeignKey("AlbumId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null) + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ArtistGenres", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", null) + .WithMany() + .HasForeignKey("ArtistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null) + .WithMany() + .HasForeignKey("GenreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ArtistTags", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", null) + .WithMany() + .HasForeignKey("ArtistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null) + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BookGenres", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany() + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null) + .WithMany() + .HasForeignKey("GenreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BookTags", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany() + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null) + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission") + .WithMany("RolePermissions") + .HasForeignKey("PermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role") + .WithMany("RolePermissions") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission") + .WithMany("UserPermissions") + .HasForeignKey("PermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithMany("UserPermissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithOne("UserRole") + .HasForeignKey("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", "UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumContributorEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", null) + .WithMany("Contributors") + .HasForeignKey("AlbumId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", "Artist") + .WithMany("Albums") + .HasForeignKey("ArtistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumCatalogNumberEntity", "CatalogNumbers", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("AlbumId") + .HasColumnType("TEXT"); + + b1.Property("CatalogNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("AlbumId"); + + b1.ToTable("AlbumCatalogNumbers", (string)null); + + b1.WithOwner() + .HasForeignKey("AlbumId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AudioRatingEntity", "Ratings", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("AlbumId") + .HasColumnType("TEXT"); + + b1.Property("MaxValue") + .HasColumnType("decimal(3,2)"); + + b1.Property("Source") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("Value") + .HasColumnType("decimal(3,2)"); + + b1.Property("VoteCount") + .HasColumnType("INTEGER"); + + b1.HasKey("Id"); + + b1.HasIndex("AlbumId"); + + b1.ToTable("AlbumRatings", (string)null); + + b1.WithOwner() + .HasForeignKey("AlbumId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumReleaseTypeEntity", "ReleaseTypes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("AlbumId") + .HasColumnType("TEXT"); + + b1.Property("ReleaseType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("AlbumId"); + + b1.ToTable("AlbumReleaseTypes", (string)null); + + b1.WithOwner() + .HasForeignKey("AlbumId"); + }); + + b.Navigation("Artist"); + + b.Navigation("CatalogNumbers"); + + b.Navigation("Ratings"); + + b.Navigation("ReleaseTypes"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistContributorEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", null) + .WithMany("Contributors") + .HasForeignKey("ArtistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", b => + { + b.OwnsOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicAreaEntity", "Area", b1 => + { + b1.Property("ArtistEntityId"); + + b1.Property("Disambiguation"); + + b1.Property("Iso3166Code"); + + b1.Property("MusicBrainzAreaId"); + + b1.Property("Name") + .IsRequired(); + + b1.Property("SortName"); + + b1.Property("Type"); + + b1.HasKey("ArtistEntityId"); + + b1.ToTable("Artists"); + + b1 + .ToJson("Area") + .HasColumnType("TEXT"); + + b1.WithOwner() + .HasForeignKey("ArtistEntityId"); + }); + + b.OwnsOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicAreaEntity", "BeginArea", b1 => + { + b1.Property("ArtistEntityId"); + + b1.Property("Disambiguation"); + + b1.Property("Iso3166Code"); + + b1.Property("MusicBrainzAreaId"); + + b1.Property("Name") + .IsRequired(); + + b1.Property("SortName"); + + b1.Property("Type"); + + b1.HasKey("ArtistEntityId"); + + b1.ToTable("Artists"); + + b1 + .ToJson("BeginArea") + .HasColumnType("TEXT"); + + b1.WithOwner() + .HasForeignKey("ArtistEntityId"); + }); + + b.OwnsOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicAreaEntity", "EndArea", b1 => + { + b1.Property("ArtistEntityId"); + + b1.Property("Disambiguation"); + + b1.Property("Iso3166Code"); + + b1.Property("MusicBrainzAreaId"); + + b1.Property("Name") + .IsRequired(); + + b1.Property("SortName"); + + b1.Property("Type"); + + b1.HasKey("ArtistEntityId"); + + b1.ToTable("Artists"); + + b1 + .ToJson("EndArea") + .HasColumnType("TEXT"); + + b1.WithOwner() + .HasForeignKey("ArtistEntityId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistAliasEntity", "Aliases", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("ArtistId") + .HasColumnType("TEXT"); + + b1.Property("BeginDate") + .HasColumnType("TEXT"); + + b1.Property("EndDate") + .HasColumnType("TEXT"); + + b1.Property("IsEnded") + .HasColumnType("INTEGER"); + + b1.Property("IsPrimary") + .HasColumnType("INTEGER"); + + b1.Property("Locale") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b1.Property("SortName") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b1.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("ArtistId"); + + b1.ToTable("ArtistAliases", (string)null); + + b1.WithOwner() + .HasForeignKey("ArtistId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AudioRatingEntity", "Ratings", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("ArtistId") + .HasColumnType("TEXT"); + + b1.Property("MaxValue") + .HasColumnType("decimal(3,2)"); + + b1.Property("Source") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("Value") + .HasColumnType("decimal(3,2)"); + + b1.Property("VoteCount") + .HasColumnType("INTEGER"); + + b1.HasKey("Id"); + + b1.HasIndex("ArtistId"); + + b1.ToTable("ArtistRatings", (string)null); + + b1.WithOwner() + .HasForeignKey("ArtistId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistIpiEntity", "Ipis", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("ArtistId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("ArtistId"); + + b1.ToTable("ArtistIpis", (string)null); + + b1.WithOwner() + .HasForeignKey("ArtistId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistIsniEntity", "Isnis", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("ArtistId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("ArtistId"); + + b1.ToTable("ArtistIsnis", (string)null); + + b1.WithOwner() + .HasForeignKey("ArtistId"); + }); + + b.Navigation("Aliases"); + + b.Navigation("Area"); + + b.Navigation("BeginArea"); + + b.Navigation("EndArea"); + + b.Navigation("Ipis"); + + b.Navigation("Isnis"); + + b.Navigation("Ratings"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackContributorEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", null) + .WithMany("Contributors") + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", "Album") + .WithMany("Tracks") + .HasForeignKey("AlbumId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AudioRatingEntity", "Ratings", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("MaxValue") + .HasColumnType("decimal(3,2)"); + + b1.Property("Source") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .HasColumnType("decimal(3,2)"); + + b1.Property("VoteCount") + .HasColumnType("INTEGER"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackRatings", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackIsrcEntity", "Isrcs", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(12) + .HasColumnType("TEXT") + .HasColumnName("ISRC"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackIsrcs", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackMoodEntity", "Moods", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackMoods", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackWorkIswcEntity", "WorkIswcs", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackWorkIswcs", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackWorkLanguageEntity", "WorkLanguages", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("LanguageCode") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("TEXT"); + + b1.Property("LanguageName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b1.Property("NativeName") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b1.Property("TrackId") + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("TrackId"); + + b1.ToTable("TrackWorkLanguages", (string)null); + + b1.WithOwner() + .HasForeignKey("TrackId"); + }); + + b.Navigation("Album"); + + b.Navigation("Isrcs"); + + b.Navigation("Moods"); + + b.Navigation("Ratings"); + + b.Navigation("WorkIswcs"); + + b.Navigation("WorkLanguages"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.DirectoryScanFingerprintEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", null) + .WithMany() + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithMany("Libraries") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryContentLocationEntity", "ContentLocations", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("LibraryId") + .HasColumnType("TEXT"); + + b1.Property("Path") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("TEXT") + .HasColumnName("Path"); + + b1.HasKey("Id"); + + b1.HasIndex("LibraryId"); + + b1.ToTable("LibraryContentLocations", (string)null); + + b1.WithOwner() + .HasForeignKey("LibraryId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryPathTemplatePartEntity", "PathTemplateParts", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("IsOptional") + .HasColumnType("INTEGER"); + + b1.Property("Kind") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b1.Property("LibraryId") + .HasColumnType("TEXT"); + + b1.Property("Position") + .HasColumnType("INTEGER") + .HasColumnName("Position"); + + b1.Property("Representation") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b1.HasKey("Id"); + + b1.HasIndex("LibraryId", "Position") + .IsUnique(); + + b1.ToTable("LibraryPathTemplateParts", (string)null); + + b1.WithOwner() + .HasForeignKey("LibraryId"); + }); + + b.Navigation("ContentLocations"); + + b.Navigation("PathTemplateParts"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", "Library") + .WithMany("LibraryScans") + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithMany("LibraryScans") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Library"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", "LibraryScan") + .WithMany("LibraryScanResults") + .HasForeignKey("LibraryScanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LibraryScan"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanSnapshotEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", "Library") + .WithMany() + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Library"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanStagingResultsEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", null) + .WithMany() + .HasForeignKey("LibraryScanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookArtworkEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany("Artwork") + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookContributorEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany("Contributors") + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b => + { + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookRatingEntity", "Ratings", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("BookId") + .HasColumnType("TEXT"); + + b1.Property("MaxValue") + .HasColumnType("decimal(3,2)"); + + b1.Property("Source") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("Value") + .HasColumnType("decimal(3,2)"); + + b1.Property("VoteCount") + .HasColumnType("INTEGER"); + + b1.HasKey("Id"); + + b1.HasIndex("BookId"); + + b1.ToTable("BookRatings", (string)null); + + b1.WithOwner() + .HasForeignKey("BookId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.IsbnEntity", "ISBNs", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("BookId") + .HasColumnType("TEXT"); + + b1.Property("Format") + .IsRequired() + .HasMaxLength(6) + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("TEXT") + .HasColumnName("ISBN"); + + b1.HasKey("Id"); + + b1.HasIndex("BookId"); + + b1.ToTable("BookISBNs", (string)null); + + b1.WithOwner() + .HasForeignKey("BookId"); + }); + + b.Navigation("ISBNs"); + + b.Navigation("Ratings"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntryEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntity", null) + .WithMany("Entries") + .HasForeignKey("PlaylistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserSettingsEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", null) + .WithOne() + .HasForeignKey("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserSettingsEntity", "UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("TrackGenres", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null) + .WithMany() + .HasForeignKey("GenreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", null) + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("TrackTags", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null) + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", null) + .WithMany() + .HasForeignKey("TrackId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b => + { + b.Navigation("RolePermissions"); + + b.Navigation("UserPermissions"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b => + { + b.Navigation("RolePermissions"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", b => + { + b.Navigation("Contributors"); + + b.Navigation("Tracks"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", b => + { + b.Navigation("Albums"); + + b.Navigation("Contributors"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", b => + { + b.Navigation("Contributors"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b => + { + b.Navigation("LibraryScans"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b => + { + b.Navigation("LibraryScanResults"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b => + { + b.Navigation("Artwork"); + + b.Navigation("Contributors"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Playlists.PlaylistEntity", b => + { + b.Navigation("Entries"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b => + { + b.Navigation("Libraries"); + + b.Navigation("LibraryScans"); + + b.Navigation("UserPermissions"); + + b.Navigation("UserRole"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Lumina.DataAccess/Common/Migrations/20261021134714_AddsVuMeterSettingsToUserSettings.cs b/src/Lumina.DataAccess/Common/Migrations/20261021134714_AddsVuMeterSettingsToUserSettings.cs new file mode 100644 index 00000000..08b32733 --- /dev/null +++ b/src/Lumina.DataAccess/Common/Migrations/20261021134714_AddsVuMeterSettingsToUserSettings.cs @@ -0,0 +1,166 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Lumina.DataAccess.Common.Migrations +{ + /// + public partial class AddsVuMeterSettingsToUserSettings : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Volume", + table: "UserSettings", + type: "REAL", + nullable: false, + oldClrType: typeof(double), + oldType: "REAL") + .Annotation("Relational:ColumnOrder", 28) + .OldAnnotation("Relational:ColumnOrder", 19); + + migrationBuilder.AlterColumn( + name: "IsMuted", + table: "UserSettings", + type: "INTEGER", + nullable: false, + oldClrType: typeof(bool), + oldType: "INTEGER") + .Annotation("Relational:ColumnOrder", 29) + .OldAnnotation("Relational:ColumnOrder", 20); + + migrationBuilder.AddColumn( + name: "VuMeterHighThreshold", + table: "UserSettings", + type: "REAL", + nullable: false, + defaultValue: 0.8) + .Annotation("Relational:ColumnOrder", 23); + + migrationBuilder.AddColumn( + name: "VuMeterMediumThreshold", + table: "UserSettings", + type: "REAL", + nullable: false, + defaultValue: 0.6) + .Annotation("Relational:ColumnOrder", 22); + + migrationBuilder.AddColumn( + name: "VuMeterOrientation", + table: "UserSettings", + type: "INTEGER", + nullable: false, + defaultValue: 0) + .Annotation("Relational:ColumnOrder", 19); + + migrationBuilder.AddColumn( + name: "VuMeterPeakHoldDurationInMilliseconds", + table: "UserSettings", + type: "INTEGER", + nullable: false, + defaultValue: 650) + .Annotation("Relational:ColumnOrder", 25); + + migrationBuilder.AddColumn( + name: "VuMeterPeakReleasePerSecond", + table: "UserSettings", + type: "REAL", + nullable: false, + defaultValue: 0.65) + .Annotation("Relational:ColumnOrder", 27); + + migrationBuilder.AddColumn( + name: "VuMeterReleasePerSecond", + table: "UserSettings", + type: "REAL", + nullable: false, + defaultValue: 3.0) + .Annotation("Relational:ColumnOrder", 26); + + migrationBuilder.AddColumn( + name: "VuMeterSegmentCount", + table: "UserSettings", + type: "INTEGER", + nullable: false, + defaultValue: 12) + .Annotation("Relational:ColumnOrder", 20); + + migrationBuilder.AddColumn( + name: "VuMeterSegmentGap", + table: "UserSettings", + type: "INTEGER", + nullable: false, + defaultValue: 1) + .Annotation("Relational:ColumnOrder", 21); + + migrationBuilder.AddColumn( + name: "VuMeterShowPeak", + table: "UserSettings", + type: "INTEGER", + nullable: false, + defaultValue: true) + .Annotation("Relational:ColumnOrder", 24); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "VuMeterHighThreshold", + table: "UserSettings"); + + migrationBuilder.DropColumn( + name: "VuMeterMediumThreshold", + table: "UserSettings"); + + migrationBuilder.DropColumn( + name: "VuMeterOrientation", + table: "UserSettings"); + + migrationBuilder.DropColumn( + name: "VuMeterPeakHoldDurationInMilliseconds", + table: "UserSettings"); + + migrationBuilder.DropColumn( + name: "VuMeterPeakReleasePerSecond", + table: "UserSettings"); + + migrationBuilder.DropColumn( + name: "VuMeterReleasePerSecond", + table: "UserSettings"); + + migrationBuilder.DropColumn( + name: "VuMeterSegmentCount", + table: "UserSettings"); + + migrationBuilder.DropColumn( + name: "VuMeterSegmentGap", + table: "UserSettings"); + + migrationBuilder.DropColumn( + name: "VuMeterShowPeak", + table: "UserSettings"); + + migrationBuilder.AlterColumn( + name: "Volume", + table: "UserSettings", + type: "REAL", + nullable: false, + oldClrType: typeof(double), + oldType: "REAL") + .Annotation("Relational:ColumnOrder", 19) + .OldAnnotation("Relational:ColumnOrder", 28); + + migrationBuilder.AlterColumn( + name: "IsMuted", + table: "UserSettings", + type: "INTEGER", + nullable: false, + oldClrType: typeof(bool), + oldType: "INTEGER") + .Annotation("Relational:ColumnOrder", 20) + .OldAnnotation("Relational:ColumnOrder", 29); + } + } +} diff --git a/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs b/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs index 77f187c1..07b59e53 100644 --- a/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs +++ b/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs @@ -2552,7 +2552,7 @@ namespace Lumina.DataAccess.Common.Migrations b.Property("IsMuted") .HasColumnType("INTEGER") - .HasColumnOrder(20); + .HasColumnOrder(29); b.Property("IsPaginationEnabled") .HasColumnType("INTEGER") @@ -2616,8 +2616,44 @@ namespace Lumina.DataAccess.Common.Migrations b.Property("Volume") .HasColumnType("REAL") + .HasColumnOrder(28); + + b.Property("VuMeterHighThreshold") + .HasColumnType("REAL") + .HasColumnOrder(23); + + b.Property("VuMeterMediumThreshold") + .HasColumnType("REAL") + .HasColumnOrder(22); + + b.Property("VuMeterOrientation") + .HasColumnType("INTEGER") .HasColumnOrder(19); + b.Property("VuMeterPeakHoldDurationInMilliseconds") + .HasColumnType("INTEGER") + .HasColumnOrder(25); + + b.Property("VuMeterPeakReleasePerSecond") + .HasColumnType("REAL") + .HasColumnOrder(27); + + b.Property("VuMeterReleasePerSecond") + .HasColumnType("REAL") + .HasColumnOrder(26); + + b.Property("VuMeterSegmentCount") + .HasColumnType("INTEGER") + .HasColumnOrder(20); + + b.Property("VuMeterSegmentGap") + .HasColumnType("INTEGER") + .HasColumnOrder(21); + + b.Property("VuMeterShowPeak") + .HasColumnType("INTEGER") + .HasColumnOrder(24); + b.HasKey("Id"); b.HasIndex("UserId") diff --git a/src/Lumina.Domain.SharedKernel/Common/Enums/Playback/VuMeterOrientation.cs b/src/Lumina.Domain.SharedKernel/Common/Enums/Playback/VuMeterOrientation.cs new file mode 100644 index 00000000..b696d75c --- /dev/null +++ b/src/Lumina.Domain.SharedKernel/Common/Enums/Playback/VuMeterOrientation.cs @@ -0,0 +1,18 @@ +namespace Lumina.Domain.SharedKernel.Common.Enums.Playback; + +/// +/// Enumeration for the direction in which each channel of the VU meter of the audio player grows. +/// +public enum VuMeterOrientation +{ + /// + /// The channels of the meter are columns and their levels grow from bottom to top. + /// + Vertical, + + /// + /// The channels of the meter are rows and their levels grow from left to right. + /// + Horizontal, +} + diff --git a/src/Lumina.Domain/Common/Errors/Errors.UserSettings.cs b/src/Lumina.Domain/Common/Errors/Errors.UserSettings.cs index 06219906..ae7a784f 100644 --- a/src/Lumina.Domain/Common/Errors/Errors.UserSettings.cs +++ b/src/Lumina.Domain/Common/Errors/Errors.UserSettings.cs @@ -24,5 +24,23 @@ public static partial class Errors public static Error StreamingQualityCannotBeNull => Error.Validation(description: nameof(StreamingQualityCannotBeNull)); public static Error InvalidReplayGainMode => Error.Validation(description: nameof(InvalidReplayGainMode)); public static Error InvalidStreamingQuality => Error.Validation(description: nameof(InvalidStreamingQuality)); + public static Error VuMeterOrientationCannotBeNull => Error.Validation(description: nameof(VuMeterOrientationCannotBeNull)); + public static Error InvalidVuMeterOrientation => Error.Validation(description: nameof(InvalidVuMeterOrientation)); + public static Error VuMeterSegmentCountCannotBeNull => Error.Validation(description: nameof(VuMeterSegmentCountCannotBeNull)); + public static Error VuMeterSegmentCountMustBeBetweenOneAndOneHundredTwentyEight => Error.Validation(description: nameof(VuMeterSegmentCountMustBeBetweenOneAndOneHundredTwentyEight)); + public static Error VuMeterSegmentGapCannotBeNull => Error.Validation(description: nameof(VuMeterSegmentGapCannotBeNull)); + public static Error VuMeterSegmentGapMustBeBetweenZeroAndThirtyTwo => Error.Validation(description: nameof(VuMeterSegmentGapMustBeBetweenZeroAndThirtyTwo)); + public static Error VuMeterMediumThresholdCannotBeNull => Error.Validation(description: nameof(VuMeterMediumThresholdCannotBeNull)); + public static Error VuMeterMediumThresholdMustBeBetweenZeroAndOne => Error.Validation(description: nameof(VuMeterMediumThresholdMustBeBetweenZeroAndOne)); + public static Error VuMeterHighThresholdCannotBeNull => Error.Validation(description: nameof(VuMeterHighThresholdCannotBeNull)); + public static Error VuMeterHighThresholdMustBeBetweenZeroAndOne => Error.Validation(description: nameof(VuMeterHighThresholdMustBeBetweenZeroAndOne)); + public static Error VuMeterHighThresholdMustBeGreaterThanOrEqualToMediumThreshold => Error.Validation(description: nameof(VuMeterHighThresholdMustBeGreaterThanOrEqualToMediumThreshold)); + public static Error VuMeterShowPeakCannotBeNull => Error.Validation(description: nameof(VuMeterShowPeakCannotBeNull)); + public static Error VuMeterPeakHoldDurationCannotBeNull => Error.Validation(description: nameof(VuMeterPeakHoldDurationCannotBeNull)); + public static Error VuMeterPeakHoldDurationMustBeBetweenZeroAndTenThousandMilliseconds => Error.Validation(description: nameof(VuMeterPeakHoldDurationMustBeBetweenZeroAndTenThousandMilliseconds)); + public static Error VuMeterReleasePerSecondCannotBeNull => Error.Validation(description: nameof(VuMeterReleasePerSecondCannotBeNull)); + public static Error VuMeterReleasePerSecondMustBeBetweenZeroAndOneHundred => Error.Validation(description: nameof(VuMeterReleasePerSecondMustBeBetweenZeroAndOneHundred)); + public static Error VuMeterPeakReleasePerSecondCannotBeNull => Error.Validation(description: nameof(VuMeterPeakReleasePerSecondCannotBeNull)); + public static Error VuMeterPeakReleasePerSecondMustBeBetweenZeroAndOneHundred => Error.Validation(description: nameof(VuMeterPeakReleasePerSecondMustBeBetweenZeroAndOneHundred)); } } diff --git a/src/Lumina.Domain/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettings.cs b/src/Lumina.Domain/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettings.cs index 5f151cf3..3e75c2e9 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettings.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettings.cs @@ -28,6 +28,15 @@ public class UserSettings : AggregateRoot private const bool DEFAULT_IS_GAPLESS_PLAYBACK_ENABLED = true; private const ReplayGainMode DEFAULT_REPLAY_GAIN_MODE = ReplayGainMode.Off; private const PlaybackStreamingQuality DEFAULT_STREAMING_QUALITY = PlaybackStreamingQuality.Auto; + private const VuMeterOrientation DEFAULT_VU_METER_ORIENTATION = VuMeterOrientation.Vertical; + private const int DEFAULT_VU_METER_SEGMENT_COUNT = 12; + private const int DEFAULT_VU_METER_SEGMENT_GAP = 1; + private const double DEFAULT_VU_METER_MEDIUM_THRESHOLD = 0.6; + private const double DEFAULT_VU_METER_HIGH_THRESHOLD = 0.8; + private const bool DEFAULT_VU_METER_SHOW_PEAK = true; + private const int DEFAULT_VU_METER_PEAK_HOLD_DURATION_IN_MILLISECONDS = 650; + private const double DEFAULT_VU_METER_RELEASE_PER_SECOND = 3.0; + private const double DEFAULT_VU_METER_PEAK_RELEASE_PER_SECOND = 0.65; private const double DEFAULT_VOLUME = 1.0; private const bool DEFAULT_IS_MUTED = false; @@ -104,6 +113,51 @@ public class UserSettings : AggregateRoot /// public PlaybackStreamingQuality StreamingQuality { get; private set; } + /// + /// Gets the direction in which each channel of the VU meter of the audio player grows. + /// + public VuMeterOrientation VuMeterOrientation { get; private set; } + + /// + /// Gets the number of segments each channel of the VU meter is divided into. + /// + public int VuMeterSegmentCount { get; private set; } + + /// + /// Gets the gap, in pixels, between the segments and the channels of the VU meter. + /// + public int VuMeterSegmentGap { get; private set; } + + /// + /// Gets the level, between 0 and 1, above which a segment of the VU meter is drawn with its medium state. + /// + public double VuMeterMediumThreshold { get; private set; } + + /// + /// Gets the level, between 0 and 1, above which a segment of the VU meter is drawn with its high state. + /// + public double VuMeterHighThreshold { get; private set; } + + /// + /// Gets whether the VU meter holds the peak level of each channel after it falls, or not. + /// + public bool VuMeterShowPeak { get; private set; } + + /// + /// Gets the time, in milliseconds, a peak of the VU meter is held before it starts falling. + /// + public int VuMeterPeakHoldDurationInMilliseconds { get; private set; } + + /// + /// Gets the number of level units the display of the VU meter falls per second when the input level drops. + /// + public double VuMeterReleasePerSecond { get; private set; } + + /// + /// Gets the number of level units the peak of the VU meter falls per second after its hold time elapsed. + /// + public double VuMeterPeakReleasePerSecond { get; private set; } + /// /// Gets the last volume the player reported for the user. It is written automatically by the player, and is not part of the settings the user edits. /// @@ -132,6 +186,15 @@ public class UserSettings : AggregateRoot /// Whether the player transitions between consecutive tracks without a gap, or not. /// The way ReplayGain normalization is applied to the tracks the user plays. /// The quality cap applied to the audio the server normalizes for the user. + /// The direction in which each channel of the VU meter of the audio player grows. + /// The number of segments each channel of the VU meter is divided into. + /// The gap, in pixels, between the segments and the channels of the VU meter. + /// The level above which a segment of the VU meter is drawn with its medium state. + /// The level above which a segment of the VU meter is drawn with its high state. + /// Whether the VU meter holds the peak level of each channel after it falls, or not. + /// The time a peak of the VU meter is held before it starts falling. + /// The number of level units the display of the VU meter falls per second when the input level drops. + /// The number of level units the peak of the VU meter falls per second after its hold time elapsed. /// The last volume the player reported for the user. /// The last mute state the player reported for the user. private UserSettings( @@ -150,6 +213,15 @@ public class UserSettings : AggregateRoot bool isGaplessPlaybackEnabled, ReplayGainMode replayGainMode, PlaybackStreamingQuality streamingQuality, + VuMeterOrientation vuMeterOrientation, + int vuMeterSegmentCount, + int vuMeterSegmentGap, + double vuMeterMediumThreshold, + double vuMeterHighThreshold, + bool vuMeterShowPeak, + int vuMeterPeakHoldDurationInMilliseconds, + double vuMeterReleasePerSecond, + double vuMeterPeakReleasePerSecond, double volume, bool isMuted) : base(id) { @@ -167,6 +239,15 @@ public class UserSettings : AggregateRoot IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled; ReplayGainMode = replayGainMode; StreamingQuality = streamingQuality; + VuMeterOrientation = vuMeterOrientation; + VuMeterSegmentCount = vuMeterSegmentCount; + VuMeterSegmentGap = vuMeterSegmentGap; + VuMeterMediumThreshold = vuMeterMediumThreshold; + VuMeterHighThreshold = vuMeterHighThreshold; + VuMeterShowPeak = vuMeterShowPeak; + VuMeterPeakHoldDurationInMilliseconds = vuMeterPeakHoldDurationInMilliseconds; + VuMeterReleasePerSecond = vuMeterReleasePerSecond; + VuMeterPeakReleasePerSecond = vuMeterPeakReleasePerSecond; Volume = volume; IsMuted = isMuted; } @@ -194,6 +275,15 @@ public class UserSettings : AggregateRoot DEFAULT_IS_GAPLESS_PLAYBACK_ENABLED, DEFAULT_REPLAY_GAIN_MODE, DEFAULT_STREAMING_QUALITY, + DEFAULT_VU_METER_ORIENTATION, + DEFAULT_VU_METER_SEGMENT_COUNT, + DEFAULT_VU_METER_SEGMENT_GAP, + DEFAULT_VU_METER_MEDIUM_THRESHOLD, + DEFAULT_VU_METER_HIGH_THRESHOLD, + DEFAULT_VU_METER_SHOW_PEAK, + DEFAULT_VU_METER_PEAK_HOLD_DURATION_IN_MILLISECONDS, + DEFAULT_VU_METER_RELEASE_PER_SECOND, + DEFAULT_VU_METER_PEAK_RELEASE_PER_SECOND, DEFAULT_VOLUME, DEFAULT_IS_MUTED ); @@ -223,6 +313,15 @@ public class UserSettings : AggregateRoot DEFAULT_IS_GAPLESS_PLAYBACK_ENABLED, DEFAULT_REPLAY_GAIN_MODE, DEFAULT_STREAMING_QUALITY, + DEFAULT_VU_METER_ORIENTATION, + DEFAULT_VU_METER_SEGMENT_COUNT, + DEFAULT_VU_METER_SEGMENT_GAP, + DEFAULT_VU_METER_MEDIUM_THRESHOLD, + DEFAULT_VU_METER_HIGH_THRESHOLD, + DEFAULT_VU_METER_SHOW_PEAK, + DEFAULT_VU_METER_PEAK_HOLD_DURATION_IN_MILLISECONDS, + DEFAULT_VU_METER_RELEASE_PER_SECOND, + DEFAULT_VU_METER_PEAK_RELEASE_PER_SECOND, DEFAULT_VOLUME, DEFAULT_IS_MUTED ); @@ -245,6 +344,15 @@ public class UserSettings : AggregateRoot /// Whether the player transitions between consecutive tracks without a gap, or not. /// The way ReplayGain normalization is applied to the tracks the user plays. /// The quality cap applied to the audio the server normalizes for the user. + /// The direction in which each channel of the VU meter of the audio player grows. + /// The number of segments each channel of the VU meter is divided into. + /// The gap, in pixels, between the segments and the channels of the VU meter. + /// The level above which a segment of the VU meter is drawn with its medium state. + /// The level above which a segment of the VU meter is drawn with its high state. + /// Whether the VU meter holds the peak level of each channel after it falls, or not. + /// The time a peak of the VU meter is held before it starts falling. + /// The number of level units the display of the VU meter falls per second when the input level drops. + /// The number of level units the peak of the VU meter falls per second after its hold time elapsed. /// The last volume the player reported for the user. /// The last mute state the player reported for the user. /// @@ -265,6 +373,15 @@ public class UserSettings : AggregateRoot bool isGaplessPlaybackEnabled, ReplayGainMode replayGainMode, PlaybackStreamingQuality streamingQuality, + VuMeterOrientation vuMeterOrientation, + int vuMeterSegmentCount, + int vuMeterSegmentGap, + double vuMeterMediumThreshold, + double vuMeterHighThreshold, + bool vuMeterShowPeak, + int vuMeterPeakHoldDurationInMilliseconds, + double vuMeterReleasePerSecond, + double vuMeterPeakReleasePerSecond, double volume, bool isMuted) { @@ -284,6 +401,15 @@ public class UserSettings : AggregateRoot isGaplessPlaybackEnabled, replayGainMode, streamingQuality, + vuMeterOrientation, + vuMeterSegmentCount, + vuMeterSegmentGap, + vuMeterMediumThreshold, + vuMeterHighThreshold, + vuMeterShowPeak, + vuMeterPeakHoldDurationInMilliseconds, + vuMeterReleasePerSecond, + vuMeterPeakReleasePerSecond, volume, isMuted); } @@ -306,6 +432,15 @@ public class UserSettings : AggregateRoot /// Whether the player transitions between consecutive tracks without a gap, or not. /// The way ReplayGain normalization is applied to the tracks the user plays. /// The quality cap applied to the audio the server normalizes for the user. + /// The direction in which each channel of the VU meter of the audio player grows. + /// The number of segments each channel of the VU meter is divided into. + /// The gap, in pixels, between the segments and the channels of the VU meter. + /// The level above which a segment of the VU meter is drawn with its medium state. + /// The level above which a segment of the VU meter is drawn with its high state. + /// Whether the VU meter holds the peak level of each channel after it falls, or not. + /// The time a peak of the VU meter is held before it starts falling. + /// The number of level units the display of the VU meter falls per second when the input level drops. + /// The number of level units the peak of the VU meter falls per second after its hold time elapsed. /// The last volume the player reported for the user. /// The last mute state the player reported for the user. /// @@ -327,10 +462,45 @@ public class UserSettings : AggregateRoot bool isGaplessPlaybackEnabled, ReplayGainMode replayGainMode, PlaybackStreamingQuality streamingQuality, + VuMeterOrientation vuMeterOrientation, + int vuMeterSegmentCount, + int vuMeterSegmentGap, + double vuMeterMediumThreshold, + double vuMeterHighThreshold, + bool vuMeterShowPeak, + int vuMeterPeakHoldDurationInMilliseconds, + double vuMeterReleasePerSecond, + double vuMeterPeakReleasePerSecond, double volume, bool isMuted) { - return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing, shouldAggregateArtworkWhenMissing, shouldRenderPdfAsImages, shouldPreserveBookStyles, shouldKeepDownloadingWhilePaused, shouldAutoplay, isGaplessPlaybackEnabled, replayGainMode, streamingQuality, volume, isMuted); + return new UserSettings( + id, + userId, + isPaginationEnabled, + itemsPerPage, + shouldIgnoreThePrefixForAlphaPicker, + isThemeCachingEnabled, + shouldAggregateMetadataWhenMissing, + shouldAggregateArtworkWhenMissing, + shouldRenderPdfAsImages, + shouldPreserveBookStyles, + shouldKeepDownloadingWhilePaused, + shouldAutoplay, + isGaplessPlaybackEnabled, + replayGainMode, + streamingQuality, + vuMeterOrientation, + vuMeterSegmentCount, + vuMeterSegmentGap, + vuMeterMediumThreshold, + vuMeterHighThreshold, + vuMeterShowPeak, + vuMeterPeakHoldDurationInMilliseconds, + vuMeterReleasePerSecond, + vuMeterPeakReleasePerSecond, + volume, + isMuted); } /// @@ -353,6 +523,15 @@ public class UserSettings : AggregateRoot /// Whether the player transitions between consecutive tracks without a gap, or not. /// The way ReplayGain normalization is applied to the tracks the user plays. /// The quality cap applied to the audio the server normalizes for the user. + /// The direction in which each channel of the VU meter of the audio player grows. + /// The number of segments each channel of the VU meter is divided into. + /// The gap, in pixels, between the segments and the channels of the VU meter. + /// The level above which a segment of the VU meter is drawn with its medium state. + /// The level above which a segment of the VU meter is drawn with its high state. + /// Whether the VU meter holds the peak level of each channel after it falls, or not. + /// The time a peak of the VU meter is held before it starts falling. + /// The number of level units the display of the VU meter falls per second when the input level drops. + /// The number of level units the peak of the VU meter falls per second after its hold time elapsed. /// An representing either a successful update, or an error. public Result UpdateSettings( bool isPaginationEnabled, @@ -367,7 +546,16 @@ public class UserSettings : AggregateRoot bool shouldAutoplay, bool isGaplessPlaybackEnabled, ReplayGainMode replayGainMode, - PlaybackStreamingQuality streamingQuality) + PlaybackStreamingQuality streamingQuality, + VuMeterOrientation vuMeterOrientation, + int vuMeterSegmentCount, + int vuMeterSegmentGap, + double vuMeterMediumThreshold, + double vuMeterHighThreshold, + bool vuMeterShowPeak, + int vuMeterPeakHoldDurationInMilliseconds, + double vuMeterReleasePerSecond, + double vuMeterPeakReleasePerSecond) { IsPaginationEnabled = isPaginationEnabled; ItemsPerPage = itemsPerPage; @@ -382,6 +570,15 @@ public class UserSettings : AggregateRoot IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled; ReplayGainMode = replayGainMode; StreamingQuality = streamingQuality; + VuMeterOrientation = vuMeterOrientation; + VuMeterSegmentCount = vuMeterSegmentCount; + VuMeterSegmentGap = vuMeterSegmentGap; + VuMeterMediumThreshold = vuMeterMediumThreshold; + VuMeterHighThreshold = vuMeterHighThreshold; + VuMeterShowPeak = vuMeterShowPeak; + VuMeterPeakHoldDurationInMilliseconds = vuMeterPeakHoldDurationInMilliseconds; + VuMeterReleasePerSecond = vuMeterReleasePerSecond; + VuMeterPeakReleasePerSecond = vuMeterPeakReleasePerSecond; return Result.Updated; } diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Settings/GetUserSettings/GetUserSettingsEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Settings/GetUserSettings/GetUserSettingsEndpointSummary.cs index 5be9415c..f5f65cb5 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Settings/GetUserSettings/GetUserSettingsEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/UsersManagement/Settings/GetUserSettings/GetUserSettingsEndpointSummary.cs @@ -22,6 +22,30 @@ public class GetUserSettingsEndpointSummary : Summary(r => r.UserId, "The unique identifier of the user that owns these settings."); + ResponseParam(r => r.IsPaginationEnabled, "Whether pagination is enabled for the user, or not."); + ResponseParam(r => r.ItemsPerPage, "The number of library items displayed per page when pagination is enabled."); + ResponseParam(r => r.ShouldIgnoreThePrefixForAlphaPicker, "Whether the \"The\" prefix of library item titles is ignored by the alpha picker, or not."); + ResponseParam(r => r.IsThemeCachingEnabled, "Whether the theme data served to this user is cached, or not."); + ResponseParam(r => r.ShouldAggregateMetadataWhenMissing, "Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not."); + ResponseParam(r => r.ShouldAggregateArtworkWhenMissing, "Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not."); + ResponseParam(r => r.ShouldRenderPdfAsImages, "Whether PDF books are rendered as page images for the user, or not."); + ResponseParam(r => r.ShouldPreserveBookStyles, "Whether the styles of the book content are preserved when it is rendered for the user, or not."); + ResponseParam(r => r.ShouldKeepDownloadingWhilePaused, "Whether the player keeps downloading a track while playback is paused, or not."); + ResponseParam(r => r.ShouldAutoplay, "Whether the player continues playback at the end of an album or artist, or not."); + ResponseParam(r => r.IsGaplessPlaybackEnabled, "Whether the player transitions between consecutive tracks without a gap, or not."); + ResponseParam(r => r.ReplayGainMode, "The way ReplayGain normalization is applied to the tracks the user plays."); + ResponseParam(r => r.StreamingQuality, "The quality cap applied to the audio the server normalizes for the user."); + ResponseParam(r => r.VuMeterOrientation, "The direction in which each channel of the VU meter of the audio player grows."); + ResponseParam(r => r.VuMeterSegmentCount, "The number of segments each channel of the VU meter is divided into."); + ResponseParam(r => r.VuMeterSegmentGap, "The gap, in pixels, between the segments and the channels of the VU meter."); + ResponseParam(r => r.VuMeterMediumThreshold, "The level, between 0 and 1, above which a segment of the VU meter is drawn with its medium state."); + ResponseParam(r => r.VuMeterHighThreshold, "The level, between 0 and 1, above which a segment of the VU meter is drawn with its high state."); + ResponseParam(r => r.VuMeterShowPeak, "Whether the VU meter holds the peak level of each channel after it falls, or not."); + ResponseParam(r => r.VuMeterPeakHoldDurationInMilliseconds, "The time, in milliseconds, a peak of the VU meter is held before it starts falling."); + ResponseParam(r => r.VuMeterReleasePerSecond, "The number of level units the display of the VU meter falls per second when the input level drops."); + ResponseParam(r => r.VuMeterPeakReleasePerSecond, "The number of level units the peak of the VU meter falls per second after its hold time elapsed."); + Response(200, "The settings of the current user are returned.", example: new UserSettingsResponse( UserId: Guid.NewGuid(), @@ -37,7 +61,16 @@ public class GetUserSettingsEndpointSummary : Summary r.IsPaginationEnabled, "Whether pagination is enabled for the user, or not. Required."); @@ -51,6 +60,15 @@ public class UpdateUserSettingsEndpointSummary : Summary r.IsGaplessPlaybackEnabled, "Whether the player transitions between consecutive tracks without a gap, or not. Required."); RequestParam(r => r.ReplayGainMode, "The way ReplayGain normalization is applied to the tracks the user plays. Required."); RequestParam(r => r.StreamingQuality, "The quality cap applied to the audio the server normalizes for the user. Required."); + RequestParam(r => r.VuMeterOrientation, "The direction in which each channel of the VU meter of the audio player grows. Required."); + RequestParam(r => r.VuMeterSegmentCount, "The number of segments each channel of the VU meter is divided into. Required."); + RequestParam(r => r.VuMeterSegmentGap, "The gap, in pixels, between the segments and the channels of the VU meter. Required."); + RequestParam(r => r.VuMeterMediumThreshold, "The level, between 0 and 1, above which a segment of the VU meter is drawn with its medium state. Required."); + RequestParam(r => r.VuMeterHighThreshold, "The level, between 0 and 1, above which a segment of the VU meter is drawn with its high state. Required."); + RequestParam(r => r.VuMeterShowPeak, "Whether the VU meter holds the peak level of each channel after it falls, or not. Required."); + RequestParam(r => r.VuMeterPeakHoldDurationInMilliseconds, "The time, in milliseconds, a peak of the VU meter is held before it starts falling. Required."); + RequestParam(r => r.VuMeterReleasePerSecond, "The number of level units the display of the VU meter falls per second when the input level drops. Required."); + RequestParam(r => r.VuMeterPeakReleasePerSecond, "The number of level units the peak of the VU meter falls per second after its hold time elapsed. Required."); Response(200, "The settings of the current user were successfully updated."); @@ -84,6 +102,18 @@ public class UpdateUserSettingsEndpointSummary : Summary public PlaybackStreamingQuality? StreamingQuality { get; set; } + + /// + /// Gets or sets the direction in which each channel of the VU meter of the audio player grows. + /// + public VuMeterOrientation? VuMeterOrientation { get; set; } = Enums.AudioLibrary.VuMeterOrientation.Vertical; + + /// + /// Gets or sets the number of segments each channel of the VU meter is divided into. + /// + public int? VuMeterSegmentCount { get; set; } = 12; + + /// + /// Gets or sets the gap, in pixels, between the segments and the channels of the VU meter. + /// + public int? VuMeterSegmentGap { get; set; } = 1; + + /// + /// Gets or sets the level, between 0 and 1, above which a segment of the VU meter is drawn with its medium state. + /// + public double? VuMeterMediumThreshold { get; set; } = 0.6; + + /// + /// Gets or sets the level, between 0 and 1, above which a segment of the VU meter is drawn with its high state. + /// + public double? VuMeterHighThreshold { get; set; } = 0.8; + + /// + /// Gets or sets whether the VU meter holds the peak level of each channel after it falls, or not. + /// + public bool? VuMeterShowPeak { get; set; } = true; + + /// + /// Gets or sets the time, in milliseconds, a peak of the VU meter is held before it starts falling. + /// + public int? VuMeterPeakHoldDurationInMilliseconds { get; set; } = 650; + + /// + /// Gets or sets the number of level units the display of the VU meter falls per second when the input level drops. + /// + public double? VuMeterReleasePerSecond { get; set; } = 3.0; + + /// + /// Gets or sets the number of level units the peak of the VU meter falls per second after its hold time elapsed. + /// + public double? VuMeterPeakReleasePerSecond { get; set; } = 0.65; } diff --git a/src/Lumina.Presentation.Web/Common/Enums/AudioLibrary/VuMeterOrientation.cs b/src/Lumina.Presentation.Web/Common/Enums/AudioLibrary/VuMeterOrientation.cs new file mode 100644 index 00000000..118a8c91 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/AudioLibrary/VuMeterOrientation.cs @@ -0,0 +1,22 @@ +#region ========================================================================= USING ===================================================================================== +using System.Diagnostics; +#endregion + +namespace Lumina.Presentation.Web.Common.Enums.AudioLibrary; + +/// +/// Enumeration for the direction in which each channel of the VU meter of the audio player grows. +/// +[DebuggerDisplay("{ToString()}")] +public enum VuMeterOrientation +{ + /// + /// The channels of the meter are columns and their levels grow from bottom to top. + /// + Vertical, + + /// + /// The channels of the meter are rows and their levels grow from left to right. + /// + Horizontal, +} diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ar-SA.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ar-SA.resx index 9507368f..60097377 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ar-SA.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ar-SA.resx @@ -849,4 +849,58 @@ يجب ألا يتجاوز عدد المقطوعات العشوائية 500! + + لا يمكن أن يكون انخفاض مقياس VU فارغًا! + + + لا يمكن أن يكون عدد مقاطع مقياس VU فارغًا! + + + يجب أن يكون انخفاض مقياس VU بين 0 و100 في الثانية! + + + يجب أن تكون مدة تثبيت القمم لمقياس VU بين 0 و10000 مللي ثانية! + + + اتجاه مقياس VU غير صالح! + + + يجب أن يكون عدد مقاطع مقياس VU بين 1 و128! + + + لا يمكن أن يكون تفضيل عرض القمم لمقياس VU فارغًا! + + + يجب أن تكون العتبة المتوسطة لمقياس VU بين 0 و1! + + + يجب أن يكون انخفاض القمم لمقياس VU بين 0 و100 في الثانية! + + + لا يمكن أن تكون المسافة بين مقاطع مقياس VU فارغة! + + + يجب أن تكون المسافة بين مقاطع مقياس VU بين 0 و32! + + + لا يمكن أن تكون مدة تثبيت القمم لمقياس VU فارغة! + + + لا يمكن أن تكون اتجاهات مقياس VU فارغة! + + + لا يمكن أن تكون العتبة المتوسطة لمقياس VU فارغة! + + + يجب أن تكون العتبة العالية لمقياس VU بين 0 و1! + + + لا يمكن أن يكون انخفاض القمم لمقياس VU فارغًا! + + + يجب أن تكون العتبة العالية لمقياس VU أكبر من أو تساوي العتبة المتوسطة! + + + لا يمكن أن تكون العتبة العالية لمقياس VU فارغة! + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.de-DE.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.de-DE.resx index 75c5e379..6a305a61 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.de-DE.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.de-DE.resx @@ -849,4 +849,58 @@ Die Anzahl der Shuffle-Titel darf höchstens 500 betragen! + + Der Rückgang des VU-Meters darf nicht null sein! + + + Die Segmentanzahl des VU-Meters darf nicht null sein! + + + Der Rückgang des VU-Meters muss zwischen 0 und 100 pro Sekunde liegen! + + + Die Haltedauer der Spitzenwerte des VU-Meters muss zwischen 0 und 10000 Millisekunden liegen! + + + Ungültige Ausrichtung des VU-Meters! + + + Die Segmentanzahl des VU-Meters muss zwischen 1 und 128 liegen! + + + Die Einstellung zum Anzeigen der Spitzenwerte des VU-Meters darf nicht null sein! + + + Der mittlere Schwellenwert des VU-Meters muss zwischen 0 und 1 liegen! + + + Der Rückgang der Spitzenwerte des VU-Meters muss zwischen 0 und 100 pro Sekunde liegen! + + + Der Segmentabstand des VU-Meters darf nicht null sein! + + + Der Segmentabstand des VU-Meters muss zwischen 0 und 32 liegen! + + + Die Haltedauer der Spitzenwerte des VU-Meters darf nicht null sein! + + + Die Ausrichtung des VU-Meters darf nicht null sein! + + + Der mittlere Schwellenwert des VU-Meters darf nicht null sein! + + + Der hohe Schwellenwert des VU-Meters muss zwischen 0 und 1 liegen! + + + Der Rückgang der Spitzenwerte des VU-Meters darf nicht null sein! + + + Der hohe Schwellenwert des VU-Meters muss größer oder gleich dem mittleren Schwellenwert sein! + + + Der hohe Schwellenwert des VU-Meters darf nicht null sein! + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.en-US.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.en-US.resx index a44449dd..d383f42d 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.en-US.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.en-US.resx @@ -849,4 +849,58 @@ The shuffle track count must be at most 500! + + The VU meter release cannot be null! + + + The VU meter segment count cannot be null! + + + The VU meter release must be between 0 and 100 per second! + + + The VU meter peak hold duration must be between 0 and 10000 milliseconds! + + + Invalid VU meter orientation! + + + The VU meter segment count must be between 1 and 128! + + + The VU meter show peak preference cannot be null! + + + The VU meter medium threshold must be between 0 and 1! + + + The VU meter peak release must be between 0 and 100 per second! + + + The VU meter segment gap cannot be null! + + + The VU meter segment gap must be between 0 and 32! + + + The VU meter peak hold duration cannot be null! + + + The VU meter orientation cannot be null! + + + The VU meter medium threshold cannot be null! + + + The VU meter high threshold must be between 0 and 1! + + + The VU meter peak release cannot be null! + + + The VU meter high threshold must be greater than or equal to the medium threshold! + + + The VU meter high threshold cannot be null! + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.es-ES.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.es-ES.resx index c75cb36a..8aea5c77 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.es-ES.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.es-ES.resx @@ -849,4 +849,58 @@ ¡La cantidad de pistas de reproducción aleatoria no debe superar 500! + + La caída del vúmetro no puede ser nula. + + + El número de segmentos del vúmetro no puede ser nulo. + + + La caída del vúmetro debe estar entre 0 y 100 por segundo. + + + La duración de retención de los picos del vúmetro debe estar entre 0 y 10000 milisegundos. + + + ¡Orientación del vúmetro no válida! + + + El número de segmentos del vúmetro debe estar entre 1 y 128. + + + La preferencia de mostrar los picos del vúmetro no puede ser nula. + + + El umbral medio del vúmetro debe estar entre 0 y 1. + + + La caída de los picos del vúmetro debe estar entre 0 y 100 por segundo. + + + La separación de los segmentos del vúmetro no puede ser nula. + + + La separación de los segmentos del vúmetro debe estar entre 0 y 32. + + + La duración de retención de los picos del vúmetro no puede ser nula. + + + La orientación del vúmetro no puede ser nula. + + + El umbral medio del vúmetro no puede ser nulo. + + + El umbral alto del vúmetro debe estar entre 0 y 1. + + + La caída de los picos del vúmetro no puede ser nula. + + + El umbral alto del vúmetro debe ser mayor o igual que el umbral medio. + + + El umbral alto del vúmetro no puede ser nulo. + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.fr-FR.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.fr-FR.resx index 3667444c..c5e03b35 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.fr-FR.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.fr-FR.resx @@ -849,4 +849,58 @@ Le nombre de pistes du shuffle ne doit pas dépasser 500 ! + + La décroissance du vumètre ne peut pas être nulle ! + + + Le nombre de segments du vumètre ne peut pas être nul ! + + + La décroissance du vumètre doit être comprise entre 0 et 100 par seconde ! + + + La durée de maintien des crêtes du vumètre doit être comprise entre 0 et 10000 millisecondes ! + + + Orientation du vumètre non valide ! + + + Le nombre de segments du vumètre doit être compris entre 1 et 128 ! + + + La préférence d'affichage des crêtes du vumètre ne peut pas être nulle ! + + + Le seuil moyen du vumètre doit être compris entre 0 et 1 ! + + + La décroissance des crêtes du vumètre doit être comprise entre 0 et 100 par seconde ! + + + L'espacement des segments du vumètre ne peut pas être nul ! + + + L'espacement des segments du vumètre doit être compris entre 0 et 32 ! + + + La durée de maintien des crêtes du vumètre ne peut pas être nulle ! + + + L'orientation du vumètre ne peut pas être nulle ! + + + Le seuil moyen du vumètre ne peut pas être nul ! + + + Le seuil élevé du vumètre doit être compris entre 0 et 1 ! + + + La décroissance des crêtes du vumètre ne peut pas être nulle ! + + + Le seuil élevé du vumètre doit être supérieur ou égal au seuil moyen ! + + + Le seuil élevé du vumètre ne peut pas être nul ! + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.it-IT.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.it-IT.resx index 304bb6e9..7def4889 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.it-IT.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.it-IT.resx @@ -849,4 +849,58 @@ Il numero di brani dello shuffle non può superare 500! + + La caduta del vumetro non può essere nulla. + + + Il numero di segmenti del vumetro non può essere nullo. + + + La caduta del vumetro deve essere compresa tra 0 e 100 al secondo. + + + La durata di mantenimento dei picchi del vumetro deve essere compresa tra 0 e 10000 millisecondi. + + + Orientamento del vumetro non valido! + + + Il numero di segmenti del vumetro deve essere compreso tra 1 e 128. + + + La preferenza di mostrare i picchi del vumetro non può essere nulla. + + + La soglia media del vumetro deve essere compresa tra 0 e 1. + + + La caduta dei picchi del vumetro deve essere compresa tra 0 e 100 al secondo. + + + La spaziatura dei segmenti del vumetro non può essere nulla. + + + La spaziatura dei segmenti del vumetro deve essere compresa tra 0 e 32. + + + La durata di mantenimento dei picchi del vumetro non può essere nulla. + + + L'orientamento del vumetro non può essere nullo. + + + La soglia media del vumetro non può essere nulla. + + + La soglia alta del vumetro deve essere compresa tra 0 e 1. + + + La caduta dei picchi del vumetro non può essere nulla. + + + La soglia alta del vumetro deve essere maggiore o uguale alla soglia media. + + + La soglia alta del vumetro non può essere nulla. + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ja-JP.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ja-JP.resx index cf3b999d..c1a9a453 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ja-JP.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ja-JP.resx @@ -849,4 +849,58 @@ シャッフルするトラック数は 500 以下である必要があります。 + + VUメーターの減衰はnullにできません。 + + + VUメーターのセグメント数はnullにできません。 + + + VUメーターの減衰は毎秒0から100の間である必要があります。 + + + VUメーターのピーク保持時間は0から10000ミリ秒の間である必要があります。 + + + VUメーターの向きが無効です。 + + + VUメーターのセグメント数は1から128の間である必要があります。 + + + VUメーターのピーク表示設定はnullにできません。 + + + VUメーターの中間しきい値は0から1の間である必要があります。 + + + VUメーターのピーク減衰は毎秒0から100の間である必要があります。 + + + VUメーターのセグメント間隔はnullにできません。 + + + VUメーターのセグメント間隔は0から32の間である必要があります。 + + + VUメーターのピーク保持時間はnullにできません。 + + + VUメーターの向きはnullにできません。 + + + VUメーターの中間しきい値はnullにできません。 + + + VUメーターの高いしきい値は0から1の間である必要があります。 + + + VUメーターのピーク減衰はnullにできません。 + + + VUメーターの高いしきい値は中間しきい値以上である必要があります。 + + + VUメーターの高いしきい値はnullにできません。 + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.resx index f993b119..bda7bec0 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.resx @@ -849,4 +849,58 @@ The shuffle track count must be at most 500! + + The VU meter release cannot be null! + + + The VU meter segment count cannot be null! + + + The VU meter release must be between 0 and 100 per second! + + + The VU meter peak hold duration must be between 0 and 10000 milliseconds! + + + Invalid VU meter orientation! + + + The VU meter segment count must be between 1 and 128! + + + The VU meter show peak preference cannot be null! + + + The VU meter medium threshold must be between 0 and 1! + + + The VU meter peak release must be between 0 and 100 per second! + + + The VU meter segment gap cannot be null! + + + The VU meter segment gap must be between 0 and 32! + + + The VU meter peak hold duration cannot be null! + + + The VU meter orientation cannot be null! + + + The VU meter medium threshold cannot be null! + + + The VU meter high threshold must be between 0 and 1! + + + The VU meter peak release cannot be null! + + + The VU meter high threshold must be greater than or equal to the medium threshold! + + + The VU meter high threshold cannot be null! + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ro-RO.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ro-RO.resx index e097d831..553ea829 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ro-RO.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.ro-RO.resx @@ -849,4 +849,58 @@ Numărul de piste pentru redare aleatorie nu poate depăși 500! + + Scăderea vumetrului nu poate fi nulă! + + + Numărul de segmente al vumetrului nu poate fi nul! + + + Scăderea vumetrului trebuie să fie între 0 și 100 pe secundă! + + + Durata de menținere a vârfurilor vumetrului trebuie să fie între 0 și 10000 de milisecunde! + + + Orientare nevalidă a vumetrului! + + + Numărul de segmente al vumetrului trebuie să fie între 1 și 128! + + + Preferința de afișare a vârfurilor vumetrului nu poate fi nulă! + + + Pragul mediu al vumetrului trebuie să fie între 0 și 1! + + + Scăderea vârfurilor vumetrului trebuie să fie între 0 și 100 pe secundă! + + + Spațiul dintre segmentele vumetrului nu poate fi nul! + + + Spațiul dintre segmentele vumetrului trebuie să fie între 0 și 32! + + + Durata de menținere a vârfurilor vumetrului nu poate fi nulă! + + + Orientarea vumetrului nu poate fi nulă! + + + Pragul mediu al vumetrului nu poate fi nul! + + + Pragul ridicat al vumetrului trebuie să fie între 0 și 1! + + + Scăderea vârfurilor vumetrului nu poate fi nulă! + + + Pragul ridicat al vumetrului trebuie să fie mai mare sau egal cu pragul mediu! + + + Pragul ridicat al vumetrului nu poate fi nul! + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.uk-UA.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.uk-UA.resx index 0a2027c5..b42fb8fb 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.uk-UA.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.uk-UA.resx @@ -849,4 +849,58 @@ Кількість треків для перемішування не може перевищувати 500! + + Спад VU-метра не може бути порожнім! + + + Кількість сегментів VU-метра не може бути порожньою! + + + Спад VU-метра має бути від 0 до 100 за секунду! + + + Тривалість утримання піків VU-метра має бути від 0 до 10000 мілісекунд! + + + Недійсна орієнтація VU-метра! + + + Кількість сегментів VU-метра має бути від 1 до 128! + + + Налаштування показу піків VU-метра не може бути порожнім! + + + Середній поріг VU-метра має бути від 0 до 1! + + + Спад піків VU-метра має бути від 0 до 100 за секунду! + + + Проміжок між сегментами VU-метра не може бути порожнім! + + + Проміжок між сегментами VU-метра має бути від 0 до 32! + + + Тривалість утримання піків VU-метра не може бути порожньою! + + + Орієнтація VU-метра не може бути порожньою! + + + Середній поріг VU-метра не може бути порожнім! + + + Високий поріг VU-метра має бути від 0 до 1! + + + Спад піків VU-метра не може бути порожнім! + + + Високий поріг VU-метра має бути більшим або дорівнювати середньому порогу! + + + Високий поріг VU-метра не може бути порожнім! + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.zh-CN.resx b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.zh-CN.resx index ba17cabc..0283eb88 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.zh-CN.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Common/Middlewares/ExceptionHandlingMiddleware.zh-CN.resx @@ -849,4 +849,58 @@ 随机播放曲目数不能超过 500! + + VU 表的衰落速度不能为空! + + + VU 表的段数不能为空! + + + VU 表的衰落速度必须介于每秒 0 到 100 之间! + + + VU 表的峰值保持时间必须在 0 到 10000 毫秒之间! + + + VU 表的方向无效! + + + VU 表的段数必须在 1 到 128 之间! + + + VU 表的峰值显示首选项不能为空! + + + VU 表的中等阈值必须在 0 到 1 之间! + + + VU 表的峰值衰落速度必须介于每秒 0 到 100 之间! + + + VU 表的段间距不能为空! + + + VU 表的段间距必须在 0 到 32 之间! + + + VU 表的峰值保持时间不能为空! + + + VU 表的方向不能为空! + + + VU 表的中等阈值不能为空! + + + VU 表的高阈值必须在 0 到 1 之间! + + + VU 表的峰值衰落速度不能为空! + + + VU 表的高阈值必须大于或等于中等阈值! + + + VU 表的高阈值不能为空! + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ar-SA.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ar-SA.resx index a506eef3..11d5e739 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ar-SA.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ar-SA.resx @@ -123,4 +123,67 @@ عالية (320 kbps) + + عدد المقاطع التي تنقسم إليها كل قناة من مقياس VU، بين 1 و128. + + + انخفاض القمم + + + المستوى بين 0 و1 الذي يُرسم فوقه المقطع بالحالة العالية. يجب أن يكون على الأقل مساويًا للعتبة المتوسطة. + + + ما إذا كانت قنوات مقياس VU تنمو من الأسفل إلى الأعلى أو من اليسار إلى اليمين. + + + المستوى بين 0 و1 الذي يُرسم فوقه المقطع بالحالة المتوسطة. + + + عمودي + + + انخفاض المستوى + + + أفقي + + + الاتجاه + + + العتبة العالية + + + المقاطع لكل قناة + + + العتبة المتوسطة + + + مقياس VU + + + تثبيت القمم (مللي ثانية) + + + ما إذا كانت كل قناة تحتفظ بعلامة عند أعلى مستوى حديث لها. + + + عدد وحدات المستوى التي تنخفضها علامة القمة في الثانية بعد مدة تثبيتها، بين 0 و100. القيم الأعلى تنخفض أسرع. + + + مدة تثبيت علامة القمة بالمللي ثانية قبل أن تبدأ في الانخفاض، بين 0 و10000. + + + إظهار القمم + + + المسافة بالبكسل بين مقاطع مقياس VU وقنواته، بين 0 و32. + + + المسافة بين المقاطع + + + عدد وحدات المستوى التي تنخفضها القناة في الثانية بعد انخفاض الصوت، بين 0 و100. القيم الأعلى تنخفض أسرع. + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.de-DE.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.de-DE.resx index e3767eb2..5b1753b0 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.de-DE.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.de-DE.resx @@ -123,4 +123,67 @@ Hoch (320 kbit/s) + + In wie viele Segmente jeder Kanal des VU-Meters unterteilt wird, zwischen 1 und 128. + + + Rückgang der Spitzenwerte + + + Der Pegel zwischen 0 und 1, ab dem ein Segment mit dem hohen Zustand gezeichnet wird. Er muss mindestens dem mittleren Schwellenwert entsprechen. + + + Ob die Kanäle des VU-Meters von unten nach oben oder von links nach rechts wachsen. + + + Der Pegel zwischen 0 und 1, ab dem ein Segment mit dem mittleren Zustand gezeichnet wird. + + + Vertikal + + + Pegelrückgang + + + Horizontal + + + Ausrichtung + + + Hoher Schwellenwert + + + Segmente pro Kanal + + + Mittlerer Schwellenwert + + + VU-Meter + + + Spitzenwert halten (ms) + + + Ob jeder Kanal eine Markierung bei seinem lautesten letzten Pegel behält. + + + Wie viele Pegel-Einheiten eine Spitzenmarkierung pro Sekunde nach ihrer Haltezeit fällt, zwischen 0 und 100. Höhere Werte fallen schneller. + + + Wie lange eine Spitzenmarkierung in Millisekunden gehalten wird, bevor sie zu fallen beginnt, zwischen 0 und 10000. + + + Spitzenwerte anzeigen + + + Der Abstand in Pixeln zwischen den Segmenten und den Kanälen des VU-Meters, zwischen 0 und 32. + + + Segmentabstand + + + Wie viele Pegel-Einheiten ein Kanal pro Sekunde nach dem Abklingen des Tons fällt, zwischen 0 und 100. Höhere Werte fallen schneller. + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.en-US.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.en-US.resx index 27a71a6f..d08f5f21 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.en-US.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.en-US.resx @@ -123,4 +123,67 @@ High (320 kbps) + + How many segments each channel of the VU meter is divided into, between 1 and 128. + + + Peak falloff + + + The level, between 0 and 1, above which a segment is drawn with the high state. It must be at least the medium threshold. + + + Whether the channels of the VU meter grow upwards from the bottom, or rightwards from the left. + + + The level, between 0 and 1, above which a segment is drawn with the medium state. + + + Vertical + + + Level falloff + + + Horizontal + + + Orientation + + + High threshold + + + Segments per channel + + + Medium threshold + + + VU meter + + + Peak hold (ms) + + + Whether each channel holds a mark at its loudest recent level. + + + How many level units a peak mark falls per second after its hold time, between 0 and 100. Higher values fall faster. + + + How long, in milliseconds, a peak mark is held before it starts falling, between 0 and 10000. + + + Show peak + + + The gap, in pixels, between the segments and the channels of the VU meter, between 0 and 32. + + + Segment gap + + + How many level units a channel falls per second after the sound drops, between 0 and 100. Higher values fall faster. + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.es-ES.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.es-ES.resx index c4ad3366..0a8d4f18 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.es-ES.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.es-ES.resx @@ -123,4 +123,67 @@ Alta (320 kbps) + + En cuántos segmentos se divide cada canal del vúmetro, entre 1 y 128. + + + Caída de los picos + + + El nivel, entre 0 y 1, por encima del cual un segmento se dibuja con el estado alto. Debe ser al menos el umbral medio. + + + Indica si los canales del vúmetro crecen de abajo hacia arriba o de izquierda a derecha. + + + El nivel, entre 0 y 1, por encima del cual un segmento se dibuja con el estado medio. + + + Vertical + + + Caída del nivel + + + Horizontal + + + Orientación + + + Umbral alto + + + Segmentos por canal + + + Umbral medio + + + Vúmetro + + + Retención de picos (ms) + + + Indica si cada canal mantiene una marca en su nivel reciente más alto. + + + Cuántas unidades de nivel cae una marca de pico por segundo después de su tiempo de retención, entre 0 y 100. Los valores más altos caen más rápido. + + + Cuánto tiempo, en milisegundos, se mantiene una marca de pico antes de empezar a caer, entre 0 y 10000. + + + Mostrar picos + + + La separación, en píxeles, entre los segmentos y los canales del vúmetro, entre 0 y 32. + + + Separación de segmentos + + + Cuántas unidades de nivel cae un canal por segundo después de que el sonido baje, entre 0 y 100. Los valores más altos caen más rápido. + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.fr-FR.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.fr-FR.resx index 5b327b98..ee9c853a 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.fr-FR.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.fr-FR.resx @@ -123,4 +123,67 @@ Élevée (320 kbit/s) + + Le nombre de segments dans lesquels chaque canal du vumètre est divisé, entre 1 et 128. + + + Décroissance des crêtes + + + Le niveau, entre 0 et 1, au-dessus duquel un segment est dessiné avec l'état élevé. Il doit être au moins égal au seuil moyen. + + + Indique si les canaux du vumètre croissent du bas vers le haut ou de la gauche vers la droite. + + + Le niveau, entre 0 et 1, au-dessus duquel un segment est dessiné avec l'état moyen. + + + Verticale + + + Décroissance du niveau + + + Horizontale + + + Orientation + + + Seuil élevé + + + Segments par canal + + + Seuil moyen + + + Vumètre + + + Maintien des crêtes (ms) + + + Indique si chaque canal conserve un repère à son niveau récent le plus fort. + + + Le nombre d'unités de niveau dont un repère de crête descend par seconde après sa durée de maintien, entre 0 et 100. Des valeurs plus élevées descendent plus vite. + + + La durée, en millisecondes, pendant laquelle un repère de crête est maintenu avant de commencer à descendre, entre 0 et 10000. + + + Afficher les crêtes + + + L'espacement, en pixels, entre les segments et les canaux du vumètre, entre 0 et 32. + + + Espacement des segments + + + Le nombre d'unités de niveau dont un canal descend par seconde après la baisse du son, entre 0 et 100. Des valeurs plus élevées descendent plus vite. + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.it-IT.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.it-IT.resx index 82a30343..50afc447 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.it-IT.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.it-IT.resx @@ -123,4 +123,67 @@ Alta (320 kbps) + + In quanti segmenti è diviso ogni canale del vumetro, tra 1 e 128. + + + Caduta dei picchi + + + Il livello, tra 0 e 1, oltre il quale un segmento viene disegnato con lo stato alto. Deve essere almeno la soglia media. + + + Indica se i canali del vumetro crescono dal basso verso l'alto o da sinistra verso destra. + + + Il livello, tra 0 e 1, oltre il quale un segmento viene disegnato con lo stato medio. + + + Verticale + + + Caduta del livello + + + Orizzontale + + + Orientamento + + + Soglia alta + + + Segmenti per canale + + + Soglia media + + + Vumetro + + + Mantenimento dei picchi (ms) + + + Indica se ogni canale mantiene un segno al suo livello recente più alto. + + + Quante unità di livello scende un segno di picco al secondo dopo il suo tempo di mantenimento, tra 0 e 100. Valori più alti scendono più rapidamente. + + + Per quanto tempo, in millisecondi, un segno di picco viene mantenuto prima di iniziare a scendere, tra 0 e 10000. + + + Mostra picchi + + + La spaziatura, in pixel, tra i segmenti e i canali del vumetro, tra 0 e 32. + + + Spaziatura dei segmenti + + + Quante unità di livello scende un canale al secondo dopo che il suono cala, tra 0 e 100. Valori più alti scendono più rapidamente. + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ja-JP.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ja-JP.resx index 0114337d..7ab99e64 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ja-JP.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ja-JP.resx @@ -123,4 +123,67 @@ 高 (320 kbps) + + VUメーターの各チャンネルを分割するセグメント数です。1から128の間で指定します。 + + + ピークの減衰 + + + セグメントを高い状態で描画するレベルです。0から1の間で指定し、中間しきい値以上である必要があります。 + + + VUメーターの各チャンネルが下から上へ伸びるか、左から右へ伸びるかを指定します。 + + + セグメントを中間状態で描画するレベルです。0から1の間で指定します。 + + + 垂直 + + + レベルの減衰 + + + 水平 + + + 向き + + + 高いしきい値 + + + チャンネルあたりのセグメント数 + + + 中間しきい値 + + + VUメーター + + + ピーク保持 (ms) + + + 各チャンネルに直近の最大レベルの印を残すかどうかを指定します。 + + + 保持時間の後、ピークの印が1秒あたりに下がるレベルの量です。0から100の間で指定します。値が大きいほど速く下がります。 + + + ピークの印が下がり始めるまで保持される時間をミリ秒単位で指定します。0から10000の間です。 + + + ピークを表示 + + + VUメーターのセグメントとチャンネルの間隔をピクセル単位で指定します。0から32の間です。 + + + セグメント間隔 + + + 音が下がった後にチャンネルが1秒あたりに下がるレベルの量です。0から100の間で指定します。値が大きいほど速く下がります。 + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.resx index 27a71a6f..d08f5f21 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.resx @@ -123,4 +123,67 @@ High (320 kbps) + + How many segments each channel of the VU meter is divided into, between 1 and 128. + + + Peak falloff + + + The level, between 0 and 1, above which a segment is drawn with the high state. It must be at least the medium threshold. + + + Whether the channels of the VU meter grow upwards from the bottom, or rightwards from the left. + + + The level, between 0 and 1, above which a segment is drawn with the medium state. + + + Vertical + + + Level falloff + + + Horizontal + + + Orientation + + + High threshold + + + Segments per channel + + + Medium threshold + + + VU meter + + + Peak hold (ms) + + + Whether each channel holds a mark at its loudest recent level. + + + How many level units a peak mark falls per second after its hold time, between 0 and 100. Higher values fall faster. + + + How long, in milliseconds, a peak mark is held before it starts falling, between 0 and 10000. + + + Show peak + + + The gap, in pixels, between the segments and the channels of the VU meter, between 0 and 32. + + + Segment gap + + + How many level units a channel falls per second after the sound drops, between 0 and 100. Higher values fall faster. + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ro-RO.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ro-RO.resx index cf66fa31..55c1aaa1 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ro-RO.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.ro-RO.resx @@ -123,4 +123,67 @@ Ridicată (320 kbps) + + În câte segmente este împărțit fiecare canal al vumetrului, între 1 și 128. + + + Scăderea vârfurilor + + + Nivelul, între 0 și 1, peste care un segment este desenat cu starea ridicată. Trebuie să fie cel puțin pragul mediu. + + + Dacă canalele vumetrului cresc de jos în sus sau de la stânga la dreapta. + + + Nivelul, între 0 și 1, peste care un segment este desenat cu starea medie. + + + Verticală + + + Scăderea nivelului + + + Orizontală + + + Orientare + + + Prag ridicat + + + Segmente pe canal + + + Prag mediu + + + Vumetru + + + Menținerea vârfurilor (ms) + + + Dacă fiecare canal păstrează un marcaj la cel mai puternic nivel recent. + + + Câte unități de nivel scade un marcaj de vârf pe secundă după durata de menținere, între 0 și 100. Valorile mai mari scad mai repede. + + + Cât timp, în milisecunde, este menținut un marcaj de vârf înainte de a începe să scadă, între 0 și 10000. + + + Afișează vârfurile + + + Spațiul, în pixeli, dintre segmente și canalele vumetrului, între 0 și 32. + + + Spațiu între segmente + + + Câte unități de nivel scade un canal pe secundă după ce sunetul scade, între 0 și 100. Valorile mai mari scad mai repede. + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.uk-UA.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.uk-UA.resx index 6bbf73e6..82c36378 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.uk-UA.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.uk-UA.resx @@ -123,4 +123,67 @@ Висока (320 kbps) + + На скільки сегментів поділено кожен канал VU-метра, від 1 до 128. + + + Спад піків + + + Рівень від 0 до 1, вище якого сегмент малюється у високому стані. Він має бути не меншим за середній поріг. + + + Чи ростуть канали VU-метра знизу вгору або зліва направо. + + + Рівень від 0 до 1, вище якого сегмент малюється в середньому стані. + + + Вертикальна + + + Спад рівня + + + Горизонтальна + + + Орієнтація + + + Високий поріг + + + Сегментів на канал + + + Середній поріг + + + VU-метр + + + Утримання піків (мс) + + + Чи залишає кожен канал позначку на своєму найгучнішому недавньому рівні. + + + Скільки одиниць рівня позначка піку спадає за секунду після часу утримання, від 0 до 100. Більші значення спадають швидше. + + + Скільки мілісекунд позначка піку утримується перед тим, як почати спадати, від 0 до 10000. + + + Показувати піки + + + Проміжок у пікселях між сегментами та каналами VU-метра, від 0 до 32. + + + Проміжок між сегментами + + + Скільки одиниць рівня канал спадає за секунду після зниження звуку, від 0 до 100. Більші значення спадають швидше. + diff --git a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.zh-CN.resx b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.zh-CN.resx index 08aa28b9..e665e765 100644 --- a/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.zh-CN.resx +++ b/src/Lumina.Presentation.Web/Core/Resources/Views/Tools/Settings.zh-CN.resx @@ -123,4 +123,67 @@ 高 (320 kbps) + + VU 表的每个通道分为多少段,介于 1 到 128 之间。 + + + 峰值衰落 + + + 以高状态绘制段时所超过的电平,介于 0 到 1 之间。它必须大于或等于中等阈值。 + + + VU 表的通道是从下向上增长,还是从左向右增长。 + + + 以中等状态绘制段时所超过的电平,介于 0 到 1 之间。 + + + 垂直 + + + 电平衰落 + + + 水平 + + + 方向 + + + 高阈值 + + + 每通道段数 + + + 中等阈值 + + + VU 表 + + + 峰值保持(毫秒) + + + 每个通道是否在其最近的最大电平处保留标记。 + + + 峰值标记在保持时间过后每秒下降的电平单位数,介于 0 到 100 之间。数值越大下降越快。 + + + 峰值标记在开始下降之前保持的时间(以毫秒为单位),介于 0 到 10000 之间。 + + + 显示峰值 + + + VU 表的段与通道之间的间距(以像素为单位),介于 0 到 32 之间。 + + + 段间距 + + + 声音下降后通道每秒下降的电平单位数,介于 0 到 100 之间。数值越大下降越快。 + diff --git a/src/Lumina.Presentation.Web/Core/Views/Shared/_AudioPlayer.cshtml b/src/Lumina.Presentation.Web/Core/Views/Shared/_AudioPlayer.cshtml index f7de8b66..694bb64a 100644 --- a/src/Lumina.Presentation.Web/Core/Views/Shared/_AudioPlayer.cshtml +++ b/src/Lumina.Presentation.Web/Core/Views/Shared/_AudioPlayer.cshtml @@ -54,6 +54,14 @@ geometry, so a theme consumes the properties to style each state and to give either bar its own shape and orientation. The player marks the bar with 'is-buffering' while it is loading, and carries the state in 'data-audio-player-progress-state' ('idle', 'ready' or 'buffering') together with the slider ARIA attributes. + - The VU meter root carries 'data-audio-player-vu-meter'. The player fills it with one 'audio-player-vu-channel' + element per band, one 'audio-player-vu-segment' per segment of the channel, and one 'audio-player-vu-peak' per + channel, and writes 'data-audio-player-vu-segment-state' ('active' or 'inactive'), + 'data-audio-player-vu-segment-zone' ('normal', 'medium' or 'high') and 'data-audio-player-vu-peak-state' + ('active' or 'inactive'). It publishes the segment gap and the peak position as the custom properties + '--audio-player-vu-segment-gap' and '--audio-player-vu-peak-position'. The root sits between the album art and + the current time label; a theme that does not render the hook gets the meter inserted there when the bar is bound. + The meter is entirely theme-owned: the stylesheet decides its shape, orientation, size and colors. - Themed shells only: the plain text script elements that carry the raw source of the 'shared/audio-player/queue-item' and 'shared/audio-player/playlist-item' sub templates, with the ids 'audio-player-template-queue-item' and 'audio-player-template-playlist-item'. This application fallback partial @@ -102,9 +110,11 @@
    - +
    + +
    diff --git a/src/Lumina.Presentation.Web/Core/Views/Shared/_ThemeLayoutScripts.cshtml b/src/Lumina.Presentation.Web/Core/Views/Shared/_ThemeLayoutScripts.cshtml index f833e521..aa01491c 100644 --- a/src/Lumina.Presentation.Web/Core/Views/Shared/_ThemeLayoutScripts.cshtml +++ b/src/Lumina.Presentation.Web/Core/Views/Shared/_ThemeLayoutScripts.cshtml @@ -122,6 +122,7 @@ + diff --git a/src/Lumina.Presentation.Web/Core/Views/Tools/Settings.cshtml b/src/Lumina.Presentation.Web/Core/Views/Tools/Settings.cshtml index 0a38b2b1..77316861 100644 --- a/src/Lumina.Presentation.Web/Core/Views/Tools/Settings.cshtml +++ b/src/Lumina.Presentation.Web/Core/Views/Tools/Settings.cshtml @@ -202,6 +202,106 @@
    @_localizer["DescriptionStreamingQuality"]
    + +
    +

    @_localizer["VuMeter"]

    +
    + +
    +
    + : +
    +
    + +
    + @_localizer["DescriptionVuMeterOrientation"] +
    + +
    +
    + : +
    +
    + +
    + @_localizer["DescriptionVuMeterSegmentCount"] +
    + +
    +
    + : +
    +
    + +
    + @_localizer["DescriptionVuMeterSegmentGap"] +
    + +
    +
    + : +
    +
    + +
    + @_localizer["DescriptionVuMeterMediumThreshold"] +
    + +
    +
    + : +
    +
    + +
    + @_localizer["DescriptionVuMeterHighThreshold"] +
    + +
    +
    + : +
    +
    + +
    + @_localizer["DescriptionVuMeterShowPeak"] +
    + +
    +
    + : +
    +
    + +
    + @_localizer["DescriptionVuMeterPeakHoldDuration"] +
    + +
    +
    + : +
    +
    + +
    + @_localizer["DescriptionVuMeterReleasePerSecond"] +
    + +
    +
    + : +
    +
    + +
    + @_localizer["DescriptionVuMeterPeakReleasePerSecond"] +
    @@ -231,6 +331,15 @@ const checkboxIsGaplessPlaybackEnabled = document.getElementById('IsGaplessPlaybackEnabled'); const selectReplayGainMode = document.getElementById('ReplayGainMode'); const selectStreamingQuality = document.getElementById('StreamingQuality'); + const selectVuMeterOrientation = document.getElementById('VuMeterOrientation'); + const inputVuMeterSegmentCount = document.getElementById('VuMeterSegmentCount'); + const inputVuMeterSegmentGap = document.getElementById('VuMeterSegmentGap'); + const inputVuMeterMediumThreshold = document.getElementById('VuMeterMediumThreshold'); + const inputVuMeterHighThreshold = document.getElementById('VuMeterHighThreshold'); + const checkboxVuMeterShowPeak = document.getElementById('VuMeterShowPeak'); + const inputVuMeterPeakHoldDurationInMilliseconds = document.getElementById('VuMeterPeakHoldDurationInMilliseconds'); + const inputVuMeterReleasePerSecond = document.getElementById('VuMeterReleasePerSecond'); + const inputVuMeterPeakReleasePerSecond = document.getElementById('VuMeterPeakReleasePerSecond'); // Toggle the enabled state of the items per page input based on the pagination checkbox. function updateItemsPerPageEnabledState() { @@ -254,11 +363,25 @@ checkboxIsGaplessPlaybackEnabled.checked = data.isGaplessPlaybackEnabled === true; selectReplayGainMode.value = data.replayGainMode ?? 'Off'; selectStreamingQuality.value = data.streamingQuality ?? 'Auto'; + selectVuMeterOrientation.value = data.vuMeterOrientation ?? 'Vertical'; + inputVuMeterSegmentCount.value = data.vuMeterSegmentCount ?? 12; + inputVuMeterSegmentGap.value = data.vuMeterSegmentGap ?? 1; + inputVuMeterMediumThreshold.value = data.vuMeterMediumThreshold ?? 0.6; + inputVuMeterHighThreshold.value = data.vuMeterHighThreshold ?? 0.8; + checkboxVuMeterShowPeak.checked = data.vuMeterShowPeak !== false; + inputVuMeterPeakHoldDurationInMilliseconds.value = data.vuMeterPeakHoldDurationInMilliseconds ?? 650; + inputVuMeterReleasePerSecond.value = data.vuMeterReleasePerSecond ?? 3; + inputVuMeterPeakReleasePerSecond.value = data.vuMeterPeakReleasePerSecond ?? 0.65; updateItemsPerPageEnabledState(); } } // Save the settings of the current user. + // An empty numeric field is sent as null, so the server reports it as missing instead of reading it as zero. + function readOptionalNumber(input) { + return input.value.trim() === '' ? null : Number(input.value); + } + async function handleSaveUserSettingsAsync() { const formData = { IsPaginationEnabled: checkboxIsPaginationEnabled.checked, @@ -273,11 +396,25 @@ ShouldAutoplay: checkboxShouldAutoplay.checked, IsGaplessPlaybackEnabled: checkboxIsGaplessPlaybackEnabled.checked, ReplayGainMode: selectReplayGainMode.value, - StreamingQuality: selectStreamingQuality.value + StreamingQuality: selectStreamingQuality.value, + VuMeterOrientation: selectVuMeterOrientation.value, + VuMeterSegmentCount: readOptionalNumber(inputVuMeterSegmentCount), + VuMeterSegmentGap: readOptionalNumber(inputVuMeterSegmentGap), + VuMeterMediumThreshold: readOptionalNumber(inputVuMeterMediumThreshold), + VuMeterHighThreshold: readOptionalNumber(inputVuMeterHighThreshold), + VuMeterShowPeak: checkboxVuMeterShowPeak.checked, + VuMeterPeakHoldDurationInMilliseconds: readOptionalNumber(inputVuMeterPeakHoldDurationInMilliseconds), + VuMeterReleasePerSecond: readOptionalNumber(inputVuMeterReleasePerSecond), + VuMeterPeakReleasePerSecond: readOptionalNumber(inputVuMeterPeakReleasePerSecond) }; const data = await callApiPostAsync('@_urlService.GetAbsoluteUrl(WebRoutes.Settings.UPDATE_USER_SETTINGS)', formData); - if (data && data.isUpdated === true) + if (data && data.isUpdated === true) { notificationService.show('@_localizer["SettingsSaved"]', NotificationType.SUCCESS); + // The player lives in the layout and is not recreated by the navigation manager, so the saved playback and + // VU meter settings are handed to it directly instead of waiting for a full page reload. + if (window.LuminaAudioPlayer && window.LuminaAudioPlayer.instance && typeof window.LuminaAudioPlayer.instance.reloadPreferencesAsync === 'function') + await window.LuminaAudioPlayer.instance.reloadPreferencesAsync(); + } } // On form submit event. diff --git a/src/Lumina.Presentation.Web/wwwroot/css/site.css b/src/Lumina.Presentation.Web/wwwroot/css/site.css index f9bfa459..2c57fdcf 100644 --- a/src/Lumina.Presentation.Web/wwwroot/css/site.css +++ b/src/Lumina.Presentation.Web/wwwroot/css/site.css @@ -1,4 +1,4 @@ -html, +html, body { margin: 0px; padding: 0px; @@ -1380,6 +1380,14 @@ body { /* The expand and collapse duration is one value, so a theme can keep the height, fade and padding transitions in step by overriding this property on the container. */ --audio-player-expanded-duration: 0.4s; transition: height var(--audio-player-expanded-duration) ease; + /* The VU meter palette is declared on the container so a theme overrides it on the + container or on the meter root, and every channel, segment and peak marker inherits the override. */ + --audio-player-vu-normal-color: #0099FF; + --audio-player-vu-medium-color: #FFD166; + --audio-player-vu-high-color: #FF5D5D; + --audio-player-vu-inactive-color: transparent; + --audio-player-vu-peak-color: #F4F7FA; + --audio-player-vu-background-color: transparent; } .audio-player-container.not-shown { @@ -1459,6 +1467,118 @@ html.audio-player-initializing .audio-player-container { display: none; } +/* VU meter. The player renders one channel per band and one segment per channel, and writes only the state and zone of + each segment and the position of each peak, so a theme restyles the whole meter from these rules or replaces them. The + colors are custom properties declared on the container, so overriding them on the container or on a theme selector is + enough to recolor every segment. The meter publishes the configured segment gap as '--audio-player-vu-segment-gap', the + segment count as '--audio-player-vu-segment-count', the channel count as '--audio-player-vu-band-count' and the peak position as '--audio-player-vu-peak-position'. */ +.audio-player-vu-meter { + --audio-player-vu-cell: 3px; + --audio-player-vu-extent: 48px; + --audio-player-vu-max-cell: 4px; + --audio-player-vu-row: 1px; + --audio-player-vu-run: 8px; + flex: 0 0 auto; + display: flex; + gap: var(--audio-player-vu-segment-gap, 1px); + overflow: hidden; + background-color: var(--audio-player-vu-background-color, transparent); +} + +@supports (width: round(down, 5px, 1px)) { + .audio-player-vu-meter { + --audio-player-vu-cell: max(1px, round(down, min(var(--audio-player-vu-max-cell), calc((var(--audio-player-vu-extent) - (var(--audio-player-vu-segment-count, 12) - 1) * var(--audio-player-vu-segment-gap, 1px)) / var(--audio-player-vu-segment-count, 12))), 1px)); + --audio-player-vu-row: max(1px, round(down, calc((var(--audio-player-vu-extent) - (var(--audio-player-vu-band-count, 24) - 1) * var(--audio-player-vu-segment-gap, 1px)) / var(--audio-player-vu-band-count, 24)), 1px)); + } +} + +.audio-player-vu-meter[data-audio-player-vu-meter-orientation="vertical"] { + flex-direction: row; + width: calc(var(--audio-player-vu-band-count, 24) * var(--audio-player-vu-cell) + (var(--audio-player-vu-band-count, 24) - 1) * var(--audio-player-vu-segment-gap, 1px)); + height: calc(var(--audio-player-vu-segment-count, 12) * var(--audio-player-vu-cell) + (var(--audio-player-vu-segment-count, 12) - 1) * var(--audio-player-vu-segment-gap, 1px)); +} + +.audio-player-vu-meter[data-audio-player-vu-meter-orientation="horizontal"] { + flex-direction: column; + width: calc(var(--audio-player-vu-segment-count, 12) * var(--audio-player-vu-run) + (var(--audio-player-vu-segment-count, 12) - 1) * var(--audio-player-vu-segment-gap, 1px)); + height: calc(var(--audio-player-vu-band-count, 24) * var(--audio-player-vu-row) + (var(--audio-player-vu-band-count, 24) - 1) * var(--audio-player-vu-segment-gap, 1px)); +} + +.audio-player-vu-channel { + position: relative; + display: flex; + flex: 0 0 auto; + gap: var(--audio-player-vu-segment-gap, 1px); +} + +.audio-player-vu-meter[data-audio-player-vu-meter-orientation="vertical"] .audio-player-vu-channel { + flex-direction: column-reverse; + width: var(--audio-player-vu-cell); +} + +.audio-player-vu-meter[data-audio-player-vu-meter-orientation="horizontal"] .audio-player-vu-channel { + flex-direction: row; + height: var(--audio-player-vu-row); +} + +/* A segment is inactive until the level reaches it, and it takes its zone color only while it is active. The zone is + part of the markup, so a theme can give each of the three independently. */ +.audio-player-vu-segment { + flex: 0 0 auto; + background-color: var(--audio-player-vu-inactive-color, transparent); +} + +.audio-player-vu-meter[data-audio-player-vu-meter-orientation="vertical"] .audio-player-vu-segment { + width: var(--audio-player-vu-cell); + height: var(--audio-player-vu-cell); +} + +.audio-player-vu-meter[data-audio-player-vu-meter-orientation="horizontal"] .audio-player-vu-segment { + width: var(--audio-player-vu-run); + height: var(--audio-player-vu-row); +} + +.audio-player-vu-segment[data-audio-player-vu-segment-state="active"][data-audio-player-vu-segment-zone="normal"] { + background-color: var(--audio-player-vu-normal-color, #0099FF); +} + +.audio-player-vu-segment[data-audio-player-vu-segment-state="active"][data-audio-player-vu-segment-zone="medium"] { + background-color: var(--audio-player-vu-medium-color, #FFD166); +} + +.audio-player-vu-segment[data-audio-player-vu-segment-state="active"][data-audio-player-vu-segment-zone="high"] { + background-color: var(--audio-player-vu-high-color, #FF5D5D); +} + +/* The peak marker spans the short axis of its channel and is placed on the long axis from the custom property, so the + same markup serves both orientations: a theme only maps the property to whichever edge its own layout grows from. */ +.audio-player-vu-peak { + position: absolute; + background-color: var(--audio-player-vu-peak-color, #F4F7FA); + opacity: 0; + pointer-events: none; +} + +.audio-player-vu-peak[data-audio-player-vu-peak-state="active"] { + opacity: 1; +} + +.audio-player-vu-meter[data-audio-player-vu-meter-orientation="vertical"] .audio-player-vu-peak { + left: 0px; + right: 0px; + bottom: var(--audio-player-vu-peak-position, 0%); + height: 2px; + transform: translateY(50%); +} + +.audio-player-vu-meter[data-audio-player-vu-meter-orientation="horizontal"] .audio-player-vu-peak { + top: 0px; + bottom: 0px; + left: var(--audio-player-vu-peak-position, 0%); + width: 2px; + transform: translateX(-50%); +} + .audio-player-time { flex: 0 0 auto; font-size: 12px; diff --git a/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-engine.js b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-engine.js index 715bc679..e56113bb 100644 --- a/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-engine.js +++ b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-engine.js @@ -21,6 +21,12 @@ * - getBufferedTimeRanges(): the time ranges, in seconds, the engine already downloaded, as a list of objects with * a 'start' and an 'end'. It is optional: an engine that does not implement it makes the player unable to tell * whether a seek target is buffered, in which case the player never shows a loading state for a seek. + * - getOutputAnalyser() (optional): the AnalyserNode that taps the sound the engine outputs, after its ReplayGain + * normalization but before its output volume and mute state, or null when the engine cannot expose one. The player + * hands it to the VU meter of the bar, which reads it on every animation frame; tapping before the volume is what + * keeps the meter height independent of the volume setting. The node must stay valid for as long as the engine lives: + * the player binds it once, when a track was loaded, and the renderer keeps the same node across the tracks it plays. + * An engine that does not implement this method, or that returns null, makes the bar render an empty meter. * - discardCurrentAsync() (optional): releases the currently prepared track without destroying the engine, so a stop * during an automatic continuation does not leave the track it started loaded behind an idle player. * - cancelUpcomingAsync() (optional): drops a prefetched or appended handoff of the current track when the player queue is diff --git a/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-pipeline/audio-player-pipeline-engine.js b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-pipeline/audio-player-pipeline-engine.js index ded37d8a..9766f29e 100644 --- a/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-pipeline/audio-player-pipeline-engine.js +++ b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-pipeline/audio-player-pipeline-engine.js @@ -653,6 +653,16 @@ } } + /** + * Gets the analyzer that taps the track level of the engine, which the VU meter of the bar reads. The analyzer of + * the shared renderer sits before the output volume, so the meter does not change with the volume setting, and it + * stays valid across the tracks the engine plays, because the renderer and its audio context are reused. + * @returns {AnalyserNode|null} The output analyzer, or null while no audio context has been created yet. + */ + getOutputAnalyser() { + return this.renderer.getOutputAnalyser(); + } + /** * Checks whether the engine was destroyed. * @returns {boolean} True when the engine was destroyed. diff --git a/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-render.js b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-render.js index 6a3cdfb6..55ec4179 100644 --- a/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-render.js +++ b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-render.js @@ -9,14 +9,16 @@ * * Signal chain * ------------ - * Every scheduled source is connected to the per-track GainNode, which feeds the master GainNode, which feeds the - * destination, so: + * Every scheduled source is connected to the per-track GainNode, which feeds an AnalyserNode, which feeds the master GainNode, which feeds the destination, so: * - the master gain is the output volume, and it is zero while the player is muted, which is how mute is honored; - * - the per-track gain is the ReplayGain linear gain of the current track, chosen by the user's ReplayGain mode among - * the values the playback manifest carries. + * - the per-track gain is the ReplayGain linear gain of the current track, chosen by the user's ReplayGain mode among the values the playback manifest carries; + * - the analyzer sits after the per-track gain and before the master gain, so it observes the level of the track itself, + * after its ReplayGain normalization but before the output volume. The VU meter of the bar reads it, which is why + * changing the volume, or muting the player, never changes the height of the meter for the same moment of audio. * Keeping the master gain and the ReplayGain gain on two separate nodes lets either change without disturbing the other. * The engine of the player folds the mute state into the volume it passes, so it delivers a mute as setVolumeAsync(0) * and never calls setMutedAsync; that setter exists for a caller that owns both the volume and the mute state itself. + * The analyzer is created only when the audio context exposes createAnalyser, so a reduced context, or a test double, still builds the gain graph and simply exposes no analyzer. * * Scheduling model * ---------------- @@ -255,6 +257,13 @@ */ const REPORTER_FALLBACK_INTERVAL_MS = 16; + /** + * The transform size of the analyzer that taps the output for the VU meter. It is the smallest size that resolves the low bands the meter starts at. + * @readonly + * @type {number} + */ + const OUTPUT_ANALYSER_FFT_SIZE = 2048; + /** * Coerces a value to a finite number, or null when it is absent or not finite. * @param {*} value - The value to coerce. @@ -268,8 +277,7 @@ } /** - * Normalizes a ReplayGain mode into one of the {@link LuminaAudioPlayer.PlayerReplayGainMode} values, defaulting an - * absent or unrecognized value to no normalization. + * Normalizes a ReplayGain mode into one of the {@link LuminaAudioPlayer.PlayerReplayGainMode} values, defaulting an absent or unrecognized value to no normalization. * @param {string} value - The mode to normalize, as the user settings or the manifest spell it. * @returns {string} One of the {@link LuminaAudioPlayer.PlayerReplayGainMode} values. */ @@ -287,8 +295,7 @@ return LuminaAudioPlayer.PlayerReplayGainMode.ALBUM; } // A value the renderer does not know is very likely a mode the server added and this list does not carry yet, so it - // is reported, whatever its type, instead of being dropped silently; the sync of the two lists is documented on the - // enum. + // is reported, whatever its type, instead of being dropped silently; the sync of the two lists is documented on the enum. console.warn(`Audio player: the ReplayGain mode '${String(value)}' is not known to the renderer, so no normalization is applied.`); return LuminaAudioPlayer.PlayerReplayGainMode.OFF; } @@ -299,8 +306,7 @@ * ReplayGain carries a track, or album, gain to bring the loudness of the audio to the reference level, and a peak, * the highest sample amplitude of the audio. A gain that would push the peak above the full scale would clip, so the * gain is limited to the largest value that keeps the normalized peak at or below the full scale, exactly as the - * ReplayGain specification prescribes. A missing gain means no normalization, and a missing or non positive peak - * leaves the gain uncapped. + * ReplayGain specification prescribes. A missing gain means no normalization, and a missing or non positive peak leaves the gain uncapped. * @param {number|null} gainDb - The ReplayGain value, in decibels. * @param {number|null} peak - The peak amplitude the gain is applied to. * @returns {number} The linear gain, one when there is nothing to apply. @@ -326,8 +332,7 @@ * a unit. The track mode uses the track pair and falls back to the album pair, the album mode does the opposite, and * the off mode selects nothing. The fallback matters because a track whose album was not analyzed can carry only one * of the two pairs, and normalizing with the pair that exists is better than not normalizing at all. A peak is never - * taken from one pair while the gain comes from the other, because the anti-clip ceiling would then be computed from a - * peak the applied gain does not belong to. + * taken from one pair while the gain comes from the other, because the anti-clip ceiling would then be computed from a peak the applied gain does not belong to. * @param {Object|null} manifest - The playback manifest of the track. * @param {string} mode - One of the {@link LuminaAudioPlayer.PlayerReplayGainMode} values. * @returns {{ gainDb: number|null, peak: number|null }} The selected pair, null when nothing is selected. @@ -408,6 +413,10 @@ this.masterGain = null; this.trackGain = null; + // The analyzer that taps the track level for the VU meter of the bar, after the ReplayGain gain and before the + // master gain that carries the volume and the mute state. It is null when the audio context of the environment + // cannot create one, in which case the meter renders empty instead of failing. + this.analyser = null; this.manifest = null; this.duration = 0; // The media duration of the whole shared timeline. It equals the duration of the current track until a gapless @@ -441,12 +450,10 @@ // detection, so a schedule that was just reset to a media position does not report the end of the track // before a single buffer has been scheduled at that position. this.hasScheduledSinceReset = false; - // True once the decode pipeline has fed the last decoded frame of the track, which is what tells a drained - // schedule apart from the end of the track. + // True once the decode pipeline has fed the last decoded frame of the track, which is what tells a drained schedule apart from the end of the track. this.streamComplete = false; // True once the current track has reached its end, that is once the schedule drained while the track was known - // to be complete. It drives whether a newly scheduled buffer resumes playback; a configure, a seek or a newly - // scheduled buffer clears it. + // to be complete. It drives whether a newly scheduled buffer resumes playback; a configure, a seek or a newly scheduled buffer clears it. this.reachedEnd = false; // True once the end of the current configured track has been reported through onEnded. It is a latch of its // own, so the callback fires once per configured track even when audio is scheduled after the end; only a @@ -566,8 +573,7 @@ } /** - * Cancels a scheduled gapless ReplayGain change and restores the gain of the current manifest. It is used when the - * handoff is abandoned before the next track starts. + * Cancels a scheduled gapless ReplayGain change and restores the gain of the current manifest. It is used when the handoff is abandoned before the next track starts. * @returns {LuminaAudioPlayer.TrackRenderer} This renderer, for chaining. */ cancelTrackGainChange() { @@ -600,8 +606,7 @@ } /** - * Releases every resource of the renderer: the schedule, the gain nodes, the event subscriptions and, when the - * renderer owns it, the audio context. + * Releases every resource of the renderer: the schedule, the gain nodes, the event subscriptions and, when the renderer owns it, the audio context. * @returns {Promise} A promise that completes when the context is closed. */ async destroyAsync() { @@ -627,6 +632,14 @@ } this.trackGain = null; } + if (this.analyser) { + try { + this.analyser.disconnect(); + } catch (error) { + console.debug('Audio player: the output analyzer could not be disconnected.', error); + } + this.analyser = null; + } if (this.masterGain) { try { this.masterGain.disconnect(); @@ -648,8 +661,7 @@ } catch (error) { // The context is still live. Its reference is kept rather than dropped, and the failure is recorded, so a // caller can still reach the context through getContext() and close it itself; the renderer itself is - // destroyed and never uses it again. Dropping the only reference would lose a context that the browser - // counts until it is closed. + // destroyed and never uses it again. Dropping the only reference would lose a context that the browser counts until it is closed. this.raise(error, LuminaAudioPlayer.PlayerErrorCode.ENGINE_ERROR); console.error('Audio player: the audio context could not be closed.', error); return; @@ -1176,6 +1188,16 @@ return this.context; } + /** + * Gets the analyzer that taps the output of the track gain, which is what the VU meter of the bar reads. The + * analyzer sits after the ReplayGain normalization of the track and before the master gain that carries the + * volume and the mute state, so it observes the level of the track itself and never the level of the speaker. + * @returns {AnalyserNode|null} The output analyzer, or null when the context has none, when it has not been created yet, or once the renderer was destroyed. + */ + getOutputAnalyser() { + return this.analyser; + } + //+======================================================================================+ //| Internal helpers | //+======================================================================================+ @@ -1205,18 +1227,44 @@ } /** - * Builds the two gain nodes of the output and connects them: the sources feed the per-track gain, which feeds the - * master gain, which feeds the destination. + * Builds the gain nodes of the output and connects them: the sources feed the per-track gain, which feeds the + * output analyzer, which feeds the master gain, which feeds the destination. The analyzer is optional and is + * skipped when the context cannot create one, in which case the per-track gain feeds the master gain directly. + * Putting the analyzer before the master gain keeps the meter independent of the output volume and of the mute + * state, so it measures the level of the track instead of the level of the speaker. */ buildGainGraph() { this.masterGain = this.context.createGain(); this.trackGain = this.context.createGain(); - this.trackGain.connect(this.masterGain); + this.analyser = this.createOutputAnalyser(); + if (this.analyser) { + this.trackGain.connect(this.analyser); + this.analyser.connect(this.masterGain); + } else + this.trackGain.connect(this.masterGain); this.masterGain.connect(this.context.destination); this.applyMasterGain(0); this.applyTrackGain(0); } + /** + * Creates the analyzer that taps the output for the VU meter. Only its time domain buffer is used: the meter + * applies its own window and transform to those samples, so the analyzer is configured with the transform size that buffer must have and nothing else. + * @returns {AnalyserNode|null} The analyzer, or null when the context cannot create one. + */ + createOutputAnalyser() { + if (typeof this.context.createAnalyser !== 'function') + return null; + try { + const analyser = this.context.createAnalyser(); + analyser.fftSize = OUTPUT_ANALYSER_FFT_SIZE; + return analyser; + } catch (error) { + console.debug('Audio player: the output analyzer of the VU meter could not be created.', error); + return null; + } + } + /** * Applies the output gain, which is the volume, or zero while muted, to the master gain node. * @param {number} rampSeconds - The duration of the ramp to the new value, in seconds. Zero applies it at once. diff --git a/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-vu-meter.js b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-vu-meter.js new file mode 100644 index 00000000..6b257acb --- /dev/null +++ b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player-vu-meter.js @@ -0,0 +1,1074 @@ +/** + * VU meter of the audio player. + * + * The player bar shows a segmented level meter beside the track labels, so a listener can see how loud the track is at + * any moment. The meter follows the level of the track itself, not the level of the player output: the renderer taps the + * signal after the per-track ReplayGain gain and before the master gain that carries the volume and the mute state, so + * changing the volume, or muting the player, never changes the height of the meter for the same moment of audio. This is + * what makes the meter comparable across a listening session, and it is why it does not move when the volume slider is dragged. + * + * Words used in this file + * ----------------------- + * Audio processing has its own vocabulary. These are the terms the comments below rely on: + * - sample: one number between -1 and 1 that describes the position of the speaker membrane at one instant. A track + * at 48 kHz has 48000 samples per second per channel. + * - time domain: the samples in the order they are played, which is what the AnalyserNode hands out. They tell how + * the signal moves over time, but not which frequencies (bass, voice, cymbals) it contains. + * - FFT (Fast Fourier Transform): the algorithm that turns a block of time domain samples into the frequency domain, + * that is, into how strong every frequency is inside that block. + * - bin: one output slot of the FFT. A transform of N samples produces N / 2 useful bins, and bin k describes the + * frequency k * sampleRate / N. With N = 2048 at 48 kHz each bin is about 23 Hz wide. + * - band: a group of neighbouring bins that the meter shows as one channel (one column of segments). + * - decibel (dB): a logarithmic unit for loudness. Every -6 dB halves the amplitude, and 0 dBFS ("full scale") is the + * loudest level a digital signal can hold, so real music levels are negative numbers. + * - RMS (root mean square): the square root of the average of the squared values. It measures the energy of a signal, + * which matches perceived loudness better than its highest value does. + * - window: a curve the samples are multiplied by before the FFT. See buildWindow for why it is needed. + * + * What it measures + * ---------------- + * The meter is a spectrum meter rather than a two channel volume unit. A spectrum analyzer feeds it a set of bands, one + * band per channel of the meter, and each channel is drawn as a column (or a row) of segments. + * The analyzer is implemented here, so the meter has 24 logarithmically spaced bands between 40 Hz and 16 kHz, a -70 dB + * noise floor and a +10 dB display offset. Any other band count can be requested, but the shipped composition uses 24. + * + * The analyzer reads the time domain samples of an AnalyserNode of the Web Audio graph and computes the bands itself: the + * samples are windowed with a Hann window and transformed with an iterative radix-2 FFT. The browser is used only to + * deliver the samples, so the meter has a sharp transient response and a fast attack rather than the smoothed response + * of the built-in frequency data. (The AnalyserNode can compute a spectrum itself, through getFloatFrequencyData, but it + * always blends every new spectrum with the previous ones, which makes a drum hit swell up instead of jumping, and its + * smoothing is not the same in every browser.) A transform is taken once per block of samples, so a beat produces one + * sharp jump and the display falls between blocks instead of being refreshed by a sliding, overlapping window. Each band + * combines the power of the bins that fall into its frequency range, and the result is normalized to a level between 0 + * and 1. The transform allocates nothing per frame, because its scratch arrays are created once with the analyzer. + * + * Level dynamics + * -------------- + * A level rises immediately and falls gradually, which is what makes a meter readable: the attack is the peak of the + * new level and the release is a linear fall at releasePerSecond. Each channel also holds a peak marker. A new peak + * captures the level, the marker is held for peakHoldDurationInMilliseconds, and it then falls at peakReleasePerSecond. Both rates are expressed + * in level units per second, so a rate of 1 clears a full meter in one second, and both are user settings, together with the orientation, + * the segment count, the segment gap, the two thresholds and whether the peak marker is shown at all. + * + * Pausing and stopping + * -------------------- + * The meter follows the state machine of the player through start and stop. start begins to read the analyzer, while + * stop stops reading it and lets the displayed levels and peaks fall to zero, so a paused or stopped track leaves an + * empty meter instead of a frozen one. A suspended AudioContext would otherwise keep returning the last analyzed frame, + * which would look like sound that is no longer playing. The frame loop ends by itself once every channel reached zero, + * so a stopped player costs no animation frames. + * + * The DOM contract + * ---------------- + * The meter is built from elements rather than a canvas, so a theme can restyle every part of it and give it its own + * shape, orientation, colors and imagery, exactly like the progress bar. The player renders: + * - the meter root, with the 'audio-player-vu-meter' class and the 'data-audio-player-vu-meter' hook. It carries + * 'data-audio-player-vu-meter-orientation' ('vertical' or 'horizontal'), 'data-audio-player-vu-meter-segments' (the + * segment count) and 'data-audio-player-vu-meter-show-peak' ('true' or 'false'), and it publishes the configured + * segment gap as the CSS custom property '--audio-player-vu-segment-gap', the segment count as + * '--audio-player-vu-segment-count' and the number of channels as '--audio-player-vu-band-count'; + * - one channel per band, with the 'audio-player-vu-channel' class and 'data-audio-player-vu-channel' holding the zero based band index; + * - one segment per channel, with the 'audio-player-vu-segment' class and the + * 'data-audio-player-vu-segment-state' attribute ('active' or 'inactive'). Every segment, active or not, also carries + * 'data-audio-player-vu-segment-zone' ('normal', 'medium' or 'high'), which is derived from the segment position and + * the two thresholds, so a theme styles the three zones independently, and can even tint the unlit segments of a zone; + * - one peak marker per channel, with the 'audio-player-vu-peak' class, the 'data-audio-player-vu-peak' hook and the + * 'data-audio-player-vu-peak-state' attribute ('active' or 'inactive'). The marker publishes its position on the + * channel axis as the CSS custom property '--audio-player-vu-peak-position', between 0% and 100%. + * The segments are rendered in ascending level order, so the first segment of a channel is the quietest one. The + * fallback stylesheet lays the channels out as columns whose segments grow from the bottom for the vertical orientation, + * and as rows whose segments grow from the left for the horizontal one, but that is only its default: the meter writes + * no inline geometry other than the custom properties above, so a theme may lay the segments out in any direction. + * + * Rendering cost + * -------------- + * The elements are created once per configuration, and every frame only writes the attributes whose value changed. A + * burst of identical frames therefore does no DOM work, and the animation frame loop stops entirely while the meter is + * empty. The meter never reads the layout of its elements, so it does not force a reflow per frame. (A reflow is the + * browser recomputing the size and position of elements. Reading a size, such as offsetHeight, right after writing a + * style forces one immediately, and doing that every frame is a common cause of stuttering animations.) + * + * Using it + * -------- + * const meter = LuminaAudioPlayer.createVuMeter({ + * container: barElement.querySelector('[data-audio-player-vu-meter]'), + * settings: player.getPreferences() + * }); + * meter.setAnalyser(renderer.getOutputAnalyser()); + * meter.start(); // when playback starts + * meter.configure(preferences); // whenever the user settings change + * meter.stop(); // when playback pauses or stops + * meter.destroy(); // when the player is torn down + * The meter tolerates a missing analyzer: it still renders, and its levels simply stay at zero. A player engine that + * cannot expose an analyzer therefore degrades to an empty meter instead of failing. + */ +(function (LuminaAudioPlayer) { + 'use strict'; + + /** + * The number of bands of the shipped meter. 24 bands give two to three bands per octave over the range below, which + * is enough to tell bass, voice and cymbals apart while keeping the meter narrow enough for the player bar. + * @readonly + * @type {number} + */ + const BAND_COUNT = 24; + + /** + * The lowest frequency, in Hz, that the first band covers. Below about 40 Hz music carries little more than rumble, + * and the bins there are so few that a band would flicker between one bin and none. + * @readonly + * @type {number} + */ + const MINIMUM_FREQUENCY = 40; + + /** + * The highest frequency, in Hz, that the last band covers. Most music has very little energy above 16 kHz, and many + * lossy encoders (MP3, AAC at common bitrates) cut most of what lies above it, so bands up there would almost always be empty. + * @readonly + * @type {number} + */ + const MAXIMUM_FREQUENCY = 16000; + + /** + * The noise floor, in decibels, below which a band is reported as silent. It is the bottom of the meter: a level at + * or under it lights no segment, so quiet hiss and dithering noise do not keep the lowest segments permanently lit. + * @readonly + * @type {number} + */ + const NOISE_FLOOR_DB = -70; + + /** + * The display offset, in decibels, added before a band is normalized, so a signal around -10 dBFS fills the meter. + * Without it a band would only reach the top at 0 dBFS, which a single band of real music almost never does, because + * the energy of a track is spread over all the bands. The offset makes ordinary loud passages use the top segments. + * @readonly + * @type {number} + */ + const DISPLAY_GAIN_DB = 10; + + /** + * The transform size of the analyzer. A transform of this size at a typical context rate resolves the lowest band, which starts at 40 Hz, while covering a window short enough to follow the beat. + * The FFT can only take a power of two, and the choice is a trade-off: doubling it halves the width of a bin, which + * gives the bass bands more bins, but also doubles the time a block covers, which makes the meter react more slowly. + * 2048 samples is about 43 ms at 48 kHz, so the meter takes about 23 fresh measurements per second. + * @readonly + * @type {number} + */ + const FFT_SIZE = 2048; + + /** + * The longest frame delta, in seconds, that the release calculation accepts. A tab that was hidden for a long time + * must not empty the meter in one visible frame and skip its release, so a long delta is clamped to a normal frame. + * @readonly + * @type {number} + */ + const MAXIMUM_FRAME_SECONDS = 0.1; + + /** + * The shortest and longest raw frame delta, in milliseconds, that is trusted as the duration of a real frame. The range + * covers displays from about 30 to 240 Hz; anything outside it is a rounded timestamp or a stall. + * See advanceClock for why the timestamps can be rounded at all. + * @readonly + * @type {number} + */ + const MINIMUM_REAL_FRAME_MS = 4; + const MAXIMUM_REAL_FRAME_MS = 40; + + /** + * The fallback frame interval, in milliseconds, used when the page has no requestAnimationFrame. + * @readonly + * @type {number} + */ + const FRAME_FALLBACK_INTERVAL_MS = 16; + + // The ranges below repeat the limits the server validates the user settings against (UpdateUserSettingsCommandValidator + // and the UserSettings aggregate). They are repeated here because the meter also runs with settings that never went + // through the server, such as the defaults or a theme building its own meter, and it must never be driven outside of + // what the settings page can describe. When a limit changes on the server, it has to change here as well. + + /** + * The minimum and maximum accepted number of segments of a channel. + * @readonly + * @type {{ minimum: number, maximum: number }} + */ + const SEGMENT_COUNT_RANGE = Object.freeze({ minimum: 1, maximum: 128 }); + + /** + * The minimum and maximum accepted number of bands of the analyzer. + * @readonly + * @type {{ minimum: number, maximum: number }} + */ + const BAND_COUNT_RANGE = Object.freeze({ minimum: 1, maximum: 128 }); + + /** + * The minimum and maximum accepted segment gap, in pixels. + * @readonly + * @type {{ minimum: number, maximum: number }} + */ + const SEGMENT_GAP_RANGE = Object.freeze({ minimum: 0, maximum: 32 }); + + /** + * The minimum and maximum accepted peak hold duration, in milliseconds. + * @readonly + * @type {{ minimum: number, maximum: number }} + */ + const PEAK_HOLD_RANGE = Object.freeze({ minimum: 0, maximum: 10000 }); + + /** + * The minimum and maximum accepted release rate, in level units per second. + * @readonly + * @type {{ minimum: number, maximum: number }} + */ + const RELEASE_RANGE = Object.freeze({ minimum: 0, maximum: 100 }); + + /** + * The default settings of the meter, mirroring the defaults of the user settings aggregate. + * They are used when a setting is absent, so a player that starts before the stored preferences arrive, or a theme that builds its own meter, still renders a usable meter. + * When a default changes in the UserSettings aggregate, it has to change here as well, otherwise a new user would see one meter before the settings load and a different one after. + * @readonly + * @type {Object} + */ + LuminaAudioPlayer.VU_METER_DEFAULTS = Object.freeze({ + orientation: 'vertical', + segmentCount: 12, + segmentGap: 1, + mediumThreshold: 0.6, + highThreshold: 0.8, + showPeak: true, + peakHoldDurationInMilliseconds: 650, + releasePerSecond: 3, + peakReleasePerSecond: 0.65 + }); + + /** + * The number of bands of the shipped meter, exposed for consumers that build their own meter markup. + * @readonly + * @type {number} + */ + LuminaAudioPlayer.VU_METER_BAND_COUNT = BAND_COUNT; + + /** + * Clamps a number into an inclusive range, through the shared helper on the namespace. The reference is resolved on + * every call rather than captured at load time, so this module does not depend on the load order of the util. + * @param {number} value - The value to clamp. + * @param {number} minimum - The inclusive lower bound. + * @param {number} maximum - The inclusive upper bound. + * @returns {number} The clamped value. + */ + function clamp(value, minimum, maximum) { + return LuminaAudioPlayer.clamp(value, minimum, maximum); + } + + /** + * Coerces a value to a finite number, through the shared helper on the namespace. + * It is used on every setting because settings arrive as JSON or form values, where a number can be a string, null, or missing, and a single NaN would silently break every calculation it touches. + * @param {*} value - The value to coerce. + * @returns {number|null} The finite number, or null. + */ + function toFiniteNumber(value) { + return LuminaAudioPlayer.toFiniteNumber(value); + } + + /** + * Normalizes the orientation of the meter into the value the DOM contract uses. + * The comparison ignores case because the server serializes its enum as 'Vertical' and 'Horizontal', while the DOM + * attributes and the stylesheet use lower case. Anything unknown falls back to vertical, the default orientation. + * @param {*} value - The orientation the user settings carry, either the server's 'Vertical' or 'Horizontal', or the DOM form 'vertical' or 'horizontal' a consumer may pass. + * @returns {string} 'vertical' or 'horizontal'. + */ + function normalizeOrientation(value) { + return typeof value === 'string' && value.toLowerCase() === 'horizontal' ? 'horizontal' : 'vertical'; + } + + /** + * Normalizes a settings object into the values the meter renders and animates with. + * + * Every value is clamped into the range the server validates, so a stale or hand written settings object can never + * put the meter into a state the user settings page cannot describe. A high threshold below the medium threshold is + * raised to it instead of leaving the two zones inverted, which keeps a segment in a defined zone. + * @param {Object} [settings] - The user settings the player holds. + * @returns {Object} The normalized settings. + */ + function normalizeSettings(settings) { + const values = settings || {}; + // The counts, the gap and the hold time are whole numbers on the server, so they are rounded here too: half a + // segment cannot be drawn, and a fractional gap would make the CSS cell sizing produce uneven rows. + const segmentCount = Math.round(toFiniteNumber(values.vuMeterSegmentCount) ?? LuminaAudioPlayer.VU_METER_DEFAULTS.segmentCount); + const segmentGap = Math.round(toFiniteNumber(values.vuMeterSegmentGap) ?? LuminaAudioPlayer.VU_METER_DEFAULTS.segmentGap); + const mediumThreshold = clamp(toFiniteNumber(values.vuMeterMediumThreshold) ?? LuminaAudioPlayer.VU_METER_DEFAULTS.mediumThreshold, 0, 1); + const highThreshold = clamp(toFiniteNumber(values.vuMeterHighThreshold) ?? LuminaAudioPlayer.VU_METER_DEFAULTS.highThreshold, 0, 1); + const peakHoldDurationInMilliseconds = Math.round(toFiniteNumber(values.vuMeterPeakHoldDurationInMilliseconds) ?? LuminaAudioPlayer.VU_METER_DEFAULTS.peakHoldDurationInMilliseconds); + const releasePerSecond = toFiniteNumber(values.vuMeterReleasePerSecond) ?? LuminaAudioPlayer.VU_METER_DEFAULTS.releasePerSecond; + const peakReleasePerSecond = toFiniteNumber(values.vuMeterPeakReleasePerSecond) ?? LuminaAudioPlayer.VU_METER_DEFAULTS.peakReleasePerSecond; + return { + orientation: normalizeOrientation(values.vuMeterOrientation), + segmentCount: clamp(segmentCount, SEGMENT_COUNT_RANGE.minimum, SEGMENT_COUNT_RANGE.maximum), + segmentGap: clamp(segmentGap, SEGMENT_GAP_RANGE.minimum, SEGMENT_GAP_RANGE.maximum), + mediumThreshold: mediumThreshold, + highThreshold: Math.max(mediumThreshold, highThreshold), + // Compared with false on purpose: a missing value means "not configured", and the default is to show the peak. + showPeak: values.vuMeterShowPeak !== false, + peakHoldDurationInMilliseconds: clamp(peakHoldDurationInMilliseconds, PEAK_HOLD_RANGE.minimum, PEAK_HOLD_RANGE.maximum), + releasePerSecond: clamp(releasePerSecond, RELEASE_RANGE.minimum, RELEASE_RANGE.maximum), + peakReleasePerSecond: clamp(peakReleasePerSecond, RELEASE_RANGE.minimum, RELEASE_RANGE.maximum) + }; + } + + /** + * Analyzes the time domain samples of an analyzer into logarithmically spaced bands. + * + * The time domain samples are windowed with a Hann window, transformed with an iterative radix-2 FFT, and each band combines the power of the bins that fall + * into its frequency range. The browser is used only to deliver the samples through the AnalyserNode of the audio graph, not to compute the transform, so the meter has a sharp + * transient response, like an analyzer that transforms whole blocks of samples. + * + * It is a class of its own, separate from VuMeter, so the signal processing can be tested with plain arrays of samples, + * without a DOM, and so the drawing code never has to know anything about frequencies. + */ + class VuMeterSpectrumAnalyzer { + /** + * Creates an instance of VuMeterSpectrumAnalyzer. + * @param {Object} options - The analyzer options. + * @param {AnalyserNode} options.analyser - The analyzer of the audio graph whose time domain data is read. + * @param {number} [options.bandCount] - The number of bands to produce. Defaults to 24. + * @param {number} [options.minimumFrequency] - The lowest frequency of the first band, in Hz. + * @param {number} [options.maximumFrequency] - The highest frequency of the last band, in Hz. + * @param {number} [options.sampleRate] - The sample rate of the audio context, when the analyzer does not expose it. + * @param {number} [options.fftSize] - The transform size, when the analyzer does not expose it. + */ + constructor(options = {}) { + this.analyser = options.analyser || null; + this.bandCount = clamp(Math.round(toFiniteNumber(options.bandCount) ?? BAND_COUNT), BAND_COUNT_RANGE.minimum, BAND_COUNT_RANGE.maximum); + this.minimumFrequency = toFiniteNumber(options.minimumFrequency) ?? MINIMUM_FREQUENCY; + this.maximumFrequency = toFiniteNumber(options.maximumFrequency) ?? MAXIMUM_FREQUENCY; + this.sampleRate = toFiniteNumber(options.sampleRate) ?? this.readSampleRate(); + this.fftSize = Math.round(toFiniteNumber(options.fftSize) ?? this.readFftSize()); + // Every buffer is allocated once, here, and reused by every analysis. Allocating them per frame would create + // garbage about 23 times a second, and the pauses of the garbage collector show up as visible stutters. + // 'samples' is a Float32Array because that is the type getFloatTimeDomainData fills. The other three are + // Float64Array because the FFT adds up thousands of products, and the extra precision keeps the rounding + // errors of those sums from showing up as noise in the quiet bands. + this.samples = new Float32Array(this.fftSize); + this.window = new Float64Array(this.fftSize); + this.real = new Float64Array(this.fftSize); + this.imaginary = new Float64Array(this.fftSize); + this.bandRanges = []; + this.levels = new Array(this.bandCount).fill(0); + // The time, in seconds, of the last transform. The analyzer transforms a fresh block of samples only, + // not every animation frame, so the level of a band jumps once per block and falls in between. Keeping the same + // cadence is what makes the meter kick on every beat instead of smearing every attack across a sliding window. + this.lastAnalysisTime = null; + // The window and the band ranges only depend on the transform size, the sample rate and the band layout, + // none of which change after construction, so they are computed once instead of on every analysis. + this.buildWindow(); + this.buildBandRanges(); + } + + /** + * Reads the sample rate of the audio context the analyzer belongs to. + * The rate is needed to know which frequency each bin describes. 48 kHz is the fallback because it is the rate most audio hardware, and therefore most audio contexts, run at. + * @returns {number} The sample rate in Hz, or the default rate when it cannot be read. + */ + readSampleRate() { + const context = this.analyser && this.analyser.context; + const sampleRate = context ? toFiniteNumber(context.sampleRate) : null; + return sampleRate !== null && sampleRate > 0 ? sampleRate : 48000; + } + + /** + * Reads the transform size of the analyzer, which the renderer sets to the default size. + * @returns {number} The transform size, or the default size when it cannot be read. + */ + readFftSize() { + const fftSize = this.analyser ? toFiniteNumber(this.analyser.fftSize) : null; + // A transform size must be a power of two, which is what the FFT requires. An analyzer that + // reports anything else is treated as the default size, so the FFT never receives an invalid length. + // 32 to 32768 is the range the Web Audio specification allows for AnalyserNode.fftSize, and + // (n & (n - 1)) === 0 is the usual bit trick to test for a power of two: a power of two has exactly one bit set. + if (fftSize !== null && fftSize >= 32 && fftSize <= 32768 && (fftSize & (fftSize - 1)) === 0) + return fftSize; + return FFT_SIZE; + } + + /** + * Reads the clock the analysis cadence is measured against. + * The audio context clock is preferred because it advances with the audio itself and stands still while the + * context is suspended. VuMeter normally passes its own frame clock to readLevels, so this is only the fallback for a caller, such as a test, that does not. + * @returns {number} The current audio context time in seconds, or the wall clock when there is no context. + */ + readClock() { + const context = this.analyser && this.analyser.context; + const contextTime = context ? toFiniteNumber(context.currentTime) : null; + if (contextTime !== null) + return contextTime; + return typeof performance !== 'undefined' ? performance.now() / 1000 : Date.now() / 1000; + } + + /** + * Builds the Hann window the analyzer applies before the transform. + * + * Why a window is needed: the FFT assumes the block it receives repeats forever, end to start. A block cut out of + * real music almost never ends where it started, so that assumed repetition has a sudden jump at the seam, and + * the FFT reports the jump as energy spread over every frequency ("spectral leakage"). On the meter, a single + * bass note would then light the treble bands too. The Hann window is a smooth bump that is 0 at both ends and 1 + * in the middle; multiplying the samples by it fades the block in and out, which removes the jump. + */ + buildWindow() { + for (let index = 0; index < this.fftSize; index++) + this.window[index] = 0.5 - (0.5 * Math.cos(2 * Math.PI * index / (this.fftSize - 1))); + } + + /** + * Builds the first and the last bin of every band, so a frame only visits the bins it needs. + * + * The bands are spaced logarithmically, not evenly, because hearing works in ratios: every octave doubles the + * frequency, and 40 to 80 Hz sounds like as wide a step as 4000 to 8000 Hz. Evenly spaced bands would spend most + * of the meter on the treble, where the bins are, and squeeze all the bass into the first one or two channels. + * The formula gives every band the same frequency ratio: band b covers + * minimum * (maximum / minimum) ^ (b / count) up to minimum * (maximum / minimum) ^ ((b + 1) / count). + */ + buildBandRanges() { + const binCount = this.fftSize / 2; + this.bandRanges = []; + for (let band = 0; band < this.bandCount; band++) { + const lowFrequency = this.minimumFrequency * Math.pow(this.maximumFrequency / this.minimumFrequency, band / this.bandCount); + const highFrequency = this.minimumFrequency * Math.pow(this.maximumFrequency / this.minimumFrequency, (band + 1) / this.bandCount); + // The first bin is skipped because it carries the DC offset of the signal, which is not audible and would + // only make the lowest band depend on the recording's offset instead of its sound. + // A frequency f falls into bin f * fftSize / sampleRate. The low edge is rounded down and the high edge up, + // so a narrow bass band that falls between two bins still gets at least one bin instead of none. + const firstBin = Math.max(1, Math.floor(lowFrequency * this.fftSize / this.sampleRate)); + const lastBin = Math.min(binCount, Math.ceil(highFrequency * this.fftSize / this.sampleRate)); + this.bandRanges.push({ firstBin: firstBin, lastBin: lastBin }); + } + } + + /** + * Reads the current level of every band when a new transform is due. + * + * The samples of the analyzer are windowed, transformed, and combined per band, and each band is normalized between the noise floor and the display ceiling. A transform is only taken + * after a whole block of new samples has arrived, which analyzes a block of 'fftSize' samples at a time: the frames in between return null, so the meter lets the displayed levels fall + * instead of refreshing them from a sliding, overlapping window. + * Why not analyze on every frame: the AnalyserNode always returns the latest fftSize samples, so two frames 16 ms + * apart would see mostly the same samples. A drum hit would then show up in three or four consecutive analyses and + * hold the bar up, instead of producing one jump followed by a fall, and the meter would look sluggish. + * @param {number} [nowSeconds] - The current time, in seconds. Defaults to the audio context clock. + * @returns {Array|null} One level between 0 and 1 per band, or null when no analyzer is available or no + * new block is due yet. + */ + readLevels(nowSeconds) { + if (!this.analyser || typeof this.analyser.getFloatTimeDomainData !== 'function') + return null; + const now = toFiniteNumber(nowSeconds) ?? this.readClock(); + // How long one block of samples lasts: 2048 samples at 48000 per second is about 0.043 seconds. + const blockSeconds = this.fftSize / this.sampleRate; + // The due time advances by one block from the previous due time rather than from the frame that happened to + // observe it, so the analysis cadence stays close to one block per transform even though the meter renders at the + // display refresh rate. A late frame, such as a resumed tab, resets the due time instead of catching up with a burst of transforms. + const dueTime = this.lastAnalysisTime === null ? now : this.lastAnalysisTime + blockSeconds; + if (this.lastAnalysisTime !== null && now < dueTime) + return null; + // Normally this stores dueTime, which keeps the cadence steady. After a long gap, now - blockSeconds is the + // larger value, so the next analysis is due one block from now rather than immediately again. + this.lastAnalysisTime = Math.max(now - blockSeconds, dueTime); + try { + this.analyser.getFloatTimeDomainData(this.samples); + } catch (error) { + console.debug('Audio player: the VU meter could not read the analyzer samples.', error); + return null; + } + // Step 1: apply the window (see buildWindow). The FFT works on complex numbers, and audio samples are real + // numbers, so the imaginary part starts at zero. It is reset on every analysis because the previous transform left its own results in the array. + for (let index = 0; index < this.fftSize; index++) { + this.real[index] = this.samples[index] * this.window[index]; + this.imaginary[index] = 0; + } + // Step 2: turn the block into frequencies. Afterwards real[k] and imaginary[k] describe bin k. + this.transform(); + // Step 3: turn the bins of every band into one level between 0 and 1. + for (let band = 0; band < this.bandCount; band++) { + const range = this.bandRanges[band]; + let power = 0; + let binCount = 0; + // The power of a bin is its squared magnitude, real^2 + imaginary^2. Power is added up rather than + // magnitude because the energy of independent frequencies adds up, while their magnitudes do not. + for (let bin = range.firstBin; bin < range.lastBin; bin++) { + power += this.real[bin] * this.real[bin] + this.imaginary[bin] * this.imaginary[bin]; + binCount++; + } + // The power is the squared magnitude of the bins, scaled by 2 / fftSize each, so the scale folds into one factor. + // Averaging over the bins (rather than summing) keeps a wide treble band, which has many bins, from always + // reading louder than a narrow bass band with only one or two. The raw FFT output grows with the number of + // samples transformed, and the 2 / fftSize factor scales it back down, so the levels do not change when the transform size does. + const rms = binCount === 0 ? 0 : Math.sqrt(power / binCount) * 2 / this.fftSize; + // Amplitude to decibels. The tiny lower bound avoids Math.log10(0), which is -Infinity, during silence. + const decibels = 20 * Math.log10(Math.max(rms, 1e-9)); + // Map the decibel scale onto 0 to 1: the noise floor (-70 dB) becomes 0, and -10 dB (0 dB minus the display + // gain) becomes 1. For example, a band at -38 dB gives (-38 + 10 + 70) / 70 = 0.6, which is 60% of the meter. + this.levels[band] = clamp((decibels + DISPLAY_GAIN_DB - NOISE_FLOOR_DB) / -NOISE_FLOOR_DB, 0, 1); + } + return this.levels; + } + + /** + * Transforms the windowed samples in place with an iterative radix-2 Cooley-Tukey FFT, the same transform the + * analyzer uses. The transformation is applied to the real and imaginary arrays, so a frame allocates nothing. + * + * The input is the windowed block, the output is one complex number per bin, and the rest of the file only reads the result. + * The algorithm is the textbook "iterative radix-2 Cooley-Tukey FFT", and it works in two stages: + * 1. Reorder the samples by bit reversal. Sample 1 (binary 00000000001) swaps with sample 1024 (binary + * 10000000000), and so on. This puts every pair of samples the next stage combines side by side. + * 2. Combine the samples in rounds ("butterflies"): first pairs, then groups of 4, 8, and so on, up to the whole + * block. Each round merges two half size transforms into one of double size. + * It computes the same result as the direct formula, but in about N * log2(N) steps instead of N * N, which for + * 2048 samples is roughly 22 thousand steps instead of 4 million. + */ + transform() { + const length = this.fftSize; + const real = this.real; + const imaginary = this.imaginary; + // Stage 1: bit reversal. 'reversed' is the bit reversed counterpart of 'index', updated incrementally (adding 1 + // to a bit reversed number means carrying from the top bit downwards) instead of being recomputed every time. + // Each pair is swapped only once, when index < reversed, otherwise the second visit would swap it back. + for (let index = 1, reversed = 0; index < length; index++) { + let bit = length >> 1; + while ((reversed & bit) !== 0) { + reversed ^= bit; + bit >>= 1; + } + reversed ^= bit; + if (index < reversed) { + const realValue = real[index]; + const imaginaryValue = imaginary[index]; + real[index] = real[reversed]; + imaginary[index] = imaginary[reversed]; + real[reversed] = realValue; + imaginary[reversed] = imaginaryValue; + } + } + // Stage 2: the butterflies, with blocks of 2, 4, 8, ... samples. + for (let blockSize = 2; blockSize <= length; blockSize <<= 1) { + // Every element of a block is rotated by a slightly larger angle than the previous one. Instead of calling + // Math.cos and Math.sin for every element, the rotation of one step is computed once per round and then + // applied repeatedly to (offsetReal, offsetImaginary), which is much cheaper. + const angle = -2 * Math.PI / blockSize; + const rotationReal = Math.cos(angle); + const rotationImaginary = Math.sin(angle); + const halfSize = blockSize / 2; + for (let block = 0; block < length; block += blockSize) { + let offsetReal = 1; + let offsetImaginary = 0; + for (let offset = 0; offset < halfSize; offset++) { + // One butterfly: combine an element of the first half of the block with its partner in the second + // half. The partner is rotated first (a complex multiplication), then the pair becomes its sum and its difference. + const evenIndex = block + offset; + const oddIndex = evenIndex + halfSize; + const oddReal = real[oddIndex] * offsetReal - imaginary[oddIndex] * offsetImaginary; + const oddImaginary = real[oddIndex] * offsetImaginary + imaginary[oddIndex] * offsetReal; + real[oddIndex] = real[evenIndex] - oddReal; + imaginary[oddIndex] = imaginary[evenIndex] - oddImaginary; + real[evenIndex] += oddReal; + imaginary[evenIndex] += oddImaginary; + // Advance the rotation by one step for the next element (another complex multiplication). + const nextOffsetReal = offsetReal * rotationReal - offsetImaginary * rotationImaginary; + offsetImaginary = offsetReal * rotationImaginary + offsetImaginary * rotationReal; + offsetReal = nextOffsetReal; + } + } + } + } + } + + /** + * A segmented VU meter bound to the analyzer of the player output. + * + * It owns three things: the DOM elements of the meter, the per channel state (displayed level, peak and peak hold), and the animation loop that moves that state forward once per display frame. + */ + class VuMeter { + /** + * Creates an instance of VuMeter. + * @param {Object} options - The meter options. + * @param {HTMLElement} options.container - The meter root of the bar, carrying the 'data-audio-player-vu-meter' hook. + * @param {Object} [options.settings] - The user settings of the meter, in the shape the user settings endpoint returns. + * @param {Document} [options.document] - The document the elements are created in. Defaults to the current document. + * @param {Function} [options.requestFrame] - The frame scheduler, for a composition or a test. Defaults to requestAnimationFrame. + * @param {Function} [options.cancelFrame] - The frame canceller. Defaults to cancelAnimationFrame. + */ + constructor(options = {}) { + this.container = options.container || null; + this.document = options.document || (typeof document !== 'undefined' ? document : null); + // The scheduler can be injected so a test can step through frames one by one with fake timestamps, instead of + // waiting for real animation frames. requestAnimationFrame is the default because the browser calls it right + // before it paints, once per display refresh, and pauses it in hidden tabs, so the meter never draws frames nobody can see. + this.requestFrame = typeof options.requestFrame === 'function' + ? options.requestFrame + : (typeof requestAnimationFrame === 'function' ? (callback) => requestAnimationFrame(callback) : null); + this.cancelFrame = typeof options.cancelFrame === 'function' + ? options.cancelFrame + : (typeof cancelAnimationFrame === 'function' ? (handle) => cancelAnimationFrame(handle) : null); + this.settings = normalizeSettings(options.settings); + this.analyser = null; + this.spectrum = null; + this.channels = []; + // Per channel state, one entry per band, all between 0 and 1 except the hold times: + // displayLevels - the height the bar is drawn at; it jumps up with the input and then falls at the release rate. + // peakLevels - the height of the peak marker; it only moves up with a new peak, then waits and falls slowly. + // peakHoldUntil - the time, on the meter clock in milliseconds, until which the peak marker stays still. + this.displayLevels = []; + this.peakLevels = []; + this.peakHoldUntil = []; + // True between start and stop. While it is false, the meter ignores the analyzer and only lets the bars fall. + this.isInputActive = false; + this.isDestroyed = false; + /** @type {{ id: *, isFrame: boolean }|null} */ + this.frameHandle = null; + // The state of the frame clock, see advanceClock: the raw timestamp of the previous frame, when the current + // run of frames started and how many frames it had, and the meter's own time in milliseconds. + this.lastFrameTime = null; + this.runStartTime = 0; + this.runFrameCount = 0; + this.clockMilliseconds = 0; + this.build(); + } + + /** + * Gets the normalized settings the meter currently renders with. + * @returns {Object} A frozen copy of the settings. + */ + getSettings() { + // A frozen copy, so a caller can inspect the settings but never change them behind the meter's back. Settings must go through configure, which also updates the DOM. + return Object.freeze({ ...this.settings }); + } + + /** + * Gets a copy of the levels that were rendered last. + * @returns {Array} The displayed level of every channel, between 0 and 1. + */ + getLevels() { + return [...this.displayLevels]; + } + + /** + * Checks whether the meter is reading the analyzer. + * @returns {boolean} True while the frame loop reads the analyzer. + */ + isActive() { + return this.isInputActive; + } + + /** + * Applies a new settings object. A change of the segment count rebuilds the channels, because the number of + * segments is part of the markup; every other setting is applied in place, so a change never drops the levels. + * @param {Object} settings - The user settings of the meter, in the shape the user settings endpoint returns. + * @returns {LuminaAudioPlayer.VuMeter} This meter, for chaining. + */ + configure(settings) { + if (this.isDestroyed) + return this; + const next = normalizeSettings(settings); + const previousSegmentCount = this.settings.segmentCount; + this.settings = next; + if (!this.container) + return this; + // The channel count check covers a meter whose markup was never fully built, for example because it had no document at construction time; such a meter gets its elements now. + if (next.segmentCount !== previousSegmentCount || this.channels.length !== BAND_COUNT) { + this.build(); + return this; + } + this.container.dataset.audioPlayerVuMeterOrientation = next.orientation; + this.container.dataset.audioPlayerVuMeterSegments = String(next.segmentCount); + this.container.dataset.audioPlayerVuMeterShowPeak = next.showPeak ? 'true' : 'false'; + this.container.style.setProperty('--audio-player-vu-segment-gap', `${next.segmentGap}px`); + this.container.style.setProperty('--audio-player-vu-segment-count', String(next.segmentCount)); + for (const channel of this.channels) { + if (channel.peak) + channel.peak.hidden = !next.showPeak; + } + // Redraw once so a changed threshold or peak option shows at once, even while the frame loop is idle. + this.ensureLevelArrays(); + for (let band = 0; band < this.channels.length; band++) + this.renderChannel(band, this.displayLevels[band], this.peakLevels[band]); + return this; + } + + /** + * Binds the analyzer the meter reads from. Passing a different analyzer replaces the previous one and resets the + * displayed levels, because the levels of another graph do not describe this one. + * @param {AnalyserNode|null} analyser - The analyzer of the player output, or null to detach. + * @returns {LuminaAudioPlayer.VuMeter} This meter, for chaining. + */ + setAnalyser(analyser) { + if (this.isDestroyed) + return this; + // Binding the same analyzer again is a no-op, so the player can call this freely (for example on every track change) without the meter flashing back to empty each time. + if (this.analyser === analyser) + return this; + this.analyser = analyser || null; + // A new VuMeterSpectrumAnalyzer is created because its buffers and band ranges depend on the sample rate and + // the transform size of this particular analyzer. + this.spectrum = this.analyser ? new VuMeterSpectrumAnalyzer({ analyser: this.analyser, bandCount: BAND_COUNT }) : null; + this.reset(); + if (this.isInputActive) + this.startFrameLoop(); + return this; + } + + /** + * Starts reading the analyzer. The frame loop runs while the meter is active, and then for as long as a channel + * still shows a level, so stopping the player never leaves a frozen meter behind. + */ + start() { + if (this.isDestroyed) + return; + this.isInputActive = true; + this.startFrameLoop(); + } + + /** + * Stops reading the analyzer and lets the displayed levels and peaks fall to zero. + */ + stop() { + if (this.isDestroyed || !this.isInputActive) + return; + this.isInputActive = false; + // Stopping still needs frames: the bars have to fall to zero smoothly rather than vanish. The loop is started + // (it may already be running), and renderFrame ends it by itself once every channel is empty. + this.startFrameLoop(); + } + + /** + * Resets every displayed level and peak to zero, and draws the empty meter once. + */ + reset() { + const bandCount = this.channels.length; + this.displayLevels = new Array(bandCount).fill(0); + this.peakLevels = new Array(bandCount).fill(0); + this.peakHoldUntil = new Array(bandCount).fill(0); + for (let channel = 0; channel < bandCount; channel++) + this.renderChannel(channel, 0, 0); + } + + /** + * Releases the frame loop and the element references. The generated channels are removed from the root, so a later meter bound to the same root starts from a clean shell. + */ + destroy() { + // The flag is set first, because a frame that was already queued may still fire once; every public method and + // renderFrame check it and do nothing on a destroyed meter. + this.isDestroyed = true; + this.isInputActive = false; + this.cancelFrameLoop(); + this.clear(); + this.channels = []; + this.displayLevels = []; + this.peakLevels = []; + this.peakHoldUntil = []; + this.analyser = null; + this.spectrum = null; + } + + //+======================================================================================+ + //| Internal helpers | + //+======================================================================================+ + + /** + * Creates the channels, segments and peak markers from the current settings. + */ + build() { + // Start from an empty root, so building twice (for example after a segment count change) never leaves the channels of the previous configuration behind. + this.clear(); + if (!this.container || !this.document) + return; + const next = this.settings; + this.container.style.setProperty('--audio-player-vu-band-count', String(BAND_COUNT)); + this.container.dataset.audioPlayerVuMeterOrientation = next.orientation; + this.container.dataset.audioPlayerVuMeterSegments = String(next.segmentCount); + this.container.dataset.audioPlayerVuMeterShowPeak = next.showPeak ? 'true' : 'false'; + this.container.style.setProperty('--audio-player-vu-segment-gap', `${next.segmentGap}px`); + this.container.style.setProperty('--audio-player-vu-segment-count', String(next.segmentCount)); + this.channels = []; + for (let band = 0; band < BAND_COUNT; band++) { + const channelElement = this.document.createElement('div'); + channelElement.className = 'audio-player-vu-channel'; + channelElement.dataset.audioPlayerVuChannel = String(band); + const segments = []; + for (let index = 0; index < next.segmentCount; index++) { + const segmentElement = this.document.createElement('div'); + segmentElement.className = 'audio-player-vu-segment'; + segmentElement.dataset.audioPlayerVuSegment = ''; + segmentElement.dataset.audioPlayerVuSegmentState = 'inactive'; + // The zone is decided by the level at the top of the segment: with 12 segments, segment 0 covers + // the levels up to 1/12, so it is checked at 1/12, and the last segment is checked at 1. + const zone = this.getZone((index + 1) / next.segmentCount); + segmentElement.dataset.audioPlayerVuSegmentZone = zone; + channelElement.appendChild(segmentElement); + // The values last written to the DOM are remembered next to the element, so renderChannel can compare + // against them instead of reading the attribute back from the DOM, which is slower. + segments.push({ element: segmentElement, renderedState: 'inactive', renderedZone: zone }); + } + const peakElement = this.document.createElement('div'); + peakElement.className = 'audio-player-vu-peak'; + peakElement.dataset.audioPlayerVuPeak = ''; + peakElement.dataset.audioPlayerVuPeakState = 'inactive'; + peakElement.hidden = !next.showPeak; + channelElement.appendChild(peakElement); + this.container.appendChild(channelElement); + this.channels.push({ element: channelElement, segments: segments, peak: peakElement, renderedPeak: null }); + } + this.reset(); + } + + /** + * Removes every generated element from the meter root. + */ + clear() { + if (!this.container) + return; + // replaceChildren with no arguments removes every child in one call. + this.container.replaceChildren(); + } + + /** + * Resolves the style zone of a segment from its position on the channel. + * The comparisons are strict (greater than, not greater or equal), so a segment whose top sits exactly on a + * threshold still belongs to the lower zone: with thresholds of 0.6 and 0.8 and ten segments, the sixth segment (top at 0.6) is the last normal one. + * @param {number} position - The level of the segment, between 0 and 1, at which it becomes active. + * @returns {string} 'normal', 'medium' or 'high'. + */ + getZone(position) { + if (position > this.settings.highThreshold) + return 'high'; + return position > this.settings.mediumThreshold ? 'medium' : 'normal'; + } + + /** + * Starts the frame loop when it is not already running. + */ + startFrameLoop() { + // A pending frame means the loop is already running. Starting a second one would make the meter advance twice per display frame, so the bars would fall at double speed. + if (this.frameHandle !== null || this.isDestroyed) + return; + // Forget the previous frame, so the first frame of this run does not see the whole idle time as its duration. + this.lastFrameTime = null; + if (!this.requestFrame) { + // Without an animation frame the meter still renders the first frame, so its state is correct; only the + // animation is missing, which is a reduced motion fallback rather than a broken meter. + this.renderFrame(0); + return; + } + this.scheduleFrame(); + } + + /** + * Schedules the next frame. + */ + scheduleFrame() { + if (!this.requestFrame) + return; + const tick = (timestamp) => { + // The handle is cleared before rendering, because renderFrame decides whether to schedule the next frame, and scheduling only works while no frame is pending. + this.frameHandle = null; + this.renderFrame(timestamp); + }; + try { + const id = this.requestFrame(tick); + // An injected scheduler may not return an id. Without an id the frame cannot be cancelled, so canCancel records whether cancelFrameLoop may try. + this.frameHandle = { id: id, isFrame: true, canCancel: id !== undefined && id !== null }; + } catch (error) { + console.debug('Audio player: the VU meter could not schedule its frame.', error); + this.frameHandle = null; + } + } + + /** + * Cancels the pending frame, when there is one. + */ + cancelFrameLoop() { + if (this.frameHandle === null) + return; + const handle = this.frameHandle; + this.frameHandle = null; + if (!this.cancelFrame || handle.canCancel !== true) + return; + try { + if (handle.isFrame === true) + this.cancelFrame(handle.id); + else + clearTimeout(handle.id); + } catch (error) { + console.debug('Audio player: the VU meter frame could not be cancelled.', error); + } + } + + /** + * Advances the frame clock of the meter and returns the time the frame lasted. + * + * Every duration of the meter, the falloff, the peak hold and the analysis cadence, is measured on this clock + * instead of on the raw frame timestamp, because a browser that resists fingerprinting, such as LibreWolf or + * Firefox with that protection on, rounds the timestamps to steps of 100 milliseconds or more. A frame would then + * see a delta of zero, followed by a delta of a hundred milliseconds, so the bars would fall in lumps and the + * analysis would run about ten times a second. A delta that looks like a real frame is used as it is. A delta that + * cannot be one, because it is zero or far longer than a frame, is replaced by the average frame duration measured + * over the whole run, which converges even when every single timestamp is coarse. + * (Browsers round timestamps on purpose: precise timers let a page measure tiny differences in how fast the + * machine runs, which can identify a user or leak data between pages.) + * + * The meter works with elapsed time rather than a fixed step per frame so it moves at the same speed on a 60 Hz + * and on a 144 Hz display: a release of 3 per second must take a full bar down in a third of a second on both. + * @param {number} [timestamp] - The frame timestamp, in milliseconds. Defaults to the current time. + * @returns {number} The duration of the frame, in seconds. + */ + advanceClock(timestamp) { + const raw = toFiniteNumber(timestamp) ?? (typeof performance !== 'undefined' ? performance.now() : Date.now()); + let elapsed = 1 / 60; + if (this.lastFrameTime === null) { + // The first frame of a run has nothing to measure against, so it lasts zero seconds and starts the run. + this.runStartTime = raw; + this.runFrameCount = 0; + elapsed = 0; + } else { + this.runFrameCount++; + const delta = raw - this.lastFrameTime; + const runSeconds = (raw - this.runStartTime) / 1000; + // The average only becomes trustworthy after enough frames to smooth out the rounding, so it waits for 30 + // frames (about half a second) and assumes a 60 Hz display until then. + const average = this.runFrameCount >= 30 && runSeconds > 0 ? runSeconds / this.runFrameCount : 1 / 60; + const isPlausible = delta >= MINIMUM_REAL_FRAME_MS && delta <= MAXIMUM_REAL_FRAME_MS; + // The lower bound (a 240 Hz frame) keeps a bogus tiny delta from stalling the animation, and the upper bound is MAXIMUM_FRAME_SECONDS (see its comment). + elapsed = clamp(isPlausible ? delta / 1000 : average, 1 / 240, MAXIMUM_FRAME_SECONDS); + } + this.lastFrameTime = raw; + this.clockMilliseconds += elapsed * 1000; + return elapsed; + } + + /** + * Advances the meter by one frame: reads the analyzer, applies the attack, the release and the peak hold, and renders the result. + * @param {number} [timestamp] - The frame timestamp, in milliseconds. Defaults to the current time. + */ + renderFrame(timestamp) { + if (this.isDestroyed) + return; + const elapsed = this.advanceClock(timestamp); + const now = this.clockMilliseconds; + // levels is null on most frames: either the meter is stopped, or no new block of samples is due yet (see + // readLevels). A null means "no new measurement", not "silence", so the code below only lets the bars fall. + const levels = this.isInputActive && this.spectrum ? this.spectrum.readLevels(now / 1000) : null; + this.ensureLevelArrays(); + // How far a bar and a peak marker fall during this frame. A rate is in level units per second, so multiplying it + // by the frame duration gives the fall for this frame: 3 per second over a 1/60 second frame is 0.05. + const levelStep = this.settings.releasePerSecond * elapsed; + const peakStep = this.settings.peakReleasePerSecond * elapsed; + const holdMilliseconds = this.settings.peakHoldDurationInMilliseconds; + let hasVisibleLevel = false; + for (let band = 0; band < this.channels.length; band++) { + const input = levels && band < levels.length ? clamp(levels[band], 0, 1) : 0; + // Attack: a louder measurement moves the bar up at once. A quieter one is ignored here, because the bar + // must come down at the release rate rather than jump down. + if (levels && input > this.displayLevels[band]) + this.displayLevels[band] = input; + // Release: every frame, the bar falls by one step. It also runs on the frame a new level arrived, so a bar + // starts falling straight away; this is what makes a beat read as a short, sharp kick. + this.displayLevels[band] = Math.max(0, this.displayLevels[band] - levelStep); + // A new peak, or a level that reaches the current peak again, moves the marker there and restarts its hold. + // Greater or equal (not just greater) keeps the marker parked while a sustained note stays at the same level. + if (levels && input >= this.peakLevels[band]) { + this.peakLevels[band] = input; + this.peakHoldUntil[band] = now + holdMilliseconds; + } + // Once the hold time is over, the marker falls at its own, usually slower, rate. + if (now >= this.peakHoldUntil[band]) + this.peakLevels[band] = Math.max(0, this.peakLevels[band] - peakStep); + this.renderChannel(band, this.displayLevels[band], this.peakLevels[band]); + if (this.displayLevels[band] > 0 || this.peakLevels[band] > 0) + hasVisibleLevel = true; + } + // A meter that is not reading the analyzer draws its last falling frame, then releases the loop. An active + // meter keeps its loop while it has an analyzer to read, because new levels can arrive at any frame. + if ((this.isInputActive && this.spectrum) || hasVisibleLevel) + this.scheduleFrame(); + else + this.cancelFrameLoop(); + } + + /** + * Makes sure the per channel state arrays match the rendered channels. + * They can fall out of step when the channels are rebuilt. The displayed levels are carried over, so a rebuild + * does not make the bars flash to empty, while the peaks and their hold times simply start over. + */ + ensureLevelArrays() { + const count = this.channels.length; + if (this.displayLevels.length !== count) { + const previous = this.displayLevels; + this.displayLevels = new Array(count).fill(0); + for (let index = 0; index < Math.min(previous.length, count); index++) + this.displayLevels[index] = previous[index]; + } + if (this.peakLevels.length !== count) + this.peakLevels = new Array(count).fill(0); + if (this.peakHoldUntil.length !== count) + this.peakHoldUntil = new Array(count).fill(0); + } + + /** + * Renders one channel, writing only the attributes that changed since the last frame. + * Writing an attribute, even with the value it already has, makes the browser re-check the styles of that element. + * With 24 channels of 12 segments that is 288 elements per frame, so skipping unchanged writes is what keeps the meter cheap. + * @param {number} band - The zero based channel index. + * @param {number} level - The displayed level of the channel, between 0 and 1. + * @param {number} peak - The held peak level of the channel, between 0 and 1. + */ + renderChannel(band, level, peak) { + const channel = this.channels[band]; + if (!channel) + return; + // Rounded up, so any level above zero lights at least one segment and quiet sound is still visible. + const activeSegments = Math.ceil(clamp(level, 0, 1) * this.settings.segmentCount); + for (let index = 0; index < channel.segments.length; index++) { + const segment = channel.segments[index]; + const state = index < activeSegments ? 'active' : 'inactive'; + if (segment.renderedState !== state) { + segment.element.dataset.audioPlayerVuSegmentState = state; + segment.renderedState = state; + } + // The zone is checked here as well, and not only in build, because configure changes the thresholds without rebuilding the segments. + const zone = this.getZone((index + 1) / this.settings.segmentCount); + if (segment.renderedZone !== zone) { + segment.element.dataset.audioPlayerVuSegmentZone = zone; + segment.renderedZone = zone; + } + } + if (!channel.peak) + return; + if (!this.settings.showPeak) { + if (channel.renderedPeak !== null) { + channel.peak.dataset.audioPlayerVuPeakState = 'inactive'; + channel.renderedPeak = null; + } + return; + } + const position = clamp(peak, 0, 1); + const state = position > 0 ? 'active' : 'inactive'; + // The position is written as a percentage of the channel axis, so the theme maps it to whichever axis its own + // layout uses. A small tolerance keeps sub pixel movement from rewriting the property every frame. + // 0.005 is half a percent of the channel, which on a 47 pixel meter is less than a quarter of a pixel. An + // inactive marker is always written, so a marker that falls to zero lands exactly at 0%. + if (channel.renderedPeak === null || Math.abs(channel.renderedPeak - position) >= 0.005 || state === 'inactive') { + channel.peak.style.setProperty('--audio-player-vu-peak-position', `${position * 100}%`); + channel.renderedPeak = position; + } + if (channel.peak.dataset.audioPlayerVuPeakState !== state) + channel.peak.dataset.audioPlayerVuPeakState = state; + } + } + + LuminaAudioPlayer.VuMeterSpectrumAnalyzer = VuMeterSpectrumAnalyzer; + LuminaAudioPlayer.VuMeter = VuMeter; + + /** + * Creates a VU meter. See {@link LuminaAudioPlayer.VuMeter} for the options. + * @param {Object} options - The meter options. + * @returns {LuminaAudioPlayer.VuMeter} The created meter. + */ + LuminaAudioPlayer.createVuMeter = function (options) { + return new VuMeter(options); + }; +})(window.LuminaAudioPlayer = window.LuminaAudioPlayer || {}); diff --git a/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player.js b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player.js index f2b93e64..bab31098 100644 --- a/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player.js +++ b/src/Lumina.Presentation.Web/wwwroot/js/audio-player/audio-player.js @@ -57,6 +57,8 @@ * - getState(), getDescriptor(), getQueue(), getCurrentTime(), getDuration(), getVolume(), * isMuted(), isBuffering(), getBufferedTimeRanges(), getPreferences(), getCapabilities(), getLastError(), * getSubTemplates(). + * - reloadPreferencesAsync(): re-reads the stored settings and playback state of the user, so a change saved on the + * settings page applies to the running player, including the VU meter settings. * - getNextDescriptor(): the identity and descriptor of the next queue entry, or null. * - advanceQueueTo(entryId): moves the queue cursor to the entry with that identity without starting playback, so a * linear advance, a wrap, a reordered queue and a gapless handoff share one commit. The advance @@ -646,7 +648,16 @@ isGaplessPlaybackEnabled: false, replayGainMode: 'Off', streamingQuality: 'Auto', - shouldIgnoreThePrefixForAlphaPicker: false + shouldIgnoreThePrefixForAlphaPicker: false, + vuMeterOrientation: 'Vertical', + vuMeterSegmentCount: 12, + vuMeterSegmentGap: 1, + vuMeterMediumThreshold: 0.6, + vuMeterHighThreshold: 0.8, + vuMeterShowPeak: true, + vuMeterPeakHoldDurationInMilliseconds: 650, + vuMeterReleasePerSecond: 3, + vuMeterPeakReleasePerSecond: 0.65 }; this.capabilityReport = null; this.capabilitiesReady = null; @@ -704,6 +715,12 @@ this.container = null; this.main = null; this.dom = {}; + // The VU meter of the bar, created with the bar elements, and the subscription that follows the stored settings. + // Both are null when the VU meter module was not loaded, so a bare player composition, or a test, still works. + this.vuMeter = null; + this.vuMeterUnsubscribe = null; + // The analyzer the meter was bound to, so a load replaces it only when the engine exposes a different one. + this.vuMeterAnalyser = null; // The raw theme sub templates of the dynamic content, read once with the bar elements and null when the theme does not provide them. this.subTemplates = { queueItem: null, playlistItem: null }; // The playlists of the user, used by the control that adds the current queue to a playlist, and the in flight load of @@ -754,6 +771,7 @@ this.isAvailable = true; this.collectDomReferences(); + this.ensureVuMeter(); this.bindPlaybackControls(); this.bindKeyboardShortcuts(); this.bindUnloadFlush(); @@ -784,6 +802,7 @@ this.dom.albumName = query('[data-audio-player-album-name]'); this.dom.coverThumbnail = query('[data-audio-player-cover-thumbnail]'); this.dom.coverImage = query('[data-audio-player-cover-image]'); + this.dom.vuMeter = query('[data-audio-player-vu-meter]'); this.dom.currentTime = query('[data-audio-player-current-time]'); this.dom.totalTime = query('[data-audio-player-total-time]'); this.dom.progress = query('[data-audio-player-progress]'); @@ -816,6 +835,92 @@ this.ensurePlaylistControls(); } + /** + * Creates the VU meter of the bar, building its root when the active theme does not render the hook. + * + * The meter is part of the bar rather than of the page, so it is created once with the bar elements and survives + * every in place navigation. A theme that renders the 'data-audio-player-vu-meter' hook decides where the meter + * sits; a theme that does not gets the built-in meter inserted directly before the current time label, which is the place the bar reserves for it. + * The module is optional: a composition that omits it keeps a playable bar with no meter. + */ + ensureVuMeter() { + if (typeof LuminaAudioPlayer.createVuMeter !== 'function') + return; + if (!this.dom.vuMeter) { + const bar = this.container.querySelector('.audio-player-bar'); + if (!bar) + return; + const meterElement = document.createElement('div'); + meterElement.className = 'audio-player-vu-meter'; + meterElement.dataset.audioPlayerVuMeter = ''; + meterElement.setAttribute('aria-hidden', 'true'); + // The current time label is the anchor the bar reserves for the meter: the meter sits between the album art + // and the label that shows the current playback time. Only a label that is a direct child of the bar can be + // used as an insertion reference, so a theme with a nested label appends the meter to the bar instead. + const reference = this.dom.currentTime && this.dom.currentTime.parentNode === bar ? this.dom.currentTime : null; + bar.insertBefore(meterElement, reference); + this.dom.vuMeter = meterElement; + } + this.vuMeter = LuminaAudioPlayer.createVuMeter({ + container: this.dom.vuMeter, + settings: this.preferences + }); + if (this.events && typeof this.events.on === 'function') + this.vuMeterUnsubscribe = this.events.on(LuminaAudioPlayer.PlayerEvent.PREFERENCES_CHANGED, () => this.applyVuMeterSettings()); + } + + /** + * Applies the current preferences to the VU meter, so a settings change that arrives after the bar was built, or + * a change saved on the settings page, takes effect without recreating the player. + */ + applyVuMeterSettings() { + if (!this.vuMeter) + return; + this.vuMeter.configure(this.preferences); + } + + /** + * Binds the meter to the output analyzer of the engine once a track was loaded. The renderer creates its audio + * context, and with it the analyzer, when it configures a track, so the analyzer only exists from that point on. + * An engine that exposes no analyzer, or a renderer whose context cannot create one, leaves the meter empty. + * @param {Object} engine - The engine the track was loaded into. + */ + attachVuMeter(engine) { + if (!this.vuMeter || !engine || typeof engine.getOutputAnalyser !== 'function') + return; + let analyser = null; + try { + analyser = engine.getOutputAnalyser(); + } catch (error) { + console.debug('Audio player: the engine output analyzer could not be read.', error); + return; + } + if (!analyser || analyser === this.vuMeterAnalyser) + return; + this.vuMeterAnalyser = analyser; + this.vuMeter.setAnalyser(analyser); + // The state may already be PLAYING when a load replaced the engine under a running player, so a fresh analyzer + // starts reading immediately instead of waiting for the next state change. + if (this.state === LuminaAudioPlayer.PlayerState.PLAYING) + this.vuMeter.start(); + } + + /** + * Starts or stops the VU meter with the player state. A playing, visible player reads the analyzer, and every + * other case lets the meter fall to zero, so a pause, a stop, an end, a failure, or a hidden bar never leaves a + * frozen meter on screen and a hidden meter costs no animation frames. + * @param {string} state - One of the {@link LuminaAudioPlayer.PlayerState} values. + */ + updateVuMeterState(state) { + if (!this.vuMeter) + return; + const isVisible = !this.container || !this.container.classList.contains('not-shown'); + if (state === LuminaAudioPlayer.PlayerState.PLAYING && isVisible) + this.vuMeter.start(); + else + this.vuMeter.stop(); + } + /** * Binds the transport controls the player owns: the play and pause toggle, the scrub of the progress bar and * of the volume control, and the mute toggle. The expand and close affordances are bound by the global site @@ -1394,6 +1499,9 @@ await engine.loadAsync(descriptor, options); if (!isRequestCurrent()) return false; + // The load configured the renderer of the engine, which creates its audio context and the output analyzer of + // the VU meter. Binding it here, once per load, also covers an engine swap under a running player. + this.attachVuMeter(engine); if (this.state !== LuminaAudioPlayer.PlayerState.LOADING) { // A stop during the load already paused the engine; a newer request owns the player state and must not be touched by this stale continuation. if (this.state === LuminaAudioPlayer.PlayerState.IDLE) @@ -1950,6 +2058,8 @@ this.main.classList.remove('audio-player-not-shown'); if (wasHidden) this.events.emit(LuminaAudioPlayer.PlayerEvent.VISIBILITY_CHANGED, { isVisible: true }); + // A bar that becomes visible while a track plays starts the VU meter, which was stopped while the bar was out of sight. + this.updateVuMeterState(this.state); } /** @@ -1968,6 +2078,8 @@ if (this.main) this.main.classList.add('audio-player-not-shown'); this.events.emit(LuminaAudioPlayer.PlayerEvent.VISIBILITY_CHANGED, { isVisible: false }); + // A bar that is out of sight stops reading the analyzer, so a hidden meter costs no animation frames. + this.updateVuMeterState(this.state); } /** @@ -2669,6 +2781,20 @@ return Object.freeze({ ...this.preferences }); } + /** + * Re-reads the stored settings and playback state of the user, without recreating the player. + * + * It is meant for a consumer that knows the stored settings changed while the player is running, such as the + * settings page after it saved them, so the change applies immediately instead of on the next full page load. The + * read is the same one the player performs at startup, so it never overwrites a volume or a mute state the user changed in the meantime. + * @returns {Promise} A promise that completes when the preferences were read. + */ + async reloadPreferencesAsync() { + if (!this.isAvailable) + return; + await this.loadPreferencesAsync(); + } + /** * Gets the last capability report, or null when detection has not completed yet. * @returns {Object|null} The capability report. @@ -2751,6 +2877,15 @@ } this.engine = null; } + if (this.vuMeterUnsubscribe) { + this.vuMeterUnsubscribe(); + this.vuMeterUnsubscribe = null; + } + if (this.vuMeter) { + this.vuMeter.destroy(); + this.vuMeter = null; + } + this.vuMeterAnalyser = null; this.events.clear(); this.setState(LuminaAudioPlayer.PlayerState.IDLE); // The singleton is no longer usable, so it is cleared, and a later createDefaultPlayer builds a fresh one. @@ -2775,6 +2910,7 @@ console.warn(`Audio player: the transition '${previousState}' -> '${nextState}' is not part of the state machine.`); this.state = nextState; this.events.emit(LuminaAudioPlayer.PlayerEvent.STATE_CHANGED, { previousState, state: nextState }); + this.updateVuMeterState(nextState); } /** @@ -3277,7 +3413,16 @@ isGaplessPlaybackEnabled: settings.isGaplessPlaybackEnabled === true, replayGainMode: settings.replayGainMode || 'Off', streamingQuality: settings.streamingQuality || 'Auto', - shouldIgnoreThePrefixForAlphaPicker: settings.shouldIgnoreThePrefixForAlphaPicker === true + shouldIgnoreThePrefixForAlphaPicker: settings.shouldIgnoreThePrefixForAlphaPicker === true, + vuMeterOrientation: settings.vuMeterOrientation || 'Vertical', + vuMeterSegmentCount: LuminaAudioPlayer.toFiniteNumber(settings.vuMeterSegmentCount) ?? 12, + vuMeterSegmentGap: LuminaAudioPlayer.toFiniteNumber(settings.vuMeterSegmentGap) ?? 1, + vuMeterMediumThreshold: LuminaAudioPlayer.toFiniteNumber(settings.vuMeterMediumThreshold) ?? 0.6, + vuMeterHighThreshold: LuminaAudioPlayer.toFiniteNumber(settings.vuMeterHighThreshold) ?? 0.8, + vuMeterShowPeak: settings.vuMeterShowPeak !== false, + vuMeterPeakHoldDurationInMilliseconds: LuminaAudioPlayer.toFiniteNumber(settings.vuMeterPeakHoldDurationInMilliseconds) ?? 650, + vuMeterReleasePerSecond: LuminaAudioPlayer.toFiniteNumber(settings.vuMeterReleasePerSecond) ?? 3, + vuMeterPeakReleasePerSecond: LuminaAudioPlayer.toFiniteNumber(settings.vuMeterPeakReleasePerSecond) ?? 0.65 }; // The payload is a frozen copy, so a subscriber that mutates it cannot change the preferences the player uses. this.events.emit(LuminaAudioPlayer.PlayerEvent.PREFERENCES_CHANGED, Object.freeze({ ...this.preferences })); diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserSettingsEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserSettingsEntityFixture.cs index 9997a6ae..7b646a47 100644 --- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserSettingsEntityFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserSettingsEntityFixture.cs @@ -33,6 +33,15 @@ public class UserSettingsEntityFixture /// Optional. Whether the player transitions between consecutive tracks without a gap, or not. /// Optional. The way ReplayGain normalization is applied to the tracks the user plays. /// Optional. The quality cap applied to the audio the server normalizes for the user. + /// Optional. The direction in which each channel of the VU meter of the audio player grows. + /// Optional. The number of segments each channel of the VU meter is divided into. + /// Optional. The gap, in pixels, between the segments and the channels of the VU meter. + /// Optional. The level above which a segment of the VU meter is drawn with its medium state. + /// Optional. The level above which a segment of the VU meter is drawn with its high state. + /// Optional. Whether the VU meter holds the peak level of each channel after it falls. + /// Optional. The time a peak of the VU meter is held before it starts falling. + /// Optional. The number of level units the display of the VU meter falls per second when the input level drops. + /// Optional. The number of level units the peak of the VU meter falls per second after its hold time elapsed. /// Optional. The last volume the player reported for the user. /// Optional. The last mute state the player reported for the user. /// The created user settings entity. @@ -51,28 +60,51 @@ public class UserSettingsEntityFixture bool? isGaplessPlaybackEnabled = null, ReplayGainMode? replayGainMode = null, PlaybackStreamingQuality? streamingQuality = null, + VuMeterOrientation? vuMeterOrientation = null, + int? vuMeterSegmentCount = null, + int? vuMeterSegmentGap = null, + double? vuMeterMediumThreshold = null, + double? vuMeterHighThreshold = null, + bool? vuMeterShowPeak = null, + int? vuMeterPeakHoldDurationInMilliseconds = null, + double? vuMeterReleasePerSecond = null, + double? vuMeterPeakReleasePerSecond = null, double? volume = null, bool? isMuted = null) { return new Faker() - .CustomInstantiator(f => new UserSettingsEntity + .CustomInstantiator(f => { - Id = id ?? Guid.NewGuid(), - UserId = userId ?? Guid.NewGuid(), - IsPaginationEnabled = isPaginationEnabled ?? f.Random.Bool(), - ItemsPerPage = itemsPerPage ?? f.Random.Int(1, 100), - ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool(), - IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool(), - ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? f.Random.Bool(), - ShouldRenderPdfAsImages = shouldRenderPdfAsImages ?? f.Random.Bool(), - ShouldPreserveBookStyles = shouldPreserveBookStyles ?? f.Random.Bool(), - ShouldKeepDownloadingWhilePaused = shouldKeepDownloadingWhilePaused ?? f.Random.Bool(), - ShouldAutoplay = shouldAutoplay ?? f.Random.Bool(), - IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled ?? f.Random.Bool(), - ReplayGainMode = replayGainMode ?? f.PickRandom(), - StreamingQuality = streamingQuality ?? f.PickRandom(), - Volume = volume ?? f.Random.Double(0.0, 1.0), - IsMuted = isMuted ?? f.Random.Bool() + // The high threshold is generated from the medium one, so a randomized entity always describes a valid meter. + double mediumThreshold = vuMeterMediumThreshold ?? f.Random.Double(0, 1); + return new UserSettingsEntity + { + Id = id ?? Guid.NewGuid(), + UserId = userId ?? Guid.NewGuid(), + IsPaginationEnabled = isPaginationEnabled ?? f.Random.Bool(), + ItemsPerPage = itemsPerPage ?? f.Random.Int(1, 100), + ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool(), + IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool(), + ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? f.Random.Bool(), + ShouldRenderPdfAsImages = shouldRenderPdfAsImages ?? f.Random.Bool(), + ShouldPreserveBookStyles = shouldPreserveBookStyles ?? f.Random.Bool(), + ShouldKeepDownloadingWhilePaused = shouldKeepDownloadingWhilePaused ?? f.Random.Bool(), + ShouldAutoplay = shouldAutoplay ?? f.Random.Bool(), + IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled ?? f.Random.Bool(), + ReplayGainMode = replayGainMode ?? f.PickRandom(), + StreamingQuality = streamingQuality ?? f.PickRandom(), + VuMeterOrientation = vuMeterOrientation ?? f.PickRandom(), + VuMeterSegmentCount = vuMeterSegmentCount ?? f.Random.Int(1, 128), + VuMeterSegmentGap = vuMeterSegmentGap ?? f.Random.Int(0, 32), + VuMeterMediumThreshold = mediumThreshold, + VuMeterHighThreshold = vuMeterHighThreshold ?? f.Random.Double(mediumThreshold, 1), + VuMeterShowPeak = vuMeterShowPeak ?? f.Random.Bool(), + VuMeterPeakHoldDurationInMilliseconds = vuMeterPeakHoldDurationInMilliseconds ?? f.Random.Int(0, 10000), + VuMeterReleasePerSecond = vuMeterReleasePerSecond ?? f.Random.Double(0, 100), + VuMeterPeakReleasePerSecond = vuMeterPeakReleasePerSecond ?? f.Random.Double(0, 100), + Volume = volume ?? f.Random.Double(0.0, 1.0), + IsMuted = isMuted ?? f.Random.Bool() + }; }) .Generate(); } diff --git a/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs index 73f32c90..b66d28e9 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandFixture.cs @@ -2,6 +2,7 @@ using Bogus; using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSettings; using Lumina.Domain.SharedKernel.Common.Enums.Playback; +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -31,6 +32,15 @@ public class UpdateUserSettingsCommandFixture /// Optional. Whether the player transitions between consecutive tracks without a gap, or not. /// Optional. The way ReplayGain normalization is applied to the tracks the user plays. /// Optional. The quality cap applied to the audio the server normalizes for the user. + /// Optional. The direction in which each channel of the VU meter of the audio player grows. + /// Optional. The number of segments each channel of the VU meter is divided into. + /// Optional. The gap, in pixels, between the segments and the channels of the VU meter. + /// Optional. The level above which a segment of the VU meter is drawn with its medium state. + /// Optional. The level above which a segment of the VU meter is drawn with its high state. + /// Optional. Whether the VU meter holds the peak level of each channel after it falls. + /// Optional. The time a peak of the VU meter is held before it starts falling. + /// Optional. The number of level units the display of the VU meter falls per second when the input level drops. + /// Optional. The number of level units the peak of the VU meter falls per second after its hold time elapsed. /// The created command. public UpdateUserSettingsCommand Create( bool? isPaginationEnabled = null, @@ -45,10 +55,22 @@ public class UpdateUserSettingsCommandFixture bool? shouldAutoplay = null, bool? isGaplessPlaybackEnabled = null, ReplayGainMode? replayGainMode = null, - PlaybackStreamingQuality? streamingQuality = null) + PlaybackStreamingQuality? streamingQuality = null, + VuMeterOrientation? vuMeterOrientation = null, + int? vuMeterSegmentCount = null, + int? vuMeterSegmentGap = null, + double? vuMeterMediumThreshold = null, + double? vuMeterHighThreshold = null, + bool? vuMeterShowPeak = null, + int? vuMeterPeakHoldDurationInMilliseconds = null, + double? vuMeterReleasePerSecond = null, + double? vuMeterPeakReleasePerSecond = null) { + // The high threshold is generated from the medium one, so a randomized command always describes a valid meter. + double mediumThreshold = vuMeterMediumThreshold ?? Random.Shared.NextDouble(); + double highThreshold = vuMeterHighThreshold ?? (mediumThreshold + Random.Shared.NextDouble() * (1 - mediumThreshold)); return new Faker() - .CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default, default, default, default, default, default, default, default, default)) + .CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default, default, default, default, default, default, default, default, default, default, default, default, default, default, default, default, default, default)) .RuleFor(x => x.IsPaginationEnabled, f => isPaginationEnabled ?? f.Random.Bool()) .RuleFor(x => x.ItemsPerPage, f => itemsPerPage ?? f.Random.Int(1, 100)) .RuleFor(x => x.ShouldIgnoreThePrefixForAlphaPicker, f => shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool()) @@ -62,6 +84,15 @@ public class UpdateUserSettingsCommandFixture .RuleFor(x => x.IsGaplessPlaybackEnabled, f => isGaplessPlaybackEnabled ?? f.Random.Bool()) .RuleFor(x => x.ReplayGainMode, f => replayGainMode ?? f.PickRandom()) .RuleFor(x => x.StreamingQuality, f => streamingQuality ?? f.PickRandom()) + .RuleFor(x => x.VuMeterOrientation, f => vuMeterOrientation ?? f.PickRandom()) + .RuleFor(x => x.VuMeterSegmentCount, f => vuMeterSegmentCount ?? f.Random.Int(1, 128)) + .RuleFor(x => x.VuMeterSegmentGap, f => vuMeterSegmentGap ?? f.Random.Int(0, 32)) + .RuleFor(x => x.VuMeterMediumThreshold, f => mediumThreshold) + .RuleFor(x => x.VuMeterHighThreshold, f => highThreshold) + .RuleFor(x => x.VuMeterShowPeak, f => vuMeterShowPeak ?? f.Random.Bool()) + .RuleFor(x => x.VuMeterPeakHoldDurationInMilliseconds, f => vuMeterPeakHoldDurationInMilliseconds ?? f.Random.Int(0, 10000)) + .RuleFor(x => x.VuMeterReleasePerSecond, f => vuMeterReleasePerSecond ?? f.Random.Double(0, 100)) + .RuleFor(x => x.VuMeterPeakReleasePerSecond, f => vuMeterPeakReleasePerSecond ?? f.Random.Double(0, 100)) .Generate(); } diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs index 44c56f6b..09c0a626 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/UsersManagement/Settings/UpdateUserSettingsRequestFixture.cs @@ -33,6 +33,15 @@ public class UpdateUserSettingsRequestFixture /// Whether the player transitions between consecutive tracks without a gap. /// The way ReplayGain normalization is applied to the tracks the user plays. /// The quality cap applied to the audio the server normalizes for the user. + /// The direction in which each channel of the VU meter of the audio player grows. + /// The number of segments each channel of the VU meter is divided into. + /// The gap, in pixels, between the segments and the channels of the VU meter. + /// The level above which a segment of the VU meter is drawn with its medium state. + /// The level above which a segment of the VU meter is drawn with its high state. + /// Whether the VU meter holds the peak level of each channel after it falls. + /// The time a peak of the VU meter is held before it starts falling. + /// The number of level units the display of the VU meter falls per second when the input level drops. + /// The number of level units the peak of the VU meter falls per second after its hold time elapsed. /// The created . public UpdateUserSettingsRequest Create( bool? isPaginationEnabled = null, @@ -47,8 +56,20 @@ public class UpdateUserSettingsRequestFixture bool? shouldAutoplay = null, bool? isGaplessPlaybackEnabled = null, ReplayGainMode? replayGainMode = null, - PlaybackStreamingQuality? streamingQuality = null) + PlaybackStreamingQuality? streamingQuality = null, + VuMeterOrientation? vuMeterOrientation = null, + int? vuMeterSegmentCount = null, + int? vuMeterSegmentGap = null, + double? vuMeterMediumThreshold = null, + double? vuMeterHighThreshold = null, + bool? vuMeterShowPeak = null, + int? vuMeterPeakHoldDurationInMilliseconds = null, + double? vuMeterReleasePerSecond = null, + double? vuMeterPeakReleasePerSecond = null) { + // The high threshold is generated from the medium one, so a randomized request always describes a valid meter. + double mediumThreshold = vuMeterMediumThreshold ?? _faker.Random.Double(0, 1); + double highThreshold = vuMeterHighThreshold ?? _faker.Random.Double(mediumThreshold, 1); return new UpdateUserSettingsRequest( isPaginationEnabled ?? _faker.Random.Bool(), itemsPerPage ?? _faker.Random.Int(1, 100), @@ -62,7 +83,16 @@ public class UpdateUserSettingsRequestFixture shouldAutoplay ?? _faker.Random.Bool(), isGaplessPlaybackEnabled ?? _faker.Random.Bool(), replayGainMode ?? _faker.PickRandom(), - streamingQuality ?? _faker.PickRandom()); + streamingQuality ?? _faker.PickRandom(), + vuMeterOrientation ?? _faker.PickRandom(), + vuMeterSegmentCount ?? _faker.Random.Int(1, 128), + vuMeterSegmentGap ?? _faker.Random.Int(0, 32), + mediumThreshold, + highThreshold, + vuMeterShowPeak ?? _faker.Random.Bool(), + vuMeterPeakHoldDurationInMilliseconds ?? _faker.Random.Int(0, 10000), + vuMeterReleasePerSecond ?? _faker.Random.Double(0, 100), + vuMeterPeakReleasePerSecond ?? _faker.Random.Double(0, 100)); } /// diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs index 504e3b92..4230b63d 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/Settings/UserSettingsResponseFixture.cs @@ -35,6 +35,15 @@ public class UserSettingsResponseFixture /// Optional. Whether the player transitions between consecutive tracks without a gap. /// Optional. The way ReplayGain normalization is applied to the tracks the user plays. /// Optional. The quality cap applied to the audio the server normalizes for the user. + /// Optional. The direction in which each channel of the VU meter of the audio player grows. + /// Optional. The number of segments each channel of the VU meter is divided into. + /// Optional. The gap, in pixels, between the segments and the channels of the VU meter. + /// Optional. The level above which a segment of the VU meter is drawn with its medium state. + /// Optional. The level above which a segment of the VU meter is drawn with its high state. + /// Optional. Whether the VU meter holds the peak level of each channel after it falls. + /// Optional. The time a peak of the VU meter is held before it starts falling. + /// Optional. The number of level units the display of the VU meter falls per second when the input level drops. + /// Optional. The number of level units the peak of the VU meter falls per second after its hold time elapsed. /// The created . public UserSettingsResponse Create( Guid? userId = null, @@ -50,8 +59,20 @@ public class UserSettingsResponseFixture bool? shouldAutoplay = null, bool? isGaplessPlaybackEnabled = null, ReplayGainMode? replayGainMode = null, - PlaybackStreamingQuality? streamingQuality = null) + PlaybackStreamingQuality? streamingQuality = null, + VuMeterOrientation? vuMeterOrientation = null, + int? vuMeterSegmentCount = null, + int? vuMeterSegmentGap = null, + double? vuMeterMediumThreshold = null, + double? vuMeterHighThreshold = null, + bool? vuMeterShowPeak = null, + int? vuMeterPeakHoldDurationInMilliseconds = null, + double? vuMeterReleasePerSecond = null, + double? vuMeterPeakReleasePerSecond = null) { + // The high threshold is generated from the medium one, so a randomized response always describes a valid meter. + double mediumThreshold = vuMeterMediumThreshold ?? _faker.Random.Double(0, 1); + double highThreshold = vuMeterHighThreshold ?? _faker.Random.Double(mediumThreshold, 1); return new UserSettingsResponse( userId ?? Guid.NewGuid(), isPaginationEnabled ?? _faker.Random.Bool(), @@ -66,7 +87,16 @@ public class UserSettingsResponseFixture shouldAutoplay ?? _faker.Random.Bool(), isGaplessPlaybackEnabled ?? _faker.Random.Bool(), replayGainMode ?? _faker.PickRandom(), - streamingQuality ?? _faker.PickRandom()); + streamingQuality ?? _faker.PickRandom(), + vuMeterOrientation ?? _faker.PickRandom(), + vuMeterSegmentCount ?? _faker.Random.Int(1, 128), + vuMeterSegmentGap ?? _faker.Random.Int(0, 32), + mediumThreshold, + highThreshold, + vuMeterShowPeak ?? _faker.Random.Bool(), + vuMeterPeakHoldDurationInMilliseconds ?? _faker.Random.Int(0, 10000), + vuMeterReleasePerSecond ?? _faker.Random.Double(0, 100), + vuMeterPeakReleasePerSecond ?? _faker.Random.Double(0, 100)); } /// diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs index 5ed4e956..4d768a50 100644 --- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs +++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsFixture.cs @@ -34,6 +34,15 @@ public class UserSettingsFixture /// Whether the player transitions between consecutive tracks without a gap. /// The way ReplayGain normalization is applied to the tracks the user plays. /// The quality cap applied to the audio the server normalizes for the user. + /// The direction in which each channel of the VU meter of the audio player grows. + /// The number of segments each channel of the VU meter is divided into. + /// The gap, in pixels, between the segments and the channels of the VU meter. + /// The level above which a segment of the VU meter is drawn with its medium state. + /// The level above which a segment of the VU meter is drawn with its high state. + /// Whether the VU meter holds the peak level of each channel after it falls. + /// The time a peak of the VU meter is held before it starts falling. + /// The number of level units the display of the VU meter falls per second when the input level drops. + /// The number of level units the peak of the VU meter falls per second after its hold time elapsed. /// The last volume the player reported for the user. /// The last mute state the player reported for the user. /// The created . @@ -52,6 +61,15 @@ public class UserSettingsFixture bool isGaplessPlaybackEnabled = true, ReplayGainMode replayGainMode = ReplayGainMode.Off, PlaybackStreamingQuality streamingQuality = PlaybackStreamingQuality.Auto, + VuMeterOrientation vuMeterOrientation = VuMeterOrientation.Vertical, + int vuMeterSegmentCount = 12, + int vuMeterSegmentGap = 1, + double vuMeterMediumThreshold = 0.6, + double vuMeterHighThreshold = 0.8, + bool vuMeterShowPeak = true, + int vuMeterPeakHoldDurationInMilliseconds = 650, + double vuMeterReleasePerSecond = 3.0, + double vuMeterPeakReleasePerSecond = 0.65, double volume = 1.0, bool isMuted = false) { @@ -70,6 +88,15 @@ public class UserSettingsFixture isGaplessPlaybackEnabled, replayGainMode, streamingQuality, + vuMeterOrientation, + vuMeterSegmentCount, + vuMeterSegmentGap, + vuMeterMediumThreshold, + vuMeterHighThreshold, + vuMeterShowPeak, + vuMeterPeakHoldDurationInMilliseconds, + vuMeterReleasePerSecond, + vuMeterPeakReleasePerSecond, volume, isMuted); return settings.Value; diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UserSettingsEntityMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UserSettingsEntityMappingTests.cs index 5cb9ab7a..cee12c1e 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UserSettingsEntityMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UserSettingsEntityMappingTests.cs @@ -5,6 +5,7 @@ using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement; using Lumina.Contracts.Responses.UsersManagement.Settings; using Lumina.Domain.Common.Primitives; using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate; +using Lumina.Domain.SharedKernel.Common.Enums.Playback; using System.Diagnostics.CodeAnalysis; #endregion @@ -22,7 +23,16 @@ public class UserSettingsEntityMappingTests public void ToDomainEntity_WhenMappingValidRepositoryEntity_ShouldMapCorrectly() { // Arrange - UserSettingsEntity entity = _userSettingsEntityFixture.Create(); + UserSettingsEntity entity = _userSettingsEntityFixture.Create( + vuMeterOrientation: VuMeterOrientation.Horizontal, + vuMeterSegmentCount: 24, + vuMeterSegmentGap: 2, + vuMeterMediumThreshold: 0.4, + vuMeterHighThreshold: 0.9, + vuMeterShowPeak: false, + vuMeterPeakHoldDurationInMilliseconds: 900, + vuMeterReleasePerSecond: 2.5, + vuMeterPeakReleasePerSecond: 0.9); // Act Result result = entity.ToDomainEntity(); @@ -37,13 +47,31 @@ public class UserSettingsEntityMappingTests Assert.Equal(entity.IsThemeCachingEnabled, result.Value.IsThemeCachingEnabled); Assert.Equal(entity.ShouldRenderPdfAsImages, result.Value.ShouldRenderPdfAsImages); Assert.Equal(entity.ShouldPreserveBookStyles, result.Value.ShouldPreserveBookStyles); + Assert.Equal(entity.VuMeterOrientation, result.Value.VuMeterOrientation); + Assert.Equal(entity.VuMeterSegmentCount, result.Value.VuMeterSegmentCount); + Assert.Equal(entity.VuMeterSegmentGap, result.Value.VuMeterSegmentGap); + Assert.Equal(entity.VuMeterMediumThreshold, result.Value.VuMeterMediumThreshold); + Assert.Equal(entity.VuMeterHighThreshold, result.Value.VuMeterHighThreshold); + Assert.Equal(entity.VuMeterShowPeak, result.Value.VuMeterShowPeak); + Assert.Equal(entity.VuMeterPeakHoldDurationInMilliseconds, result.Value.VuMeterPeakHoldDurationInMilliseconds); + Assert.Equal(entity.VuMeterReleasePerSecond, result.Value.VuMeterReleasePerSecond); + Assert.Equal(entity.VuMeterPeakReleasePerSecond, result.Value.VuMeterPeakReleasePerSecond); } [Fact] public void ToResponse_WhenMappingValidRepositoryEntity_ShouldMapCorrectly() { // Arrange - UserSettingsEntity entity = _userSettingsEntityFixture.Create(); + UserSettingsEntity entity = _userSettingsEntityFixture.Create( + vuMeterOrientation: VuMeterOrientation.Horizontal, + vuMeterSegmentCount: 24, + vuMeterSegmentGap: 2, + vuMeterMediumThreshold: 0.4, + vuMeterHighThreshold: 0.9, + vuMeterShowPeak: false, + vuMeterPeakHoldDurationInMilliseconds: 900, + vuMeterReleasePerSecond: 2.5, + vuMeterPeakReleasePerSecond: 0.9); // Act UserSettingsResponse result = entity.ToResponse(); @@ -57,5 +85,14 @@ public class UserSettingsEntityMappingTests Assert.Equal(entity.IsThemeCachingEnabled, result.IsThemeCachingEnabled); Assert.Equal(entity.ShouldRenderPdfAsImages, result.ShouldRenderPdfAsImages); Assert.Equal(entity.ShouldPreserveBookStyles, result.ShouldPreserveBookStyles); + Assert.Equal(entity.VuMeterOrientation, result.VuMeterOrientation); + Assert.Equal(entity.VuMeterSegmentCount, result.VuMeterSegmentCount); + Assert.Equal(entity.VuMeterSegmentGap, result.VuMeterSegmentGap); + Assert.Equal(entity.VuMeterMediumThreshold, result.VuMeterMediumThreshold); + Assert.Equal(entity.VuMeterHighThreshold, result.VuMeterHighThreshold); + Assert.Equal(entity.VuMeterShowPeak, result.VuMeterShowPeak); + Assert.Equal(entity.VuMeterPeakHoldDurationInMilliseconds, result.VuMeterPeakHoldDurationInMilliseconds); + Assert.Equal(entity.VuMeterReleasePerSecond, result.VuMeterReleasePerSecond); + Assert.Equal(entity.VuMeterPeakReleasePerSecond, result.VuMeterPeakReleasePerSecond); } } diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UserSettingsMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UserSettingsMappingTests.cs index 17969e47..d330b4e6 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UserSettingsMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/UsersManagement/Users/UserSettingsMappingTests.cs @@ -4,6 +4,7 @@ using Lumina.Application.Common.Mapping.UsersManagement.Users; using Lumina.Contracts.Responses.UsersManagement.Settings; using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate; using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate; +using Lumina.Domain.SharedKernel.Common.Enums.Playback; using System; using System.Diagnostics.CodeAnalysis; #endregion @@ -23,7 +24,17 @@ public class UserSettingsMappingTests { // Arrange Guid userId = Guid.NewGuid(); - UserSettings domainEntity = _userSettingsFixture.Create(userId: userId); + UserSettings domainEntity = _userSettingsFixture.Create( + userId: userId, + vuMeterOrientation: VuMeterOrientation.Horizontal, + vuMeterSegmentCount: 24, + vuMeterSegmentGap: 2, + vuMeterMediumThreshold: 0.4, + vuMeterHighThreshold: 0.9, + vuMeterShowPeak: false, + vuMeterPeakHoldDurationInMilliseconds: 900, + vuMeterReleasePerSecond: 2.5, + vuMeterPeakReleasePerSecond: 0.9); // Act UserSettingsEntity result = domainEntity.ToRepositoryEntity(); @@ -37,6 +48,15 @@ public class UserSettingsMappingTests Assert.Equal(domainEntity.ShouldIgnoreThePrefixForAlphaPicker, result.ShouldIgnoreThePrefixForAlphaPicker); Assert.Equal(domainEntity.ShouldRenderPdfAsImages, result.ShouldRenderPdfAsImages); Assert.Equal(domainEntity.ShouldPreserveBookStyles, result.ShouldPreserveBookStyles); + Assert.Equal(domainEntity.VuMeterOrientation, result.VuMeterOrientation); + Assert.Equal(domainEntity.VuMeterSegmentCount, result.VuMeterSegmentCount); + Assert.Equal(domainEntity.VuMeterSegmentGap, result.VuMeterSegmentGap); + Assert.Equal(domainEntity.VuMeterMediumThreshold, result.VuMeterMediumThreshold); + Assert.Equal(domainEntity.VuMeterHighThreshold, result.VuMeterHighThreshold); + Assert.Equal(domainEntity.VuMeterShowPeak, result.VuMeterShowPeak); + Assert.Equal(domainEntity.VuMeterPeakHoldDurationInMilliseconds, result.VuMeterPeakHoldDurationInMilliseconds); + Assert.Equal(domainEntity.VuMeterReleasePerSecond, result.VuMeterReleasePerSecond); + Assert.Equal(domainEntity.VuMeterPeakReleasePerSecond, result.VuMeterPeakReleasePerSecond); } [Fact] @@ -44,7 +64,17 @@ public class UserSettingsMappingTests { // Arrange Guid userId = Guid.NewGuid(); - UserSettings domainEntity = _userSettingsFixture.Create(userId: userId); + UserSettings domainEntity = _userSettingsFixture.Create( + userId: userId, + vuMeterOrientation: VuMeterOrientation.Horizontal, + vuMeterSegmentCount: 24, + vuMeterSegmentGap: 2, + vuMeterMediumThreshold: 0.4, + vuMeterHighThreshold: 0.9, + vuMeterShowPeak: false, + vuMeterPeakHoldDurationInMilliseconds: 900, + vuMeterReleasePerSecond: 2.5, + vuMeterPeakReleasePerSecond: 0.9); // Act UserSettingsResponse result = domainEntity.ToResponse(); @@ -57,5 +87,14 @@ public class UserSettingsMappingTests Assert.Equal(domainEntity.ShouldIgnoreThePrefixForAlphaPicker, result.ShouldIgnoreThePrefixForAlphaPicker); Assert.Equal(domainEntity.ShouldRenderPdfAsImages, result.ShouldRenderPdfAsImages); Assert.Equal(domainEntity.ShouldPreserveBookStyles, result.ShouldPreserveBookStyles); + Assert.Equal(domainEntity.VuMeterOrientation, result.VuMeterOrientation); + Assert.Equal(domainEntity.VuMeterSegmentCount, result.VuMeterSegmentCount); + Assert.Equal(domainEntity.VuMeterSegmentGap, result.VuMeterSegmentGap); + Assert.Equal(domainEntity.VuMeterMediumThreshold, result.VuMeterMediumThreshold); + Assert.Equal(domainEntity.VuMeterHighThreshold, result.VuMeterHighThreshold); + Assert.Equal(domainEntity.VuMeterShowPeak, result.VuMeterShowPeak); + Assert.Equal(domainEntity.VuMeterPeakHoldDurationInMilliseconds, result.VuMeterPeakHoldDurationInMilliseconds); + Assert.Equal(domainEntity.VuMeterReleasePerSecond, result.VuMeterReleasePerSecond); + Assert.Equal(domainEntity.VuMeterPeakReleasePerSecond, result.VuMeterPeakReleasePerSecond); } } diff --git a/tests/UnitTests/Lumina.DataAccess.UnitTests/Common/Configuration/UserSettingsConfigurationTests.cs b/tests/UnitTests/Lumina.DataAccess.UnitTests/Common/Configuration/UserSettingsConfigurationTests.cs index 1638dcb9..d55f386f 100644 --- a/tests/UnitTests/Lumina.DataAccess.UnitTests/Common/Configuration/UserSettingsConfigurationTests.cs +++ b/tests/UnitTests/Lumina.DataAccess.UnitTests/Common/Configuration/UserSettingsConfigurationTests.cs @@ -53,12 +53,30 @@ public class UserSettingsConfigurationTests IProperty isPaginationEnabledProperty = entityType.GetProperty(nameof(UserSettingsEntity.IsPaginationEnabled)); IProperty itemsPerPageProperty = entityType.GetProperty(nameof(UserSettingsEntity.ItemsPerPage)); IProperty ignoreThePrefixProperty = entityType.GetProperty(nameof(UserSettingsEntity.ShouldIgnoreThePrefixForAlphaPicker)); + IProperty vuMeterOrientationProperty = entityType.GetProperty(nameof(UserSettingsEntity.VuMeterOrientation)); + IProperty vuMeterSegmentCountProperty = entityType.GetProperty(nameof(UserSettingsEntity.VuMeterSegmentCount)); + IProperty vuMeterSegmentGapProperty = entityType.GetProperty(nameof(UserSettingsEntity.VuMeterSegmentGap)); + IProperty vuMeterMediumThresholdProperty = entityType.GetProperty(nameof(UserSettingsEntity.VuMeterMediumThreshold)); + IProperty vuMeterHighThresholdProperty = entityType.GetProperty(nameof(UserSettingsEntity.VuMeterHighThreshold)); + IProperty vuMeterShowPeakProperty = entityType.GetProperty(nameof(UserSettingsEntity.VuMeterShowPeak)); + IProperty vuMeterPeakHoldDurationProperty = entityType.GetProperty(nameof(UserSettingsEntity.VuMeterPeakHoldDurationInMilliseconds)); + IProperty vuMeterReleasePerSecondProperty = entityType.GetProperty(nameof(UserSettingsEntity.VuMeterReleasePerSecond)); + IProperty vuMeterPeakReleasePerSecondProperty = entityType.GetProperty(nameof(UserSettingsEntity.VuMeterPeakReleasePerSecond)); // Assert Assert.False(userIdProperty.IsNullable); Assert.False(isPaginationEnabledProperty.IsNullable); Assert.False(itemsPerPageProperty.IsNullable); Assert.False(ignoreThePrefixProperty.IsNullable); + Assert.False(vuMeterOrientationProperty.IsNullable); + Assert.False(vuMeterSegmentCountProperty.IsNullable); + Assert.False(vuMeterSegmentGapProperty.IsNullable); + Assert.False(vuMeterMediumThresholdProperty.IsNullable); + Assert.False(vuMeterHighThresholdProperty.IsNullable); + Assert.False(vuMeterShowPeakProperty.IsNullable); + Assert.False(vuMeterPeakHoldDurationProperty.IsNullable); + Assert.False(vuMeterReleasePerSecondProperty.IsNullable); + Assert.False(vuMeterPeakReleasePerSecondProperty.IsNullable); } [Fact] diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Common/Errors/ErrorsTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Common/Errors/ErrorsTests.cs index 672d78cb..99d679a3 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Common/Errors/ErrorsTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Common/Errors/ErrorsTests.cs @@ -79,7 +79,7 @@ public class ErrorsTests { // Assert // The count assertion fails when an error is added or removed, reminding to update the assertions below. - Assert.Equal(13, typeof(DomainErrors.UserSettings).GetProperties().Length); + Assert.Equal(31, typeof(DomainErrors.UserSettings).GetProperties().Length); AssertError(DomainErrors.UserSettings.UserSettingsAlreadyExists, ErrorType.Conflict); AssertError(DomainErrors.UserSettings.UserSettingsNotFound, ErrorType.NotFound); AssertError(DomainErrors.UserSettings.ItemsPerPageMustBeGreaterThanZero, ErrorType.Validation); @@ -93,6 +93,24 @@ public class ErrorsTests AssertError(DomainErrors.UserSettings.StreamingQualityCannotBeNull, ErrorType.Validation); AssertError(DomainErrors.UserSettings.InvalidReplayGainMode, ErrorType.Validation); AssertError(DomainErrors.UserSettings.InvalidStreamingQuality, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterOrientationCannotBeNull, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.InvalidVuMeterOrientation, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterSegmentCountCannotBeNull, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterSegmentCountMustBeBetweenOneAndOneHundredTwentyEight, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterSegmentGapCannotBeNull, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterSegmentGapMustBeBetweenZeroAndThirtyTwo, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterMediumThresholdCannotBeNull, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterMediumThresholdMustBeBetweenZeroAndOne, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterHighThresholdCannotBeNull, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterHighThresholdMustBeBetweenZeroAndOne, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterHighThresholdMustBeGreaterThanOrEqualToMediumThreshold, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterShowPeakCannotBeNull, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterPeakHoldDurationCannotBeNull, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterPeakHoldDurationMustBeBetweenZeroAndTenThousandMilliseconds, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterReleasePerSecondCannotBeNull, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterReleasePerSecondMustBeBetweenZeroAndOneHundred, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterPeakReleasePerSecondCannotBeNull, ErrorType.Validation); + AssertError(DomainErrors.UserSettings.VuMeterPeakReleasePerSecondMustBeBetweenZeroAndOneHundred, ErrorType.Validation); } [Fact] diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsTests.cs index fbb27861..82421cc1 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/UserManagementBoundedContext/UserSettingsAggregate/UserSettingsTests.cs @@ -80,7 +80,7 @@ public class UserSettingsTests UserId userId = _userIdFixture.Create(); // Act - Result result = UserSettings.Create(userId, isPaginationEnabled: false, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true, shouldKeepDownloadingWhilePaused: true, shouldAutoplay: true, isGaplessPlaybackEnabled: true, replayGainMode: ReplayGainMode.Off, streamingQuality: PlaybackStreamingQuality.Auto, volume: 1.0, isMuted: false); + Result result = UserSettings.Create(userId, isPaginationEnabled: false, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true, shouldKeepDownloadingWhilePaused: true, shouldAutoplay: true, isGaplessPlaybackEnabled: true, replayGainMode: ReplayGainMode.Off, streamingQuality: PlaybackStreamingQuality.Auto, vuMeterOrientation: VuMeterOrientation.Vertical, vuMeterSegmentCount: 12, vuMeterSegmentGap: 1, vuMeterMediumThreshold: 0.6, vuMeterHighThreshold: 0.8, vuMeterShowPeak: true, vuMeterPeakHoldDurationInMilliseconds: 650, vuMeterReleasePerSecond: 1.5, vuMeterPeakReleasePerSecond: 0.65, volume: 1.0, isMuted: false); // Assert Assert.False(result.IsFailure); @@ -116,7 +116,7 @@ public class UserSettingsTests UserSettingsId id = _userSettingsIdFixture.Create(); // Act - Result result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: true, shouldKeepDownloadingWhilePaused: true, shouldAutoplay: true, isGaplessPlaybackEnabled: true, replayGainMode: ReplayGainMode.Off, streamingQuality: PlaybackStreamingQuality.Auto, volume: 1.0, isMuted: false); + Result result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: true, shouldKeepDownloadingWhilePaused: true, shouldAutoplay: true, isGaplessPlaybackEnabled: true, replayGainMode: ReplayGainMode.Off, streamingQuality: PlaybackStreamingQuality.Auto, vuMeterOrientation: VuMeterOrientation.Vertical, vuMeterSegmentCount: 12, vuMeterSegmentGap: 1, vuMeterMediumThreshold: 0.6, vuMeterHighThreshold: 0.8, vuMeterShowPeak: true, vuMeterPeakHoldDurationInMilliseconds: 650, vuMeterReleasePerSecond: 1.5, vuMeterPeakReleasePerSecond: 0.65, volume: 1.0, isMuted: false); // Assert Assert.False(result.IsFailure); @@ -132,7 +132,7 @@ public class UserSettingsTests UserSettings userSettings = _userSettingsFixture.Create(); // Act - Result result = userSettings.UpdateSettings(isPaginationEnabled: false, itemsPerPage: 12, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: false, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true, shouldKeepDownloadingWhilePaused: true, shouldAutoplay: true, isGaplessPlaybackEnabled: true, replayGainMode: ReplayGainMode.Off, streamingQuality: PlaybackStreamingQuality.Auto); + Result result = userSettings.UpdateSettings(isPaginationEnabled: false, itemsPerPage: 12, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: false, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true, shouldKeepDownloadingWhilePaused: true, shouldAutoplay: true, isGaplessPlaybackEnabled: true, replayGainMode: ReplayGainMode.Off, streamingQuality: PlaybackStreamingQuality.Auto, vuMeterOrientation: VuMeterOrientation.Vertical, vuMeterSegmentCount: 12, vuMeterSegmentGap: 1, vuMeterMediumThreshold: 0.6, vuMeterHighThreshold: 0.8, vuMeterShowPeak: true, vuMeterPeakHoldDurationInMilliseconds: 650, vuMeterReleasePerSecond: 1.5, vuMeterPeakReleasePerSecond: 0.65); // Assert Assert.False(result.IsFailure);