Files
App/jest/functional/Normalization.test.ts
Violet Caulfield 2961ca39bb Introduction of Transcoding Support (#490)
Implements proper server negotation for performing transcoding

Depending on the user's platform (i.e. iOS, Android) and the desired quality specified in the settings, Jellify will playback a transcoded audio file from Jellyfin

This is helpful when the source audio file is not compatible with the user's device (i.e. playing back an ALAC encoded .M4A on Android) or if the user want to stream at a lower quality to save bandwidth

This also drives downloads in different qualities, meaning the download quality selector in the Settings is now working properly. When a track is downloaded, it will download at the quality selected by the user, and in a format compatible with the device

There is also a toggle in the "Player" Settings for displaying a badge in the player that shows the quality and container of the audio being played
2025-08-28 13:04:38 -05:00

53 lines
1.6 KiB
TypeScript

import JellifyTrack from '../../src/types/JellifyTrack'
import calculateTrackVolume from '../../src/providers/Player/utils/normalization'
describe('Normalization Module', () => {
it('should calculate the volume for a track with a normalization gain of 6', () => {
const track: JellifyTrack = {
url: 'https://example.com/track.mp3',
item: {
NormalizationGain: 6, // 6 Gain means the track is quieter than the target volume
},
duration: 420,
sessionId: 'TEST_SESSION_ID',
sourceType: 'stream',
}
const volume = calculateTrackVolume(track)
expect(volume).toBe(1) // This module will cap the volume at 1 to prevent clipping
})
it('should calculate the volume for a track with a normalization gain of 0', () => {
const track: JellifyTrack = {
url: 'https://example.com/track.mp3',
item: {
NormalizationGain: 0, // 0 Gain means the track is at the target volume
},
duration: 420,
sessionId: 'TEST_SESSION_ID',
sourceType: 'stream',
}
const volume = calculateTrackVolume(track)
expect(volume).toBe(1) // No normalization gain means the track is at the target volume
})
it('should calculate the volume for a track with a normalization gain of -10', () => {
const track: JellifyTrack = {
url: 'https://example.com/track.mp3',
item: {
NormalizationGain: -10, // -10 Gain means the track is louder than the target volume
},
duration: 420,
sessionId: 'TEST_SESSION_ID',
sourceType: 'stream',
}
const volume = calculateTrackVolume(track)
expect(volume).toBeLessThan(0.5) // This module will cap the volume at 1 to prevent clipping
})
})