Commit 71a48872 authored by Anika Treffehn's avatar Anika Treffehn
Browse files

reference renderer and loudness tool updates

parent eb7d0087
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -493,17 +493,17 @@ This is the main file to edit in order to change global configuration options, d
|                           |                    |               |                                               |
| concatenate_input         | True/False         | False         | Whether to (horizontally) concatenate files in the input directory |
| concat_silence_ms         | [1000, 1000]       | [0, 0]        | Specifies the pre- and post-silence duration to pad concatenation with in ms. If a single value is specified it will be used for BOTH pre- and post-padding |
| preproc_loudness          | -26                |               | Loudness to preprocess input to (dBov / LKFS depending on tool). Only processed if preproc_input is True. |
| preproc_loudness          | -26                |               | Loudness to preprocess input to (in LKFS). Only processed if preproc_input is True. |
|                           |                    |               |                                               |
| output_path               | ./out/             |               | Output root directory hosting generated items & log |
| out_fs                    | 48000              | 48000         | Output sampling rate for conditions to generate |
| output_loudness           | -26                |               | Loudness level for output file (dBov / LKFS depending on tool). |
| output_loudness           | -26                |               | Loudness level for output file in LKFS. |
|                           |                    |               |                                               |
| renderer_format           | 7_1_4 or CICP19    | Required      | Format to be rendered (using offline rendering, will be bypassed if = out_format) |
| binaural_rendered         | True/False         | False         | Extra binauralization of the rendered outputs (using offline rendering) |
| include_LFE               | True/False         | False         | Whether to include LFE in binural rendering   |
| gain_factor               | float value        | 1.0           | Gain factor to be applied to LFE channel      |
| loudness_tool             | "sv56demo"         | "bs1770demo"  | Tool to use for loudness adjustment. Currently only sv56demo and bs1770demo are supported for appropriate format configurations. Optionally can be a path to the binary.  |
| loudness_format           | "scale_out"/CICP19 | renderer_format | Rendering format used in iterative loudness adjustment. "scale_out" just scales the output to the desired output_loudness |  |
|                           |                    |               |                                               |
| lt_mode                   | "MUSHRA"           |               | Automatically generates a NAME.ltg file with generate_lt_file.py in output_path according to the specified mode |
| conditions_to_generate    | ["ref", "ivas"]    | Required      | list of conditions to be generated, for ivas and evs, multiple conditions can be specified with an \_ separator (i.e. "ivas_branch", "ivas_trunk" etc.)            |
+9 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import multiprocessing as mp
import os
from typing import Iterable

from generate_lt_file import generate_lt_file
from pyaudio3dtools import audiofile
from pyprocessing import processing, processing_configs, utils

@@ -171,6 +172,14 @@ def main(test_cfg):
        for r in results:
            r.get()

    # generate LT file if specified
    if hasattr(test_cfg, "lt_mode"):
        generate_lt_file(
            test_cfg,
            test_cfg.lt_mode,
            os.path.join(test_cfg.output_path, test_cfg.name + ".ltg"),
        )

    # copy over JSON to main output directory
    output_json = os.path.join(test_cfg.output_path, test_cfg.name + ".json")
    with open(output_json, "w") as fp:
+22 −31
Original line number Diff line number Diff line
#!/usr/bin/env python3

"""
   (C) 2022 Baseline Development Group with portions copyright Dolby International AB, Ericsson AB,
   (C) 2022-2023 Baseline Development Group with portions copyright Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies OY, Orange,
   Panasonic Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation. All Rights Reserved.
@@ -36,7 +36,9 @@ import numpy as np


def wrap_angles(
    azi: float, ele: float, clip_ele: Optional[bool] = False
    azi: float,
    ele: float,
    clip_ele: Optional[bool] = False,
) -> Tuple[float, float]:
    """
    Wrap angles to (-180, 180] azimuth and [-90, 90] elevation
