0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HARK の伝達関数ファイル中の .mat ファイルのインパルス応答表現

Posted at

やりたいこと

HARK の伝達関数は zip になっていて、その中の .mat ファイルには
場所ごとの定位 / 分離の伝達関数が入っている。
その伝達関数は FFT された後の表現なので、インパルス応答表現に変換したい。

問題

IFFT とか色々しないといけない

解決方法

  1. zip ファイルの解凍
    unzip foobar.zip で、 transferFunction/ ディレクトリができる。
    ここの、 localization/, separation/ に定位・分離の伝達関数ファイルがある。

  2. .mat ファイルの .csv への変換
    harktool の cli を使う。 mat2csv は mat を csv に変えてくれる。
    harktoolcli-mat2csv tf00000.mat -o tf00000.csv

  3. インパルス応答表現にして plot
    .csv を読み込んで、実:虚の順で並んでいるので複素数行列に変換して、
    対象になるよにくっつけて、直流成分を除去して、 ifft する。

import csv
import numpy
import sys
import pylab

dat = numpy.loadtxt(sys.argv[1], delimiter=",")
datcomp = dat[:, ::2] + 1j * dat[:, 1::2]
datfull = numpy.c_[numpy.fliplr(datcomp), datcomp]
datfull = datfull[:, :-1]

# datfull
# 0Hz, fs/nfft Hz, 2*fs/nfft Hz, ..., nfft Hz, nfftHz, ..., fs/nfft Hz

flt = pylab.ifft2(datfull)[:, :datfull.shape[1]/2]

for nch in range(flt.shape[0]):
    pylab.subplot(flt.shape[0], 1, nch+1)
    pylab.plot(flt[nch, :])
pylab.show()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?