2016-11-03 3 views
0

설명서에 scipy.io.wavfile.read은 샘플 속도와 데이터를 반환한다고 말합니다. 그러나 .wav 개의 파일의 경우 데이터가 실제로 실제로 의미하는 것은 무엇입니까?scipy.io.wavfile.read가 반환 한 데이터는 무엇을 의미합니까?

누구나 그 데이터가 어떻게 준비되는지 평신도 용어로 알 수 있습니까?

추신. 진폭을 의미하는 어딘가 읽었습니까? 내가 읽은 것이 맞습니까? 그렇다면 진폭은 어떻게 계산되고 scipy.io.wavfile.read에 의해 반환됩니까?

답변

0

scipy.io.wavfile.read.wav 파일을 헤더와 파일에 포함 된 데이터로 분해하는 편리한 래퍼입니다. 소스로부터 source code

Returns 
------- 
rate : int 
    Sample rate of wav file. 
data : numpy array 
    Data read from wav file. Data-type is determined from the file; 
    see Notes. 

단순화 코드 가입일

:

fid = open(filename, 'rb') 
try: 
    file_size, is_big_endian = _read_riff_chunk(fid) # find out how to read the file 
    channels = 1 # assume 1 channel and 8 bit depth if there is no format chunk 
    bit_depth = 8 
    while fid.tell() < file_size: #read the file a couple of bytes at a time 
     # read the next chunk 
     chunk_id = fid.read(4) 

     if chunk_id == b'fmt ': # retrieve formatting information 
      fmt_chunk = _read_fmt_chunk(fid, is_big_endian) 
      format_tag, channels, fs = fmt_chunk[1:4] 
      bit_depth = fmt_chunk[6] 
      if bit_depth not in (8, 16, 32, 64, 96, 128): 
       raise ValueError("Unsupported bit depth: the wav file " 
           "has {}-bit data.".format(bit_depth)) 
     elif chunk_id == b'data': 
      data = _read_data_chunk(fid, format_tag, channels, bit_depth,is_big_endian, mmap) 

finally: 
    if not hasattr(filename, 'read'): 
     fid.close() 
    else: 
     fid.seek(0) 

return fs, data 

데이터 자체는 PCM은 상이한 채널에 대한 연속적인 프레임에서의 음압 레벨을 나타내는 일반적이다. scipy.io.wavfile.read에 의해 반환되는 샘플링 속도는 초를 나타내는 프레임 수를 결정하는 데 필요합니다.

.wav 형식에 대한 설명은 question입니다.

scipy는 독자적으로 많이 계산하지 않습니다.