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:
@@ -4,3 +4,4 @@ export * from './playerReducer'
|
||||
export * from './albumView'
|
||||
export * from './activityReducer'
|
||||
export * from './settingsReducer'
|
||||
export * from './replayGainReducer'
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { CHANGE_GAIN, CHANGE_PREAMP } from '../actions'
|
||||
|
||||
const getPreAmp = () => {
|
||||
const storage = localStorage.getItem('preamp')
|
||||
|
||||
if (storage === null) {
|
||||
return 0
|
||||
} else {
|
||||
const asFloat = parseFloat(storage)
|
||||
return isNaN(asFloat) ? 0 : asFloat
|
||||
}
|
||||
}
|
||||
|
||||
const initialState = {
|
||||
gainMode: localStorage.getItem('gainMode') || 'none',
|
||||
preAmp: getPreAmp(),
|
||||
}
|
||||
|
||||
export const replayGainReducer = (
|
||||
previousState = initialState,
|
||||
{ type, payload }
|
||||
) => {
|
||||
switch (type) {
|
||||
case CHANGE_GAIN: {
|
||||
localStorage.setItem('gainMode', payload)
|
||||
return {
|
||||
...previousState,
|
||||
gainMode: payload,
|
||||
}
|
||||
}
|
||||
case CHANGE_PREAMP: {
|
||||
const value = parseFloat(payload)
|
||||
if (isNaN(value)) {
|
||||
return previousState
|
||||
}
|
||||
localStorage.setItem('preAmp', payload)
|
||||
return {
|
||||
...previousState,
|
||||
preAmp: value,
|
||||
}
|
||||
}
|
||||
default:
|
||||
return previousState
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user