def hFilter(self, T60): rp = 1 # Receiver position sp = random.randint(2, 5) # Source position r = [2, rp, 2] # Receiver position [x y z] (m) s = [4, sp, 3] # Source position [x y z] (m) L = [4, 5, 6] # Room dimensions [x y z] (m) rt = round(random.uniform(0.8, 1.0), 1) # Reflections Coefficients n = int(T60 * self.sr) # Number of samples mtype = 'omnidirectional' # Type of microphone 默认 omnidirectional 全方向的 order = 8 # Reflection order dim = 3 # Room dimension ori = round(random.uniform(0, 2 * math.pi), 2) orientation = [ori, 0] # Microphone orientation (rad) hp_filter = 1 # Enable high-pass filter h = RG.rir_generator(self.c, self.sr, s, r, L, reverbTime=rt, nSamples=n, micType=mtype, nOrder=order, nDim=dim, orientation=orientation, isHighPassFilter=hp_filter) self.reverb_file_name = '_reverb_{}_{}_{}_{}_{}.wav'.format( rp, sp, rt, ori, n) return np.array(h)
import pyrirgen as RG c = 340 # Sound velocity (m/s) fs = 16000 # Sample frequency (samples/s) r = [2, 1.5, 2] # Receiver position [x y z] (m) s = [2, 3.5, 2] # Source position [x y z] (m) L = [5, 4, 6] # Room dimensions [x y z] (m) rt = 0.4 # Reflections Coefficients n = 2048 # Number of samples mtype = 'omnidirectional' # Type of microphone order = 2 # Reflection order dim = 3 # Room dimension orientation = [0, 0] # Microphone orientation (rad) hp_filter = 1 # Enable high-pass filter h = RG.rir_generator(c, fs, s, r, L, reverbTime=rt, nSamples=n, micType=mtype, nOrder=order, nDim=dim, orientation=orientation, isHighPassFilter=hp_filter) print(len(h))
import pyrirgen as RG c = 340 # Sound velocity (m/s) fs = 16000 # Sample frequency (samples/s) r = [2, 1.5, 2] # Receiver position [x y z] (m) s = [2, 3.5, 2] # Source position [x y z] (m) L = [5, 4, 6] # Room dimensions [x y z] (m) rt = 0.4 # Reverberation time (s) n = 4096 # Number of samples h = RG.rir_generator(c, fs, s, r, L, reverbTime=rt, nSamples=n) print(len(h))