How to use the spaudiopy.sig.MultiSignal function in spaudiopy

To help you get started, we’ve selected a few spaudiopy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chris-hld / spaudiopy / examples / Loudspeaker_decoder.py View on Github external
axs[4].set_title("binaural NLS")
for ax in axs:
    ax.grid(True)
plt.tight_layout()

# Listen to some
s_in = sig.MonoSignal.from_file('../data/piano_mono.flac', fs)
s_in.trim(2.6, 6)

s_out_vbap = sig.MultiSignal(2*[s_in.signal], fs=fs)
s_out_vbap = s_out_vbap.conv([l_vbap_ir, r_vbap_ir])

s_out_allrap = sig.MultiSignal(2*[s_in.signal], fs=fs)
s_out_allrap = s_out_allrap.conv([l_allrap_ir, r_allrap_ir])

s_out_allrap2 = sig.MultiSignal(2*[s_in.signal], fs=fs)
s_out_allrap2 = s_out_allrap2.conv([l_allrap2_ir, r_allrap2_ir])

s_out_hrir = sig.MultiSignal(2*[s_in.signal], fs=fs)
s_out_hrir = s_out_hrir.conv([hrirs.nearest_hrirs(src_azi, src_colat)[0],
                              hrirs.nearest_hrirs(src_azi, src_colat)[1]])


if LISTEN:
    print("input")
    s_in.play()
    print("hrir")
    s_out_hrir.play()
    print("vbap")
    s_out_vbap.play()
    print("allrap")
    s_out_allrap.play()
github chris-hld / spaudiopy / examples / Loudspeaker_decoder.py View on Github external
axs[2].set_title("binaural ALLRAP")
axs[3].plot(l_allrap2_ir)
axs[3].plot(r_allrap2_ir)
axs[3].set_title("binaural ALLRAP2")
axs[4].plot(l_nls_ir)
axs[4].plot(r_nls_ir)
axs[4].set_title("binaural NLS")
for ax in axs:
    ax.grid(True)
plt.tight_layout()

# Listen to some
s_in = sig.MonoSignal.from_file('../data/piano_mono.flac', fs)
s_in.trim(2.6, 6)

s_out_vbap = sig.MultiSignal(2*[s_in.signal], fs=fs)
s_out_vbap = s_out_vbap.conv([l_vbap_ir, r_vbap_ir])

s_out_allrap = sig.MultiSignal(2*[s_in.signal], fs=fs)
s_out_allrap = s_out_allrap.conv([l_allrap_ir, r_allrap_ir])

s_out_allrap2 = sig.MultiSignal(2*[s_in.signal], fs=fs)
s_out_allrap2 = s_out_allrap2.conv([l_allrap2_ir, r_allrap2_ir])

s_out_hrir = sig.MultiSignal(2*[s_in.signal], fs=fs)
s_out_hrir = s_out_hrir.conv([hrirs.nearest_hrirs(src_azi, src_colat)[0],
                              hrirs.nearest_hrirs(src_azi, src_colat)[1]])


if LISTEN:
    print("input")
    s_in.play()
github chris-hld / spaudiopy / spaudiopy / IO.py View on Github external
filename : string
        Audio file name.
    fs : int
        fs(t).
    subtype : optional

    """
    # assert(isinstance(signal, (sig.MonoSignal, sig.MultiSignal)))
    if isinstance(sig, sig.MonoSignal):
        if fs is not None:
            assert(signal.fs == fs)

    if type(signal) == sig.MonoSignal:
        data = signal.signal
        data_fs = signal.fs
    elif type(signal) in (sig.MultiSignal, sig.AmbiBSignal):
        data = signal.get_signals().T
        data_fs = signal.fs
    elif isinstance(signal, (np.ndarray, np.generic)):
        data = signal
        data_fs = fs
    else:
        raise NotImplementedError('Data type not supported.')

    sf.write(filename, data, data_fs, subtype=subtype)
github chris-hld / spaudiopy / spaudiopy / sig.py View on Github external
def sh_to_b(cls, multisig):
        """Alternative constructor, convert from sig.Multisignal.
        Assumes ACN channel order.
        """
        assert isinstance(multisig, MultiSignal)
        _B = sph.sh_to_b(multisig.copy().get_signals())
        return cls([*_B], fs=multisig.fs)
github chris-hld / spaudiopy / examples / SDM.py View on Github external
ls_setup, fs)

# Render some examples
s_in = sig.MonoSignal.from_file('../data/piano_mono.flac', fs)
s_in.trim(2.6, 6)

# Convolve with the omnidirectional IR
s_out_p = s_in.copy()
s_out_p.conv(sdm_p)

# Convolve with the stereo SDM IR
s_out_SDM_stereo = sig.MultiSignal([s_in.signal, s_in.signal], fs=fs)
s_out_SDM_stereo.conv([ir_st_l, ir_st_r])

# Convolve with the loudspeaker SDM IR
s_out_SDM_ls = sig.MultiSignal([s_in.signal, s_in.signal], fs=fs)
s_out_SDM_ls.conv([ir_ls_l, ir_ls_r])


if LISTEN:
    print("input")
    s_in.play()
    print("output: Omni")
    s_out_p.play(gain=0.5/np.max(sdm_p))
    print("output: Stereo SDM")
    s_out_SDM_stereo.play(gain=0.5/np.max(sdm_p))
    print("output: Binaural Loudspeaker SDM")
    s_out_SDM_ls.play(gain=0.5/np.max(sdm_p))
github chris-hld / spaudiopy / spaudiopy / IO.py View on Github external
else:
            loaded_data.append(data)
        loaded_fs.append(fs_file)
    # Assert same sample rate for all channels
    assert all(x == loaded_fs[0] for x in loaded_fs)
    # Check against provided samplerate
    if fs is not None:
        if fs != loaded_fs[0]:
            raise ValueError("File: Found different fs:" + str(loaded_fs[0]))
    else:
        fs = loaded_fs[0]
    # MonoSignal or MultiSignal
    if len(loaded_data) == 1:
        return sig.MonoSignal(loaded_data, fs=fs)
    else:
        return sig.MultiSignal([*loaded_data], fs=fs)