Commit 7576a860 authored by Anika Treffehn's avatar Anika Treffehn
Browse files

Changed supported formats for mono rendering

parent d1205641
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -154,9 +154,7 @@ def load_ir(
            f"No latency of HRTF dataset specified in .mat file -> computed latency: {latency_smp}"
        )

    if in_fmt.startswith("MONO"):
        IR = IR[:, :, :1]  # use omni/W from SBA
    elif in_fmt.startswith("STEREO"):
    if in_fmt.startswith("STEREO"):
        IR = IR[:, :, :2]  # use L and R channels.
    elif (
        in_fmt in CHANNEL_BASED_AUDIO_FORMATS.keys()
+16 −0
Original line number Diff line number Diff line
@@ -104,6 +104,15 @@ def render_cba_to_binaural(
    bin_lfe_gain: Optional[float]
        LFE gain for binaural rendering
    """

    if cba.name == "MONO":
        # no binauralization possible for mono -> render to stereo and assume binaural signal
        cba_stereo = audio.fromtype("STEREO")
        cba_stereo.fs = bin.fs
        render_cba_to_cba(cba, cba_stereo)
        bin.audio = cba_stereo.audio
        return

    # TODO this will change if we have resampled HRTFs
    cba.audio = resample_itu(cba, 48000)
    old_fs = cba.fs
@@ -199,6 +208,9 @@ def render_cba_to_binaural(
def render_cba_to_cba(
    cba_in: audio.ChannelBasedAudio, cba_out: audio.ChannelBasedAudio
) -> None:
    if cba_in.name == "MONO" and cba_out.name != "STEREO":
        raise ValueError(f"Rendering from MONO to {cba_out.name} is not supported.")

    # Stereo to Mono
    if cba_in.name == "STEREO" and cba_out.name == "MONO":
        render_mtx = np.vstack([[0.5], [0.5]])
@@ -234,6 +246,10 @@ def render_cba_to_cba(


def render_cba_to_sba(cba: audio.ChannelBasedAudio, sba: audio.SceneBasedAudio) -> None:

    if cba.name == "MONO":
        raise ValueError(f"Rendering from MONO to {sba.name} is not supported.")

    # SH response for loudspeaker positions
    render_mtx = np.hstack(
        [
+0 −2
Original line number Diff line number Diff line
@@ -78,8 +78,6 @@ def render_masa_to_binaural(
    **kwargs,
):
    if "ROOM" in bin.name:
        # TODO decide between MOZART or 7_1_4 for BRIRs
        # cba_tmp = audio.fromtype("MOZART")
        cba_tmp = audio.fromtype("7_1_4")
        cba_tmp.fs = masa.fs

+0 −2
Original line number Diff line number Diff line
@@ -108,8 +108,6 @@ def render_oba_to_binaural(
    # bin.audio = np.zeros([oba.audio.shape[0], bin.num_channels])

    if "ROOM" in bin.name:
        # TODO decide between MOZART or 7_1_4 for BRIRs
        # cba_tmp = audio.fromtype("MOZART")
        cba_tmp = audio.fromtype("7_1_4")
        cba_tmp.fs = oba.fs

+0 −2
Original line number Diff line number Diff line
@@ -113,8 +113,6 @@ def render_sba_to_binaural(
        sba.audio = rotate_sba(sba, trajectory)

    if "ROOM" in bin.name:
        # TODO decide between MOZART or 7_1_4 for BRIRs
        # cba_tmp = audio.fromtype("MOZART")
        cba_tmp = audio.fromtype("7_1_4")
        cba_tmp.fs = sba.fs

Loading