def shoebox_rir(room_dim, source, mic): # Some simulation parameters Fs = 8000 t0 = 1.0 / (Fs * np.pi * 1e-2) # starting time function of sinc decay in RIR response absorption = 0.90 max_order_sim = 10 # create a microphone array R = pra.linear2DArray(mic, 1, 0, 1) mics = pra.Beamformer(R, Fs) # create the room with sources and mics room1 = pra.Room.shoeBox2D( [0, 0], room_dim, Fs, t0=t0, max_order=max_order_sim, absorption=absorption, sigma2_awgn=0 ) # add source and interferer room1.addSource(source) room1.addMicrophoneArray(mics) room1.compute_RIR() h = room1.rir[0][0] return h
def shoebox_rir(room_dim, source, mic): # Some simulation parameters Fs = 8000 t0 = 1./(Fs*np.pi*1e-2) # starting time function of sinc decay in RIR response absorption = 0.90 max_order_sim = 10 # create a microphone array R = pra.linear2DArray(mic, 1, 0, 1) mics = pra.Beamformer(R, Fs) # create the room with sources and mics room1 = pra.Room.shoeBox2D( [0,0], room_dim, Fs, t0 = t0, max_order=max_order_sim, absorption=absorption, sigma2_awgn=0) # add source and interferer room1.addSource(source) room1.addMicrophoneArray(mics) room1.compute_RIR() h = room1.rir[0][0] return h
max_order_design = 1 # maximum image generation used in design shape = 'Linear' # array shape Lg_t = 0.050 # Filter size in seconds Lg = np.ceil(Lg_t * Fs) # Filter size in samples delay = 0.03 # define the FFT length N = 1024 # create a microphone array if shape is 'Circular': R = pra.circular2DArray(mic1, M, phi, d * M / (2 * np.pi)) elif shape is 'Poisson': R = pra.poisson2DArray(mic1, M, d) else: R = pra.linear2DArray(mic1, M, phi, d) mics = pra.Beamformer(R, Fs, N=N, Lg=Lg) # The first signal (of interest) is singing rate1, signal1 = wavfile.read('samples/singing_' + str(Fs) + '.wav') signal1 = np.array(signal1, dtype=float) signal1 = pra.normalize(signal1) signal1 = pra.highpass(signal1, Fs) delay1 = 0. # the second signal (interferer) is some german speech rate2, signal2 = wavfile.read('samples/german_speech_' + str(Fs) + '.wav') signal2 = np.array(signal2, dtype=float) signal2 = pra.normalize(signal2) signal2 = pra.highpass(signal2, Fs) delay2 = 1.
d = 0.04 # distance between microphones phi = 0. # angle from horizontal max_order_design = 1 # maximum image generation used in design shape = 'Linear' # array shape Lg_t = 0.05 # Filter size in seconds Lg = np.ceil(Lg_t*Fs) # Filter size in samples delay = 0.02 # define the FFT length N = 1024 # create a microphone array if shape is 'Circular': R = pra.circular2DArray(mic1, M, phi, d*M/(2*np.pi)) else: R = pra.linear2DArray(mic1, M, phi, d) mics = pra.Beamformer(R, Fs, N=N, Lg=Lg) # The first signal (of interest) is singing rate1, signal1 = wavfile.read('samples/singing_'+str(Fs)+'.wav') signal1 = np.array(signal1, dtype=float) signal1 = pra.normalize(signal1) signal1 = pra.highpass(signal1, Fs) delay1 = 0. # the second signal (interferer) is some german speech rate2, signal2 = wavfile.read('samples/german_speech_'+str(Fs)+'.wav') signal2 = np.array(signal2, dtype=float) signal2 = pra.normalize(signal2) signal2 = pra.highpass(signal2, Fs) delay2 = 1.