Commit feed021c authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch 'FhG/pyaudio3dtools_maintenance' into 'main'

[scripts/pyaudio3dtools] cleanup and fixes

See merge request !316
parents c0727907 7fa0c83c
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
0, 30 -30, 60, -60, 90, -90, 135, -135, 180, 0,  45, -45, 90, -90, 0,  135, -135, 180,   0,  45, -45
0, 30, -30, 60, -60, 90, -90, 135, -135, 180, 0,  45, -45, 90, -90, 0,  135, -135, 180,   0,  45, -45
0,  0,   0,  0,   0,  0,   0,   0,    0,   0, 35, 35,  35, 35,  35, 90,  35,   35,  35, -15, -15, -15
3, 9
+0 −0

File mode changed from 100644 to 100755.

+24 −3
Original line number Diff line number Diff line
@@ -32,9 +32,10 @@

import logging
import math
from typing import Optional, Tuple
from typing import Callable, Iterable, Optional, Tuple

import numpy as np
import multiprocessing as mp
import scipy.signal as sig

main_logger = logging.getLogger("__main__")
@@ -409,7 +410,7 @@ def limiter(x: np.ndarray, fs: int):
        fr_sig[idx_min] = -32768


def get_framewise(x: np.ndarray, chunk_size: int) -> np.ndarray:
def get_framewise(x: np.ndarray, chunk_size: int, zero_pad=False) -> np.ndarray:
    """Generator to yield a signal frame by frame
        If array size is not a multiple of chunk_size, last frame contains the remainder

@@ -419,6 +420,8 @@ def get_framewise(x: np.ndarray, chunk_size: int) -> np.ndarray:
        Input reference array
    chunk_size: int
        Size of frames to yield
    zero_pad: bool
        Whether to zero pad the last chunk if there are not enough samples

    Yields
    -------
@@ -429,4 +432,22 @@ def get_framewise(x: np.ndarray, chunk_size: int) -> np.ndarray:
    for i in range(n_frames):
        yield x[i * chunk_size : (i + 1) * chunk_size, :]
    if x.shape[0] % chunk_size:
        yield x[n_frames * chunk_size :, :]
        last_chunk = x[n_frames * chunk_size :, :]
        if zero_pad:
            yield np.pad(last_chunk, [[0, chunk_size - (x.shape[0] % chunk_size)], [0, 0]])
        else:
            yield last_chunk


def process_async(files: Iterable, func: Callable, **kwargs):
    """Applies a function asynchronously to an array of audio files/filenames using a multiprocessing pool"""

    p = mp.pool(mp.cpu_count())
    results = []
    for f in files:
        results.append(p.apply_async(func, args=(f, kwargs)))
    p.close()
    p.join()
    for r in results:
        r.get()
    return results
+0 −0

File mode changed from 100755 to 100644.

+8 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ def spatial_audio_convert(

            # initialise metadata object for ISM
            metadata_obj = spatialmetadata.Metadata()
            metadata_obj.init_for_ism(in_file, in_fs, in_meta_files)
            metadata_obj.init_for_ism(in_file, in_fs, in_nchans, in_meta_files)

            # TODO decide on reference path for BINAURAL_ROOM
            if out_spfmt.name.startswith("BINAURAL_ROOM"):
@@ -426,6 +426,13 @@ def convert_ism(
            audioarray.get_framewise(out_sig, frame_len),
        )
    ):
        # update the crossfade if we have a smaller last frame
        if out_frame.shape[0] != frame_len:
            frame_size = out_frame.shape[0]
            fade_in = np.arange(frame_size) / (frame_size - 1)
            fade_in = fade_in[:, np.newaxis]
            fade_out = 1.0 - fade_in

        pos = EFAP.wrap_angles(*pos_data[i_frame % pos_frames, :], clip_ele=True)

        # ISM -> MC
Loading