How to use the pyroomacoustics.constants function in pyroomacoustics

To help you get started, we’ve selected a few pyroomacoustics 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 LCAV / FRIDA / test_stft_whithenoise.py View on Github external
In this file we will simulate K sources all emitting white noise
    The source are placed circularly in the far field with respect to the microphone array
    '''

    save_fig = False
    save_param = True
    fig_dir = './result/'

    # Check if the directory exists
    if save_fig and not os.path.exists(fig_dir):
        os.makedirs(fig_dir)

    # parameters setup
    fs = 8000  # sampling frequency in Hz
    SNR = 0  # SNR for the received signal at microphones in [dB]
    speed_sound = pra.constants.get('c')

    K = 5  # Real number of sources
    K_est = 5  # Number of sources to estimate
    num_mic = 10  # number of microphones

    # algorithm parameters
    stop_cri = 'max_iter'  # can be 'mse' or 'max_iter'
    num_snapshot = 256  # number of snapshots used to estimate the covariance matrix
    fft_size = 1024  # number of FFT bins
    fc = 500.
    fft_bins = [int(fc / fs * fft_size)]
    M = 15  # Maximum Fourier coefficient index (-M to M), K_est <= M <= num_mic*(num_mic - 1) / 2

    # ----------------------------
    # Generate all necessary signals
github LCAV / FRIDA / test_doa_whitenoise_local.py View on Github external
elif opt in ("-b", "--n_bands"):
            n_bands = int(arg)

    # file parameters
    save_fig = False
    save_param = True
    fig_dir = './result/'

    # Check if the directory exists
    if save_fig and not os.path.exists(fig_dir):
        os.makedirs(fig_dir)

    # parameters setup
    fs = 16000  # sampling frequency in Hz
    SNR = 35  # SNR for the received signal at microphones in [dB]
    speed_sound = pra.constants.get('c')

    K = num_src  # Real number of sources
    K_est = K  # Number of sources to estimate

    # algorithm parameters
    stop_cri = 'max_iter'  # can be 'mse' or 'max_iter'
    fft_size = 256  # number of FFT bins
    num_snapshot = 256  # number of snapshots used to estimate the covariance 
    # M = 14  # Maximum Fourier coefficient index (-M to M), K_est <= M <= num_mic*(num_mic - 1) / 2
    M = 16

    # ----------------------------
    # Generate all necessary signals

    # Generate Diracs at random
    alpha_ks, phi_ks, time_stamp = gen_diracs_param(K, positive_amp=True, log_normal_amp=False, semicircle=False,
github LCAV / FRIDA / test_stft_speech.py View on Github external
'''

    save_fig = False
    save_param = True
    fig_dir = './result/'
    exp_dir = './Experiment/'
    speech_files = ['fq_sample1.wav', 'fq_sample2.wav']

    # Check if the directory exists
    if save_fig and not os.path.exists(fig_dir):
        os.makedirs(fig_dir)

    # parameters setup
    fs = 16000  # sampling frequency in Hz
    SNR = 0  # SNR for the received signal at microphones in [dB]
    speed_sound = pra.constants.get('c')

    num_mic = 6  # number of microphones
    K = len(speech_files)  # Real number of sources
    K_est = K  # Number of sources to estimate

    # algorithm parameters
    stop_cri = 'max_iter'  # can be 'mse' or 'max_iter'
    fft_size = 1024  # number of FFT bins
    n_bands = 4
    f_array_tuning = 600  # hertz
    M = 14  # Maximum Fourier coefficient index (-M to M), K_est <= M <= num_mic*(num_mic - 1) / 2

    # generate microphone array layout
    radius_array = 2.5 * speed_sound / f_array_tuning  # radiaus of antenna arrays

    # we would like gradually to switch to our "standardized" functions
github LCAV / FRIDA / test_doa_simulated.py View on Github external
# file parameters
    save_fig = False
    save_param = True
    fig_dir = './result/'
    exp_dir = './experiment/'
    available_files = ['samples/fq_sample1.wav', 'samples/fq_sample2.wav']
    speech_files = available_files[:num_src]

    # Check if the directory exists
    if save_fig and not os.path.exists(fig_dir):
        os.makedirs(fig_dir)

    # parameters setup
    fs = 16000  # sampling frequency in Hz
    SNR = 5  # SNR for the received signal at microphones in [dB]
    speed_sound = pra.constants.get('c')

    #num_mic = 48  # number of microphones
    # generate microphone array layout
    #radius_array = 2.5 * speed_sound / f_array_tuning  # radiaus of antenna arrays
    # we would like gradually to switch to our "standardized" functions
    # mic_array_coordinate = pra.spiral_2D_array([0, 0], num_mic,
    #                                            radius=radius_array,
    #                                            divi=7, angle=0)
    R_flat_I = range(8, 16) + range(24, 32) + range(40, 48)
    mic_array_coordinate = arrays['pyramic_tetrahedron'][:2,R_flat_I]
    num_mic = mic_array_coordinate.shape[1]

    K = len(speech_files)  # Real number of sources
    K_est = K  # Number of sources to estimate

    # algorithm parameters
github LCAV / FRIDA / test_doa_whitenoise.py View on Github external
elif opt in ("-b", "--n_bands"):
            n_bands = int(arg)

    # file parameters
    save_fig = False
    save_param = True
    fig_dir = './result/'

    # Check if the directory exists
    if save_fig and not os.path.exists(fig_dir):
        os.makedirs(fig_dir)

    # parameters setup
    fs = 16000  # sampling frequency in Hz
    SNR = 20  # SNR for the received signal at microphones in [dB]
    speed_sound = pra.constants.get('c')

    K = num_src  # Real number of sources
    K_est = K  # Number of sources to estimate

    # algorithm parameters
    stop_cri = 'max_iter'  # can be 'mse' or 'max_iter'
    fft_size = 256  # number of FFT bins
    num_snapshot = 256  # number of snapshots used to estimate the covariance 
    M = 14  # Maximum Fourier coefficient index (-M to M), K_est <= M <= num_mic*(num_mic - 1) / 2

    # ----------------------------
    # Generate all necessary signals

    # Generate Diracs at random
    alpha_ks, phi_ks, time_stamp = gen_diracs_param(K, positive_amp=True, log_normal_amp=False, semicircle=False, save_param=save_param)
    alpha_ks = np.ones(K)
github LCAV / FRIDA / tools / generators.py View on Github external
M = R.shape[1]
    dim = R.shape[0]

    # the number of sources
    K = doa.shape[1]

    # convert the spherical coordinates to unit propagation vectors
    p_vec = -unit_vec(doa)

    # the delays are the inner product between unit vectors and mic locations
    # set zero delay at earliest microphone
    delays = np.dot(p_vec.T, R) / pra.constants.get('c')
    delays -= delays.min()

    # figure out the maximal length of the impulse responses
    L = pra.constants.get('frac_delay_length')
    t_max = delays.max()
    D = int(L + np.ceil(np.abs(t_max * fs)))

    # the impulse response filter bank
    fb = np.zeros((K, M, D))

    # create all the impulse responses
    for k in xrange(K):
        for m in xrange(M):
            t = delays[k, m]
            delay_s = t * fs
            delay_i = int(np.round(delay_s))
            delay_f = delay_s - delay_i
            fb[k, m, delay_i:delay_i + (L - 1) + 1] += pra.fractional_delay(delay_f)

    return fb
github LCAV / FRIDA / tools / generators.py View on Github external
elif doa.ndim == 1:
        doa = np.array([doa])

    # the number of microphones
    M = R.shape[1]
    dim = R.shape[0]

    # the number of sources
    K = doa.shape[1]

    # convert the spherical coordinates to unit propagation vectors
    p_vec = -unit_vec(doa)

    # the delays are the inner product between unit vectors and mic locations
    # set zero delay at earliest microphone
    delays = np.dot(p_vec.T, R) / pra.constants.get('c')
    delays -= delays.min()

    # figure out the maximal length of the impulse responses
    L = pra.constants.get('frac_delay_length')
    t_max = delays.max()
    D = int(L + np.ceil(np.abs(t_max * fs)))

    # the impulse response filter bank
    fb = np.zeros((K, M, D))

    # create all the impulse responses
    for k in xrange(K):
        for m in xrange(M):
            t = delays[k, m]
            delay_s = t * fs
            delay_i = int(np.round(delay_s))
github LCAV / FRIDA / figure_RMSE_wn.py View on Github external
save_fig = False
    save_param = False
    fig_dir = './result/'

    # Check if the directory exists
    if save_fig and not os.path.exists(fig_dir):
        os.makedirs(fig_dir)

    # Simulation parameters
    SNR = np.arange(-10., 20., 5.)
    sim_loops = 1
    thresh_detect = 1e-2

    # Fixed parameters
    fs = 8000  # sampling frequency in Hz
    speed_sound = pra.constants.get('c')

    K = 5  # Real number of sources
    K_est = 5  # Number of sources to estimate
    num_mic = 10  # number of microphones

    # algorithm parameters
    stop_cri = 'max_iter'  # can be 'mse' or 'max_iter'
    max_ini = 50  # maximum number of random initialisation
    num_snapshot = 256  # number of snapshots used to estimate the covariance matrix
    fft_size = 1024  # number of FFT bins
    fc = [500.]      # frequency in Hertz
    fft_bins = [int(f / fs * fft_size) for f in fc]
    M = 30  # Maximum Fourier coefficient index (-M to M), K_est <= M <= num_mic*(num_mic - 1) / 2

    # generate microphone array layout
    radius_array = 2.5 * speed_sound / fc[0]  # radius of antenna arrays
github LCAV / FRIDA / pt_src_recon_multiband.py View on Github external
The source are placed circularly in the far field with respect to
    the microphone array. Here we use multibands
    '''

    save_fig = False
    save_param = True
    fig_dir = './result/'

    # Check if the directory exists
    if save_fig and not os.path.exists(fig_dir):
        os.makedirs(fig_dir)

    # parameters setup
    fs = 8000  # sampling frequency in Hz
    SNR = 0  # SNR for the received signal at microphones in [dB]
    speed_sound = pra.constants.get('c')

    K = 5  # Real number of sources
    K_est = 5  # Number of sources to estimate
    num_mic = 10  # number of microphones

    # algorithm parameters
    stop_cri = 'max_iter'  # can be 'mse' or 'max_iter'
    num_snapshot = 256  # number of snapshots used to estimate the covariance matrix
    fft_size = 1024  # number of FFT bins
    fc = np.array([450, 500, 550, 600])
    fft_bins = (fc / fs * fft_size).astype(int)

    M = 15  # Maximum Fourier coefficient index (-M to M), K_est <= M <= num_mic*(num_mic - 1) / 2

    # ----------------------------
    # Generate all necessary signals