3
내가 단일 채널 데이터를 계산 코드의 (4 채널 1과 채널 사이의 오디오 교차 상관 관계를 계산하기 위해) 할
:PyAudio - 여러 채널 관리 의 Demixing
import time
import numpy as np
import pyaudio
import scipy
from scipy import signal, fftpack
pyaud = pyaudio.PyAudio()
#open the stream
stream = pyaud.open(
format = pyaudio.paInt16,
channels = 4,
rate = 16000,
input_device_index = 4,
output = False,
input = True,
frames_per_buffer=2048,)
while True:
rawsamps = stream.read(2048)
samps = np.fromstring(rawsamps, dtype=np.int16)
frames_per_buffer_length = len(samps)/4 #(channels)
assert frames_per_buffer_length == int(frames_per_buffer_length)
samps = np.reshape(samps, (frames_per_buffer_length, 4)) #4 channels
원시한다고 가정을 데이터가 인터리브됩니다.
signal.correlate(n1, n2, mode='full')
방법 I는 상관 관계 함수를 사용하기 위해 각 채널의 데이터의 어레이를 만들 수
이 제가 사용하는데 필요한 기능은 무엇입니까? 코드의 마지막 줄이 맞습니까?
당신은 같은 질문을 (http://stackoverflow.com/q/41922139/) 및 [이상] (http : 다시 /stackoverflow.com/q/42027487/). 더 작게 시작하여 NumPy에 대한 몇 가지 기본 사항을 먼저 배워야합니다 (온라인에서 사용할 수있는 좋은 자습서가 많이 있습니다). [this] (http://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/simple-signals.ipynb)와 [that] (http : // nbviewer .jupyter.org/github/mgeier/python-audio/blob/master/audio-files/audio-files-with-wave.ipynb). – Matthias
이 작업을 완료하면 전에 보았던 [예제] (https://github.com/spatialaudio/python-sounddevice/blob/master/examples/plot_input.py)를 다시 한 번 볼 수 있습니다. – Matthias