示例#1
0
文件: generate.py 项目: rirnet/rirnet
def convolve_and_pad(wav, h_list):
    data_list = []

    for i_h, h in enumerate(h_list):
        y = au.convolve(wav, h)
        y_length = au.next_power_of_two(np.size(y))
        data = au.pad_to(y, y_length, 0)
        data_list.append(data)

    return np.array(data_list)
示例#2
0
def generate_waveforms(wav, h_list):
    data_list = []
    target_list = []

    for i_h, h in enumerate(h_list):
        y = au.convolve(wav, h)
        y_length = au.next_power_of_two(np.size(y))
        data = au.pad_to(y, y_length, 0)
        target = au.pad_to(h, y_length, 0)
        target_list.append(target)
        data_list.append(data)
    return np.array(target_list), np.array(data_list)
示例#3
0
def pad_list_to_pow2(h_list):
    longest_irf = len(max(h_list, key=len))
    target_length = au.next_power_of_two(longest_irf)
    h_list = [au.pad_to(h, target_length) for h in h_list]
    return h_list
示例#4
0
import rirnet.acoustic_utils as au
import librosa
import numpy as np
import matplotlib.pyplot as plt

out_path = '../audio/chamber/'
in_path = '../audio/chamber/full/full.wav'
rate = 44100
data, rate = au.read_wav(in_path, rate=rate)
sound_starts = librosa.onset.onset_detect(data, sr=rate, backtrack=True) * 512
for i, start in enumerate(sound_starts):
    stop = start + au.next_power_of_two(int(rate / 4))
    energy = np.sum(np.abs(data[stop - 100:stop]))
    if energy < 0.01:
        au.save_wav(out_path + 'ch_{}.wav'.format(i), data[start:stop], rate)