Commit f27e9712 authored by multrus's avatar multrus
Browse files

Merge branch '15-parsing-of-scaling-factor-with-updated-bs1770demo-broken' into 'main'

Resolve "Parsing of "scaling factor" with updated bs1770demo broken"

See merge request !43
parents d030ca13 02f613e2
Loading
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@

import copy
import logging
import re
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Optional, Tuple, Union
@@ -134,8 +135,13 @@ def bs1770demo(
        result = run(cmd, logger=logger)

        # parse output
        measured_loudness = float(result.stdout.splitlines()[3].split(":")[1])
        scale_factor = float(result.stdout.splitlines()[-3].split(":")[1])
        # we are looking for the (floating-point) number after the search string - '( )' around the number denotes the first group
        measured_loudness = float(
            re.search(r"Input level:\s+([-+]?(?:\d*\.*\d+))", result.stdout).group(1)
        )
        scale_factor = float(
            re.search(r"Scaling factor:\s+([-+]?(?:\d*\.*\d+))", result.stdout).group(1)
        )

    return measured_loudness, scale_factor