Add more replaygain tests, fix wma (#2356)
* add more replaygain tests, fix wma * Convert individual specs to a table spec * Fix pipeline, by commenting incompatible tests --------- Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -56,15 +56,15 @@ var _ = Describe("Tags", func() {
|
|||||||
|
|
||||||
m = mds["tests/fixtures/test.ogg"]
|
m = mds["tests/fixtures/test.ogg"]
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(m.Title()).To(BeEmpty())
|
Expect(m.Title()).To(Equal("Title"))
|
||||||
Expect(m.HasPicture()).To(BeFalse())
|
Expect(m.HasPicture()).To(BeFalse())
|
||||||
Expect(m.Duration()).To(BeNumerically("~", 1.04, 0.01))
|
Expect(m.Duration()).To(BeNumerically("~", 1.04, 0.01))
|
||||||
Expect(m.Suffix()).To(Equal("ogg"))
|
Expect(m.Suffix()).To(Equal("ogg"))
|
||||||
Expect(m.FilePath()).To(Equal("tests/fixtures/test.ogg"))
|
Expect(m.FilePath()).To(Equal("tests/fixtures/test.ogg"))
|
||||||
Expect(m.Size()).To(Equal(int64(5178)))
|
Expect(m.Size()).To(Equal(int64(6333)))
|
||||||
// TabLib 1.12 returns 18, previous versions return 39.
|
// TabLib 1.12 returns 18, previous versions return 39.
|
||||||
// See https://github.com/taglib/taglib/commit/2f238921824741b2cfe6fbfbfc9701d9827ab06b
|
// See https://github.com/taglib/taglib/commit/2f238921824741b2cfe6fbfbfc9701d9827ab06b
|
||||||
Expect(m.BitRate()).To(BeElementOf(18, 39, 40))
|
Expect(m.BitRate()).To(BeElementOf(18, 39, 40, 49))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ var _ = Describe("Extractor", func() {
|
|||||||
Expect(m).To(HaveKeyWithValue("comment", []string{"Comment1\nComment2"}))
|
Expect(m).To(HaveKeyWithValue("comment", []string{"Comment1\nComment2"}))
|
||||||
Expect(m).To(HaveKeyWithValue("lyrics", []string{"Lyrics 1\rLyrics 2"}))
|
Expect(m).To(HaveKeyWithValue("lyrics", []string{"Lyrics 1\rLyrics 2"}))
|
||||||
Expect(m).To(HaveKeyWithValue("bpm", []string{"123"}))
|
Expect(m).To(HaveKeyWithValue("bpm", []string{"123"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("replaygain_album_gain", []string{"+3.21518 dB"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("replaygain_album_peak", []string{"0.9125"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("replaygain_track_gain", []string{"-1.48 dB"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("replaygain_track_peak", []string{"0.4512"}))
|
||||||
|
|
||||||
Expect(m).To(HaveKeyWithValue("tracknumber", []string{"2/10"}))
|
Expect(m).To(HaveKeyWithValue("tracknumber", []string{"2/10"}))
|
||||||
m = m.Map(e.CustomMappings())
|
m = m.Map(e.CustomMappings())
|
||||||
@@ -59,7 +63,6 @@ var _ = Describe("Extractor", func() {
|
|||||||
|
|
||||||
m = mds["tests/fixtures/test.ogg"]
|
m = mds["tests/fixtures/test.ogg"]
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(m).ToNot(HaveKey("title"))
|
|
||||||
Expect(m).ToNot(HaveKey("has_picture"))
|
Expect(m).ToNot(HaveKey("has_picture"))
|
||||||
Expect(m).To(HaveKeyWithValue("duration", []string{"1.04"}))
|
Expect(m).To(HaveKeyWithValue("duration", []string{"1.04"}))
|
||||||
Expect(m).To(HaveKeyWithValue("fbpm", []string{"141.7"}))
|
Expect(m).To(HaveKeyWithValue("fbpm", []string{"141.7"}))
|
||||||
@@ -67,11 +70,11 @@ var _ = Describe("Extractor", func() {
|
|||||||
// TabLib 1.12 returns 18, previous versions return 39.
|
// TabLib 1.12 returns 18, previous versions return 39.
|
||||||
// See https://github.com/taglib/taglib/commit/2f238921824741b2cfe6fbfbfc9701d9827ab06b
|
// See https://github.com/taglib/taglib/commit/2f238921824741b2cfe6fbfbfc9701d9827ab06b
|
||||||
Expect(m).To(HaveKey("bitrate"))
|
Expect(m).To(HaveKey("bitrate"))
|
||||||
Expect(m["bitrate"][0]).To(BeElementOf("18", "39", "40"))
|
Expect(m["bitrate"][0]).To(BeElementOf("18", "39", "40", "49"))
|
||||||
})
|
})
|
||||||
|
|
||||||
DescribeTable("ReplayGain",
|
DescribeTable("Format-Specific tests",
|
||||||
func(file, albumGain, albumPeak, trackGain, trackPeak string) {
|
func(file, duration, channels, albumGain, albumPeak, trackGain, trackPeak string) {
|
||||||
file = "tests/fixtures/" + file
|
file = "tests/fixtures/" + file
|
||||||
mds, err := e.Parse(file)
|
mds, err := e.Parse(file)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
@@ -83,10 +86,54 @@ var _ = Describe("Extractor", func() {
|
|||||||
Expect(m).To(HaveKeyWithValue("replaygain_album_peak", []string{albumPeak}))
|
Expect(m).To(HaveKeyWithValue("replaygain_album_peak", []string{albumPeak}))
|
||||||
Expect(m).To(HaveKeyWithValue("replaygain_track_gain", []string{trackGain}))
|
Expect(m).To(HaveKeyWithValue("replaygain_track_gain", []string{trackGain}))
|
||||||
Expect(m).To(HaveKeyWithValue("replaygain_track_peak", []string{trackPeak}))
|
Expect(m).To(HaveKeyWithValue("replaygain_track_peak", []string{trackPeak}))
|
||||||
|
|
||||||
|
Expect(m).To(HaveKeyWithValue("title", []string{"Title", "Title"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("album", []string{"Album", "Album"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("artist", []string{"Artist", "Artist"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("albumartist", []string{"Album Artist"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("compilation", []string{"1"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("genre", []string{"Rock"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("date", []string{"2014", "2014"}))
|
||||||
|
|
||||||
|
Expect(m).To(HaveKey("discnumber"))
|
||||||
|
discno := m["discnumber"]
|
||||||
|
Expect(discno).To(HaveLen(1))
|
||||||
|
Expect(discno[0]).To(BeElementOf([]string{"1", "1/2"}))
|
||||||
|
|
||||||
|
Expect(m).NotTo(HaveKeyWithValue("has_picture", []string{"true"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("duration", []string{duration}))
|
||||||
|
|
||||||
|
Expect(m).To(HaveKeyWithValue("channels", []string{channels}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("comment", []string{"Comment1\nComment2"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("lyrics", []string{"Lyrics1\nLyrics 2"}))
|
||||||
|
Expect(m).To(HaveKeyWithValue("bpm", []string{"123"}))
|
||||||
|
|
||||||
|
Expect(m).To(HaveKey("tracknumber"))
|
||||||
|
trackNo := m["tracknumber"]
|
||||||
|
Expect(trackNo).To(HaveLen(1))
|
||||||
|
Expect(trackNo[0]).To(BeElementOf([]string{"3", "3/10"}))
|
||||||
},
|
},
|
||||||
Entry("Correctly parses m4a (aac) gain tags", "01 Invisible (RED) Edit Version.m4a", "0.37", "0.48", "0.37", "0.48"),
|
|
||||||
Entry("correctly parses mp3 tags", "test.mp3", "+3.21518 dB", "0.9125", "-1.48 dB", "0.4512"),
|
// ffmpeg -f lavfi -i "sine=frequency=1200:duration=1" test.flac
|
||||||
Entry("correctly parses ogg (vorbis) tags", "test.ogg", "+7.64 dB", "0.11772506", "+7.64 dB", "0.11772506"),
|
Entry("correctly parses flac tags", "test.flac", "1.00", "1", "+4.06 dB", "0.12496948", "+4.06 dB", "0.12496948"),
|
||||||
|
|
||||||
|
Entry("Correctly parses m4a (aac) gain tags", "01 Invisible (RED) Edit Version.m4a", "1.04", "2", "0.37", "0.48", "0.37", "0.48"),
|
||||||
|
|
||||||
|
Entry("correctly parses ogg (vorbis) tags", "test.ogg", "1.04", "2", "+7.64 dB", "0.11772506", "+7.64 dB", "0.11772506"),
|
||||||
|
|
||||||
|
// ffmpeg -f lavfi -i "sine=frequency=900:duration=1" test.wma
|
||||||
|
Entry("correctly parses wma/asf tags", "test.wma", "1.02", "1", "3.27 dB", "0.132914", "3.27 dB", "0.132914"),
|
||||||
|
|
||||||
|
// ffmpeg -f lavfi -i "sine=frequency=800:duration=1" test.wv
|
||||||
|
Entry("correctly parses wv (wavpak) tags", "test.wv", "1.00", "1", "3.43 dB", "0.125061", "3.43 dB", "0.125061"),
|
||||||
|
|
||||||
|
// TODO - these breaks in the pipeline as it uses TabLib 1.11. Once Ubuntu 24.04 is released we can uncomment these tests
|
||||||
|
// ffmpeg -f lavfi -i "sine=frequency=1000:duration=1" test.wav
|
||||||
|
//Entry("correctly parses wav tags", "test.wav", "1.00", "1", "3.06 dB", "0.125056", "3.06 dB", "0.125056"),
|
||||||
|
|
||||||
|
// ffmpeg -f lavfi -i "sine=frequency=1400:duration=1" test.aiff
|
||||||
|
//Entry("correctly parses aiff tags", "test.aiff", "1.00", "1", "2.00 dB", "0.124972", "2.00 dB", "0.124972"),
|
||||||
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,29 @@ int taglib_read(const FILENAME_CHAR_T *filename, unsigned long id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WMA/ASF files may have additional tags not captured by the general iterator
|
||||||
|
TagLib::ASF::File *asfFile(dynamic_cast<TagLib::ASF::File *>(f.file()));
|
||||||
|
if (asfFile != NULL)
|
||||||
|
{
|
||||||
|
const TagLib::ASF::Tag *asfTags{asfFile->tag()};
|
||||||
|
const auto itemListMap = asfTags->attributeListMap();
|
||||||
|
for (const auto item : itemListMap) {
|
||||||
|
char *key = ::strdup(item.first.toCString(true));
|
||||||
|
char *val = ::strdup(item.second.front().toString().toCString());
|
||||||
|
go_map_put_str(id, key, val);
|
||||||
|
free(key);
|
||||||
|
free(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compilation tag needs to be handled differently
|
||||||
|
const auto compilation = asfTags->attribute("WM/IsCompilation");
|
||||||
|
if (!compilation.isEmpty()) {
|
||||||
|
char *val = ::strdup(compilation.front().toString().toCString());
|
||||||
|
go_map_put_str(id, (char *)"compilation", val);
|
||||||
|
free(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (has_cover(f)) {
|
if (has_cover(f)) {
|
||||||
go_map_put_str(id, (char *)"has_picture", (char *)"true");
|
go_map_put_str(id, (char *)"has_picture", (char *)"true");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,14 @@ var _ = Describe("TagScanner", func() {
|
|||||||
It("return all audio files from the folder", func() {
|
It("return all audio files from the folder", func() {
|
||||||
files, err := loadAllAudioFiles("tests/fixtures")
|
files, err := loadAllAudioFiles("tests/fixtures")
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(files).To(HaveLen(5))
|
Expect(files).To(HaveLen(10))
|
||||||
Expect(files).To(HaveKey("tests/fixtures/test.ogg"))
|
Expect(files).To(HaveKey("tests/fixtures/test.aiff"))
|
||||||
|
Expect(files).To(HaveKey("tests/fixtures/test.flac"))
|
||||||
Expect(files).To(HaveKey("tests/fixtures/test.mp3"))
|
Expect(files).To(HaveKey("tests/fixtures/test.mp3"))
|
||||||
|
Expect(files).To(HaveKey("tests/fixtures/test.ogg"))
|
||||||
|
Expect(files).To(HaveKey("tests/fixtures/test.wav"))
|
||||||
|
Expect(files).To(HaveKey("tests/fixtures/test.wma"))
|
||||||
|
Expect(files).To(HaveKey("tests/fixtures/test.wv"))
|
||||||
Expect(files).To(HaveKey("tests/fixtures/test_no_read_permission.ogg"))
|
Expect(files).To(HaveKey("tests/fixtures/test_no_read_permission.ogg"))
|
||||||
Expect(files).To(HaveKey("tests/fixtures/01 Invisible (RED) Edit Version.mp3"))
|
Expect(files).To(HaveKey("tests/fixtures/01 Invisible (RED) Edit Version.mp3"))
|
||||||
Expect(files).To(HaveKey("tests/fixtures/01 Invisible (RED) Edit Version.m4a"))
|
Expect(files).To(HaveKey("tests/fixtures/01 Invisible (RED) Edit Version.m4a"))
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ var _ = Describe("walk_dir_tree", func() {
|
|||||||
Expect(collected[baseDir]).To(MatchFields(IgnoreExtras, Fields{
|
Expect(collected[baseDir]).To(MatchFields(IgnoreExtras, Fields{
|
||||||
"Images": BeEmpty(),
|
"Images": BeEmpty(),
|
||||||
"HasPlaylist": BeFalse(),
|
"HasPlaylist": BeFalse(),
|
||||||
"AudioFilesCount": BeNumerically("==", 6),
|
"AudioFilesCount": BeNumerically("==", 11),
|
||||||
}))
|
}))
|
||||||
Expect(collected[filepath.Join(baseDir, "artist", "an-album")]).To(MatchFields(IgnoreExtras, Fields{
|
Expect(collected[filepath.Join(baseDir, "artist", "an-album")]).To(MatchFields(IgnoreExtras, Fields{
|
||||||
"Images": ConsistOf("cover.jpg", "front.png", "artist.png"),
|
"Images": ConsistOf("cover.jpg", "front.png", "artist.png"),
|
||||||
|
|||||||
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user