Commit da2af526 authored by Anika Treffehn's avatar Anika Treffehn
Browse files

some small additions to the omasa osba support

parent 1835ea32
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -434,7 +434,7 @@ class OMASAAudio(Audio):
        # check if number of metadata files matches format
        if self.num_ism_channels != len(self.metadata_files):
            raise ValueError(
                f"Mismatch between number of channels in file [{self.audio.shape[1]}], and metadata [{len(self.metadata_files)}]"
                f"Mismatch between number of ism channels [{self.num_ism_channels}], and metadata [{len(self.metadata_files)}]"
            )

        self.object_pos = []
@@ -535,7 +535,7 @@ class OSBAAudio(Audio):
        # check if number of metadata files matches format
        if self.num_ism_channels != len(self.metadata_files):
            raise ValueError(
                f"Mismatch between number of channels in file [{self.audio.shape[1]}], and metadata [{len(self.metadata_files)}]"
                f"Mismatch between number of ism channels [{self.num_ism_channels}], and metadata [{len(self.metadata_files)}]"
            )

        self.object_pos = []
+8 −0
Original line number Diff line number Diff line
@@ -306,27 +306,35 @@ SCENE_BASED_AUDIO_FORMATS = {
OMASA_AUDIO_FORMATS = {
    "ISM1MASA1": {
        "num_channels": 2,
        "num_ism_channels": 1,
    },
    "ISM1MASA2": {
        "num_channels": 3,
        "num_ism_channels": 1,
    },
    "ISM2MASA1": {
        "num_channels": 3,
        "num_ism_channels": 2,
    },
    "ISM2MASA2": {
        "num_channels": 4,
        "num_ism_channels": 2,
    },
    "ISM3MASA1": {
        "num_channels": 4,
        "num_ism_channels": 3,
    },
    "ISM3MASA2": {
        "num_channels": 5,
        "num_ism_channels": 3,
    },
    "ISM4MASA1": {
        "num_channels": 5,
        "num_ism_channels": 4,
    },
    "ISM4MASA2": {
        "num_channels": 6,
        "num_ism_channels": 4,
    },
}

+6 −2
Original line number Diff line number Diff line
@@ -326,9 +326,13 @@ def format_conversion(
        raise NotImplementedError("Can only convert to OMASA from OSBA")

    # check for ISM (also OMASA and OSBA) as output
    if (isinstance(output, audio.ObjectBasedAudio) or isinstance(output, audio.OMASAAudio) or isinstance(output, audio.OSBAAudio)) and input.name != output.name:
    if isinstance(output, audio.ObjectBasedAudio) and input.name != output.name:
        raise NotImplementedError(
            "ISM (also in combined formats) is not supported as an output for rendering! Only usable as pass-through"
            "ISM is not supported as an output for rendering! Only usable as pass-through"
        )
    if (isinstance(output, audio.OMASAAudio) and not isinstance(input, audio.OSBAAudio)) or (isinstance(output, audio.OSBAAudio) and not isinstance(input, audio.OMASAAudio)):
        raise NotImplementedError(
            "OMASA and OSBA only possible as output if input is OMASA or OSBA"
        )

    if logger:
+4 −0
Original line number Diff line number Diff line
@@ -97,6 +97,10 @@ def convert_omasa(
    # OMASA -> OSBA
    elif isinstance(out, audio.OSBAAudio):
        # TODO (treffehn)
        # check if ism object number is the same
        if out.num_ism_channels != masa.num_ism_channels:
            raise ValueError("OMASA to OSBA conversion only possible if number of ISM objects matches")

        # only render MASA part
        out_sba = audio.fromtype("MASA")
        render_masa_to_sba(masa, out_sba)
+5 −1
Original line number Diff line number Diff line
@@ -98,8 +98,12 @@ def convert_osba(
    # OSBA -> OMASA
    elif isinstance(out, audio.OMASAAudio):
        # TODO (treffehn)
        # check if ism object number is the same
        if out.num_ism_channels != osba.num_ism_channels:
            raise ValueError("OSBA to OMASA conversion only possible if number of ISM objects matches")

        # only render SBA part
        out_sba = audio.fromtype("MASA")
        out_sba = audio.fromtype("MASA"+out.name[-1])
        render_sba_to_masa(sba, out_sba)

        out.audio[:, :osba.num_ism_channels] = osba.audio[:, :osba.num_ism_channels]
Loading