Created
March 2, 2019 23:43
-
-
Save rniwase/4a9a984bed61587d84fc1417fc26d5a4 to your computer and use it in GitHub Desktop.
畳み込みリバーブ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy import signal | |
import matplotlib.pyplot as plt | |
import soundfile as sf | |
indata, infrq = sf.read("indata.wav") | |
impulse, impfrq = sf.read("impulse.wav") | |
outdata_0 = signal.convolve(indata[:, 0], impulse[:, 0], mode="full") | |
outdata_1 = signal.convolve(indata[:, 1], impulse[:, 1], mode="full") | |
outdata = np.array([outdata_0, outdata_1]).T | |
sf.write("outdata.wav", outdata, infrq) | |
fig = plt.figure(1) | |
plt.subplot(3, 1, 1) | |
plt.plot(indata[:, 0], "b-") | |
plt.subplot(3, 1, 2) | |
plt.plot(impulse[:, 0], "r-") | |
plt.subplot(3, 1, 3) | |
plt.plot(outdata[:, 0], "g-") | |
plt.savefig("grph.png") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment