mirror of
https://github.com/Jellify-Music/App.git
synced 2026-01-05 18:40:01 -06:00
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
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 = {
|
|
url: 'https://example.com/track.mp3',
|
|
item: {
|
|
NormalizationGain: 6, // 6 Gain means the track is quieter than the target volume
|
|
},
|
|
}
|
|
|
|
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 = {
|
|
url: 'https://example.com/track.mp3',
|
|
item: {
|
|
NormalizationGain: 0, // 0 Gain means the track is at the target volume
|
|
},
|
|
}
|
|
|
|
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 = {
|
|
url: 'https://example.com/track.mp3',
|
|
item: {
|
|
NormalizationGain: -10, // -10 Gain means the track is louder than the target volume
|
|
},
|
|
}
|
|
|
|
const volume = calculateTrackVolume(track)
|
|
|
|
expect(volume).toBeLessThan(0.5) // This module will cap the volume at 1 to prevent clipping
|
|
})
|
|
})
|