Beispiel #1
0
 def reconstruct_rir(self, output):
     fdl = 81
     fdl2 = (fdl-1) // 2
     time = (output[:,0].astype('double')+1)*1024
     peaks = np.exp(-output[:,1]).astype('double')
     ir = np.arange(np.ceil((1.05*time.max()) + fdl))*0
     for i in range(time.shape[0]):
         time_ip = int(np.round(time[i]))
         time_fp = time[i] - time_ip
         ir[time_ip-fdl2:time_ip+fdl2+1] += peaks[i]*fractional_delay(time_fp)
     start_ind = min(np.where(ir != 0)[0])
     ir = ir[start_ind:-3000]
     return ir
Beispiel #2
0
def reconstruct_rir(time, alpha):
    '''
    Construct a room impulse response from the negative log version that the
    networks use. Uses the sinc function to approximate a physical impulse response.
    A random subset of the reflections are negated (helps with removing artefacts).
    Adopted from pyroomacoustics.
    '''
    fdl = 81
    fdl2 = (fdl-1) // 2
    time = (time.astype('double')+1)*1024
    alpha = np.exp(-alpha).astype('double')
    signs = np.random.randint(0,2, len(alpha))*2-1
    #alpha *= signs
    ir = np.arange(np.ceil((1.05*time.max()) + fdl))*0
    for i in range(time.shape[0]):
        time_ip = int(np.round(time[i]))
        time_fp = time[i] - time_ip
        ir[time_ip-fdl2:time_ip+fdl2+1] += alpha[i]*fractional_delay(time_fp)
    start_ind = min(np.where(ir != 0)[0])
    ir = ir[start_ind:]
    return ir