test(analyzer): update fixtures

- add fixture with > 2 silences
This commit is contained in:
jo 2022-01-19 22:05:10 +01:00 committed by Kyle Robbertze
parent 6a919a9805
commit bf7b0d44fb
6 changed files with 67 additions and 67 deletions

View File

@ -15,50 +15,57 @@ Fixture = namedtuple(
["path", "length", "cuein", "cueout", "replaygain"],
)
# length,cuein,cueout
s1 = [10.0, 2.3, 10.0]
s2 = [3.9, 0.0, 3.9]
# fmt: off
FILES = [
# Sample 1 MP3
Fixture(here / "s1-jointstereo.mp3", *s1, -1.6),
Fixture(here / "s1-mono.mp3", *s1, -0.7),
Fixture(here / "s1-stereo.mp3", *s1, -1.6),
# Sample 1 MP3 -12dB
Fixture(here / "s1-mono-12.mp3", *s1, +8.3),
Fixture(here / "s1-stereo-12.mp3", *s1, +10.0),
# Sample 1 MP3 +12dB
Fixture(here / "s1-mono+12.mp3", *s1, -13.6),
Fixture(here / "s1-stereo+12.mp3", *s1, -12.0),
# Sample 1 FLAC
Fixture(here / "s1-mono.flac", *s1, -1.6),
Fixture(here / "s1-stereo.flac", *s1, -2.3),
# Sample 1 FLAC -12dB
Fixture(here / "s1-mono-12.flac", *s1, +10.0),
Fixture(here / "s1-stereo-12.flac", *s1, +9.3),
# Sample 1 FLAC +12dB
Fixture(here / "s1-mono+12.flac", *s1, -12.0),
Fixture(here / "s1-stereo+12.flac", *s1, -12.0),
# Sample 1 AAC
Fixture(here / "s1-mono.m4a", *s1, -4.5),
Fixture(here / "s1-stereo.m4a", *s1, -2.9),
# Sample 1 Vorbis
Fixture(here / "s1-mono.ogg", *s1, -4.3),
Fixture(here / "s1-stereo.ogg", *s1, -2.3),
# Sample 2 MP3
Fixture(here / "s2-jointstereo.mp3", *s2, 6.1),
Fixture(here / "s2-mono.mp3", *s2, 6.1),
Fixture(here / "s2-stereo.mp3", *s2, 6.1),
# Sample 2 FLAC
Fixture(here / "s2-mono.flac", *s2, 5.2),
Fixture(here / "s2-stereo.flac", *s2, 5.2),
# Sample 2 AAC
Fixture(here / "s2-mono.m4a", *s2, 2.6),
Fixture(here / "s2-stereo.m4a", *s2, 6.1),
# Sample 2 Vorbis
Fixture(here / "s2-mono.ogg", *s2, 2.3),
Fixture(here / "s2-stereo.ogg", *s2, 5.2),
# filename length cuein cueout replaygain
# sample 1
# 0s -> 8s: silence and pink noise fade in
# 8s -> 9s: silence
# 9s -> 12s: musik
# 12s -> 15s: pink noise fade out
Fixture(here / "s1-jointstereo.mp3", 15.0, 6.0, 13.0, -5.9 ),
Fixture(here / "s1-mono.mp3", 15.0, 6.0, 13.0, -2.0 ),
Fixture(here / "s1-stereo.mp3", 15.0, 6.0, 13.0, -5.9 ),
Fixture(here / "s1-mono-12.mp3", 15.0, 9.0, 12.0, +7.0 ),
Fixture(here / "s1-stereo-12.mp3", 15.0, 9.0, 12.0, +6.1 ),
Fixture(here / "s1-mono+12.mp3", 15.0, 3.5, 13.0, -17.0 ),
Fixture(here / "s1-stereo+12.mp3", 15.0, 3.5, 13.0, -17.8 ),
Fixture(here / "s1-mono.flac", 15.0, 6.0, 13.0, -2.3 ),
Fixture(here / "s1-stereo.flac", 15.0, 6.0, 13.0, -6.0 ),
Fixture(here / "s1-mono-12.flac", 15.0, 9.0, 12.0, +10.0 ),
Fixture(here / "s1-stereo-12.flac", 15.0, 9.0, 12.0, +5.9 ),
Fixture(here / "s1-mono+12.flac", 15.0, 3.5, 13.0, -12.0 ),
Fixture(here / "s1-stereo+12.flac", 15.0, 3.5, 13.0, -14.9 ),
Fixture(here / "s1-mono.m4a", 15.0, 6.0, 13.0, -4.5 ),
Fixture(here / "s1-stereo.m4a", 15.0, 6.0, 13.0, -5.8 ),
Fixture(here / "s1-mono.ogg", 15.0, 6.0, 13.0, -4.9 ),
Fixture(here / "s1-stereo.ogg", 15.0, 6.0, 13.0, -5.7 ),
# sample 2
# 0s -> 1.8s: silence
# 1.8s : noise
# 1.8s -> 3.86s: silence
Fixture(here / "s2-jointstereo.mp3", 3.86, 0.0, 3.86, 5.6 ),
Fixture(here / "s2-mono.mp3", 3.86, 0.0, 3.86, 8.6 ),
Fixture(here / "s2-stereo.mp3", 3.86, 0.0, 3.86, 5.6 ),
Fixture(here / "s2-mono.flac", 3.86, 0.0, 3.86, 8.2 ),
Fixture(here / "s2-stereo.flac", 3.86, 0.0, 3.86, 5.6 ),
Fixture(here / "s2-mono.m4a", 3.86, 0.0, 3.86, 5.6 ),
Fixture(here / "s2-stereo.m4a", 3.86, 0.0, 3.86, 5.6 ),
Fixture(here / "s2-mono.ogg", 3.86, 0.0, 3.86, 5.6 ),
Fixture(here / "s2-stereo.ogg", 3.86, 0.0, 3.86, 5.6 ),
# sample 3
# 0s -> 1s: silence
# 1s -> 3s: noise
# 3s -> 5s: silence
# 5s -> 7s: noise
# 7s -> 9s: silence
# 9s -> 11s: noise
Fixture(here / "s3-stereo.mp3", 11.0, 1.0, 11.0, 1.0 ),
Fixture(here / "s3-stereo.flac", 11.0, 1.0, 11.0, 1.0 ),
Fixture(here / "s3-stereo.m4a", 11.0, 1.0, 11.0, 1.0 ),
Fixture(here / "s3-stereo.ogg", 11.0, 1.0, 11.0, 1.0 ),
]
# fmt: on
FixtureMeta = namedtuple(
"FixtureMeta",
@ -68,8 +75,8 @@ FixtureMeta = namedtuple(
meta = {
"cuein": 0.0,
"sample_rate": 48000,
"length": str(timedelta(seconds=10)),
"length_seconds": approx(10.0, abs=0.1),
"length": str(timedelta(seconds=15)),
"length_seconds": approx(15.0, abs=0.1),
"ftype": "audioclip",
"hidden": False,
# Tags
@ -90,7 +97,6 @@ FILES_TAGGED = [
**meta,
"bit_rate": approx(128000, abs=1e2),
"channels": 2,
"filesize": approx(161094, abs=1e2),
"mime": "audio/mp3",
},
),
@ -100,7 +106,6 @@ FILES_TAGGED = [
**meta,
"bit_rate": approx(64000, abs=1e2),
"channels": 1,
"filesize": approx(80646, abs=1e2),
"mime": "audio/mp3",
},
),
@ -110,7 +115,6 @@ FILES_TAGGED = [
**meta,
"bit_rate": approx(128000, abs=1e2),
"channels": 2,
"filesize": approx(161094, abs=1e2),
"mime": "audio/mp3",
},
),
@ -118,9 +122,8 @@ FILES_TAGGED = [
here / "s1-mono-tagged.flac",
{
**meta,
"bit_rate": approx(454468, abs=1e2),
"bit_rate": approx(452802, abs=1e2),
"channels": 1,
"filesize": approx(576516, abs=1e2),
"mime": "audio/flac",
},
),
@ -128,9 +131,8 @@ FILES_TAGGED = [
here / "s1-stereo-tagged.flac",
{
**meta,
"bit_rate": approx(687113, abs=1e2),
"bit_rate": approx(938593, abs=1e3),
"channels": 2,
"filesize": approx(867323, abs=1e2),
"mime": "audio/flac",
},
),
@ -140,7 +142,6 @@ FILES_TAGGED = [
**meta,
"bit_rate": approx(65000, abs=5e4),
"channels": 2, # Weird
"filesize": approx(80000, abs=1e5),
"mime": "audio/mp4",
},
),
@ -150,7 +151,6 @@ FILES_TAGGED = [
**meta,
"bit_rate": approx(128000, abs=1e5),
"channels": 2,
"filesize": approx(150000, abs=1e5),
"mime": "audio/mp4",
},
),
@ -160,7 +160,6 @@ FILES_TAGGED = [
**meta,
"bit_rate": approx(80000, abs=1e2),
"channels": 1,
"filesize": approx(81340, abs=1e2),
"mime": "audio/vorbis",
},
),
@ -170,7 +169,6 @@ FILES_TAGGED = [
**meta,
"bit_rate": approx(112000, abs=1e2),
"channels": 2,
"filesize": approx(104036, abs=1e2),
"mime": "audio/vorbis",
},
),
@ -195,7 +193,6 @@ FILES_TAGGED += [
**meta,
"bit_rate": approx(128000, abs=1e2),
"channels": 2,
"filesize": approx(161161, abs=1e2),
"mime": "audio/mp3",
},
),
@ -205,7 +202,6 @@ FILES_TAGGED += [
**meta,
"bit_rate": approx(64000, abs=1e2),
"channels": 1,
"filesize": approx(80713, abs=1e2),
"mime": "audio/mp3",
},
),
@ -215,7 +211,6 @@ FILES_TAGGED += [
**meta,
"bit_rate": approx(128000, abs=1e2),
"channels": 2,
"filesize": approx(161161, abs=1e2),
"mime": "audio/mp3",
},
),
@ -223,9 +218,8 @@ FILES_TAGGED += [
here / "s1-mono-tagged-utf8.flac",
{
**meta,
"bit_rate": approx(454468, abs=1e2),
"bit_rate": approx(452802, abs=1e2),
"channels": 1,
"filesize": approx(576583, abs=1e2),
"mime": "audio/flac",
},
),
@ -233,9 +227,8 @@ FILES_TAGGED += [
here / "s1-stereo-tagged-utf8.flac",
{
**meta,
"bit_rate": approx(687113, abs=1e2),
"bit_rate": approx(938593, abs=1e2),
"channels": 2,
"filesize": approx(867390, abs=1e2),
"mime": "audio/flac",
},
),
@ -245,7 +238,6 @@ FILES_TAGGED += [
**meta,
"bit_rate": approx(65000, abs=5e4),
"channels": 2, # Weird
"filesize": approx(80000, abs=1e5),
"mime": "audio/mp4",
},
),
@ -255,7 +247,6 @@ FILES_TAGGED += [
**meta,
"bit_rate": approx(128000, abs=1e5),
"channels": 2,
"filesize": approx(150000, abs=1e5),
"mime": "audio/mp4",
},
),
@ -265,7 +256,6 @@ FILES_TAGGED += [
**meta,
"bit_rate": approx(80000, abs=1e2),
"channels": 1,
"filesize": approx(81408, abs=1e2),
"mime": "audio/vorbis",
},
),
@ -275,7 +265,6 @@ FILES_TAGGED += [
**meta,
"bit_rate": approx(112000, abs=1e2),
"channels": 2,
"filesize": approx(104104, abs=1e2),
"mime": "audio/vorbis",
},
),