@@ -45,7 +47,7 @@ def wrap_angles(
    if clip_ele:
        ele = min(max(ele, -90), 90)

    if ele != 0 and ele % 90 == 0:
    if ele % 90 == 0 and ele % 180 != 0:
        # if elevation is a multiple of 90, azimuth is irrelevant since we are at a pole
        azi = 0
        while np.abs(ele) > 90:
@@ -58,20 +60,15 @@ def wrap_angles(

            # compensate elevation accordingly
            if ele > 90:
                ele -= 180
                ele = 180 - ele
            elif ele < -90:
                ele += 180
                ele = -180 - ele

        # wrap azimuth value
        while np.abs(azi) > 180:
            azi = (azi + 180) % 360
            if azi < 0:
        while azi > 180:
            azi -= 360
        while azi <= -180:
            azi += 360
            azi -= 180

    # set -180 azimuth to 180
    if azi == -180:
        azi = 180

    return azi, ele

@@ -87,7 +84,6 @@ class EfapVertex:
    Vertex data structure for EFAP
    Initialises a vertex from the given spherical coordinate pair, with a flag specifying if it is a ghost loudspeaker


    Parameters
    ----------
    azi : float
@@ -141,24 +137,21 @@ class EFAP:

    Initialise EFAP data for computing panning gains


    Parameters
    ----------
    azimuths : np.ndarray
        Azimuth positions of the loudspeaker array
    elevations : npndarray
    elevations : np.ndarray
        Elevation postions of the loudspeaker array
    intensity_panning : bool
        Whether intensity panning is enabled or not

    Examples
    --------

    >>> from EFAP import EFAP
    >>> panner = EFAP([30, -30, 0, 110, -110], [0, 0, 0, 0, 0], False)
    >>> panner.pan(15, 45)
    array([0.66742381, 0.19069252, 0.66742381, 0.19069252, 0.19069252])

    """

    _EFAP_HULL_TOL = 1e-4  # tolerance for a point to be added to the convex hull
@@ -516,7 +509,6 @@ class EFAP:
        """
        Compute panning gains for each vertex in the given polygon


        Parameters
        ----------
        azimuth : float
@@ -661,7 +653,6 @@ class EFAP:
        C : float
            Third vertex of the triangle


        Returns
        -------
        bool
@@ -742,7 +733,8 @@ class EFAP:
            return 0
        else:
            N = np.cross(P1 - P2, P1 - P3)
            return np.dot(X - P1, N / np.linalg.norm(N))
            eps = np.finfo(float).eps
            return np.dot(X - P1, N / (np.linalg.norm(N) + eps))

    def _flip_plane(self, surface: np.ndarray) -> np.ndarray:
        """
@@ -775,7 +767,6 @@ class EFAP:
        """
        Compute gains for the requested panning position


        Parameters
        ----------
        azimuth : float
@@ -843,17 +834,19 @@ class EFAP:
    """ public functions """

    def pan(
        self, azimuths: float, elevations: float, intensity_panning: bool = False
        self,
        azimuths: float,
        elevations: float,
        intensity_panning: Optional[bool] = False,
    ) -> np.ndarray:
        """
        Compute gains for the requested panning position


        Parameters
        ----------
        azimuth : float
        azimuths : float
            Azimuth of requested panning position
        elevation : float
        elevations : float
            Elevation of requested panning position
        intensity_panning : bool
            Flag whether to use intensity panning (Default is False == amplitude panning)
@@ -883,12 +876,10 @@ def main(args):
    Parses a speaker layout text file and prints the panning gains
    for the requested position


    Parameters
    ----------
    args : tuple
    args : Namespace
        Command line arguments

    """

    speaker_positions = np.loadtxt(
+1 −1
Original line number Diff line number Diff line
@@ -48,5 +48,5 @@ from . import (
    spatialaudioconvert,
    spatialaudioformat,
    spatialmetadata,
    EFAP,
)
from .EFAP import EFAP
+14 −13
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@ import logging
import os

from pyaudio3dtools import (
    audiofile,
    binauralrenderer,
    spatialaudioconvert,
    spatialaudioformat,
)
@@ -65,7 +63,7 @@ def main():
        "--outdir",
        required=True,
        type=str,
        help="output file *.wav or directory",
        help="output file *.wav, *.pcm or directory",
        default="out",
    )
    parser.add_argument(
@@ -134,8 +132,8 @@ def main():
        "-n",
        "--normalize",
        default=None,
        type=int,
        help="Normalize to given loudness with --LOUDNESS_TOOL (default = %(default)s)",
        type=float,
        help="Normalize to given loudness with BS 1770-4",
    )

    """ Miscellaneous or meta arguments """
@@ -165,11 +163,10 @@ def main():
        action="store_true",
    )
    parser.add_argument(
        "-lt",
        "--loudness_tool",
        default="bs1770demo",
        "-lf",
        "--loudness_format",
        type=str,
        help="Loudness tool to use: bs1770demo [default] or sv56demo (tool must be in $PATH or a path to the binary)",
        help="Loudness format: loudness tool renders to loudness format and scales such that this format has desired loudness (default output format)",
    )
    parser.add_argument(
        "-rn",
@@ -205,7 +202,9 @@ def main():
        if os.path.isdir(args.infiles):
            path = args.infiles
            audio_list = [
                os.path.join(path, f) for f in os.listdir(path) if f.endswith((".wav"))
                os.path.join(path, f)
                for f in os.listdir(path)
                if f.endswith(".wav") or f.endswith(".pcm") or f.endswith(".raw")
            ]
        else:
            audio_list = [args.infiles]
@@ -213,7 +212,9 @@ def main():
        outdir = args.outdir
        _, output_ext = os.path.splitext(os.path.basename(outdir))
        if (len(audio_list) == 1) and (
            (output_ext.lower() == ".wav") or (output_ext.lower() == ".pcm")
            (output_ext.lower() == ".wav")
            or (output_ext.lower() == ".pcm")
            or (output_ext.lower() == ".raw")
        ):
            outfile = outdir
        else:
@@ -246,7 +247,7 @@ def main():
                out_fs=args.outfs,
                out_fc=args.outfc,
                output_loudness=args.normalize,
                loudness_tool=args.loudness_tool,
                loudness_format=args.loudness_format,
                trajectory=args.trajectory,
                binaural_dataset=args.binaural_dataset,
            )
@@ -271,7 +272,7 @@ def main():
                    in_meta_files=args.metadata,
                    out_format="BINAURAL",
                    output_loudness=args.normalize,
                    loudness_tool=args.loudness_tool,
                    loudness_format=args.loudness_format,
                    trajectory=args.trajectory,
                    binaural_dataset=args.binaural_dataset,
                )
Loading