ReplayGain support + audio normalization (web player) (#1988)

* ReplayGain support

- extract ReplayGain tags from files, expose via native api
- use metadata to normalize audio in web player

* make pre-push happy

* remove unnecessary prints

* remove another unnecessary print

* add tooltips, see metadata

* address comments, use settings instead

* remove console.log

* use better language for gain modes
This commit is contained in:
Kendall Garner
2023-01-17 20:52:00 +00:00
committed by Deluan
parent 9ae156dd82
commit 1324a16fc5
24 changed files with 411 additions and 56 deletions
+2
View File
@@ -8,6 +8,7 @@ import { NotificationsToggle } from './NotificationsToggle'
import { LastfmScrobbleToggle } from './LastfmScrobbleToggle'
import { ListenBrainzScrobbleToggle } from './ListenBrainzScrobbleToggle'
import config from '../config'
import { ReplayGainToggle } from './ReplayGainToggle'
const useStyles = makeStyles({
root: { marginTop: '1em' },
@@ -24,6 +25,7 @@ const Personal = () => {
<SelectTheme />
<SelectLanguage />
<SelectDefaultView />
{config.enableReplayGain && <ReplayGainToggle />}
<NotificationsToggle />
{config.lastFMEnabled && <LastfmScrobbleToggle />}
{config.listenBrainzEnabled && <ListenBrainzScrobbleToggle />}
+44
View File
@@ -0,0 +1,44 @@
import { NumberInput, SelectInput, useTranslate } from 'react-admin'
import { useDispatch, useSelector } from 'react-redux'
import { changeGain, changePreamp } from '../actions'
export const ReplayGainToggle = (props) => {
const translate = useTranslate()
const dispatch = useDispatch()
const gainInfo = useSelector((state) => state.replayGain)
return (
<>
<SelectInput
{...props}
fullWidth
source="replayGain"
label={translate('menu.personal.options.replaygain')}
choices={[
{ id: 'none', name: 'menu.personal.options.gain.none' },
{ id: 'track', name: 'menu.personal.options.gain.album' },
{ id: 'album', name: 'menu.personal.options.gain.track' },
]}
defaultValue={gainInfo.gainMode}
onChange={(event) => {
dispatch(changeGain(event.target.value))
}}
/>
<br />
{gainInfo.gainMode !== 'none' && (
<NumberInput
{...props}
source="preAmp"
label={translate('menu.personal.options.preAmp')}
defaultValue={gainInfo.preAmp}
step={0.5}
min={-15}
max={15}
onChange={(event) => {
dispatch(changePreamp(event.target.value))
}}
/>
)}
</>
)
}