View File

@ -69,6 +69,12 @@ generate s2.flac s2-stereo.mp3 -ac 2 -acodec libmp3lame
generate s2.flac s2-stereo.ogg -ac 2 -acodec libvorbis
generate s2.flac s2-jointstereo.mp3 -ac 2 -acodec libmp3lame -joint_stereo 1
# Generate sample 3
generate s3.flac s3-stereo.flac -ac 2 -acodec flac
generate s3.flac s3-stereo.m4a -ac 2 -acodec aac
generate s3.flac s3-stereo.mp3 -ac 2 -acodec libmp3lame
generate s3.flac s3-stereo.ogg -ac 2 -acodec libvorbis
# Tag sample 1
tag metadata.txt s1-mono.flac s1-mono-tagged.flac
tag metadata.txt s1-mono.m4a s1-mono-tagged.m4a

Binary file not shown.

BIN
analyzer/tests/fixtures/s3.flac vendored Normal file

Binary file not shown.

View File

@ -27,7 +27,7 @@ def test_run_analysis(src_dir, dest_dir):
assert metadata["year"] == "1999"
assert metadata["genre"] == "Test Genre"
assert metadata["mime"] == "audio/mp3"
assert metadata["length_seconds"] == pytest.approx(10.0, abs=0.1)
assert metadata["length_seconds"] == pytest.approx(15.0, abs=0.1)
assert metadata["length"] == str(
datetime.timedelta(seconds=metadata["length_seconds"])
)

View File

@ -31,6 +31,11 @@ def test_analyze_metadata(filepath: str, metadata: dict):
assert len(found["md5"]) == 32
del found["md5"]
# Handle filesize
assert found["filesize"] < 2e6 # ~2Mb
assert found["filesize"] > 1e5 # 100Kb
del found["filesize"]
# Handle track formatted length/cueout
assert metadata["length"] in found["length"]
assert metadata["length"] in found["cueout"]