Practice 1

Practice 1 on this page are for HARK Ver.3.5.0 or later.

Goal and Agenda of Practice1

  • 目的
    • HARK を用いた簡単なシステムを構築し、HARK Designerに慣れる
  • 内容>
    • HARKを用いた音源定位システムの構築
      1. HARKネットワークの構築
      2. 定位性能の評価実験

HARK Designer に慣れる

  • HARK designer
  • hark designer
  • カンバスとパネルの意味
  • hark designer

HARK Designer によるシステムの構築の流れ

  1. カンバスにノードを配置
    • ノードリストパネルから選択する
    • ノード検索フォームでノードを検索して選択する
  2. ノード同士の接続
    1. ノード出力端子からドラッグし、接続先のノード入力端子にドロップする
    2. ノ入出力の型が合えば候補として表示してくれる
  3. ノードのプロパティを設定
    • ノードをダブルクリックし、パラメータを設定する

Tips in Constructing Networks

  • ノードを置く
    • ノード検索フォームでノードを検索して選択
    • ノードリストパネルから選択してクリック
  • ノードを削除
    • ノードを右クリックして”Delete”をクリック
    • ノードを選択して DELキーを押す
  • ノード同士の接続
    • 接続元ノード出力端子の黒丸から接続先ノード入力端子へ左ドラッグ&ドロップ(入出力の型が合えば候補として表示)
  • ノードをコピー&ペースト
    • Ctrl-c でノードコピー
    • Ctrl-v でノードペースト
  • 接続を削除
    • リンクが接続された入出力端子を右クリックし、”Delete the link”をクリック
  • シート上の全てのノードを整列
    • format buttonを押す
  • 新しいシートを追加
    • add buttonを押し,適当な名前を指定してシートを追加する

HARKによる音源定位システムの構築

はじめに

  • 目的  HARK Designerによる聴覚システムの構築を体験する
  • 目標  HARKを使ってを使って、音源定位システムを0から構築する
  • 実習の前に
    • dataフォルダに以下のファイルが入っていることを確認
      • practice1.wav
      • practice1_2.wav
      • practice1_option.wav
      • tamago_rectf.zip
      • sendHarkParam.py
      • example/(Practice1 で作成するネットワークの完成品が入っている)
  • 実習の構成
    • Practice 1-1
      • waveファイルを入力とした音源定位システムの構築
      • 定位のパラメータは固定
    • Practice 1-2
      • Practice1-1で構築した音源定位システムのパラメータを動的に変更できるように改造
    • Practice 1-3
      • Practice1-2で構築した音源定位システムをリアルタイムにマイクロフォンアレイから入ってきた信号を処理するように改造

 

Practice1-1 HARKによる音源定位システムの構築

Practice1-1 の概要

  • システムの入出力
    • 入力 : TAMAGO03 Tamago03 Microphone Array で録音された 8ch のwaveファイル
    • 出力 : 定位結果の表示
  • 必要ファイル
    • 定位用伝達関数ファイル(事前に作成済み)
      • TAMAGO用の伝達関数ファイル : tamago_rectf.zip
    • 評価用入力waveファイル
      • 水平面上にいる三話者 : practice1.wav

定位用伝達関数ファイルの概要

  • 用意した定位用伝達関数ファイル
    • practice1/data/tamago_rectf.zip (for TAMAGO03)
    • 午前中のビデオの方法でTSPを録音
      • 録音にhark-wios を使用します。詳細はドキュメントを参照
    • TSP録音データから定位用伝達関数ファイルを生成
      • harktool5 を使用
      • 詳細はharktool5 のドキュメントを参照

音源定位システムの概要

  • 次の順番で作成
  • Practice1-1 の処理の流れ
    1. 音声波形読み込み
    2. Iteration用サブネットワークの作成
    3. 音源定位部分
      1. 周波数解析 (FFT)
      2. MUSIC法で音源定位
      3. 音源のトラッキング
    4. 結果表示

HARK Designer の3通りの起動方法

  1. HARK Designer HARK logo をクリック
  2. ターミナルで"hark_designer" と入力
  3. hark_designer
  4. ブラウザーで http://127.0.0.1:3000/ と入力
  5. http://127.0.0.1:3000/

音声波形読み込み部分の作成

  1. ノードの配置
    • HARK Designer でノードを追加
      • Constant ノードの追加
      • ノードリストパネル › General › Constant
      • InputStream ノードの追加
      • ノードリストパネル › IO › InputStream
      Adding nodes
  2. ノードの接続
    • Constantの右側の黒点(出力端子)をドラッグ
    • InputStreamの左側の黒点(入力端子)でドロップ
    Connecting nodes
  3. ノードの設定
    • 読み込むwavファイル名を指定
      1. Constantを右クリックし、Property を選択
      2. Type は string に設定
      3. VALUE に practice1.wav と入力
Connecting nodes

 

サブネットワークの作成

  • 1フレーム分読み込むたびに実行されるサブネットワーク LOOP0 を作成
Connecting nodes

音源定位部分の作成

  1. ノードの配置
    • 次の5種類のノードを LOOP0 シートに配置
      • LOOP0 シートを選択
      • ファイルの読み込みノードの追加
      • ノードリストパネル > HARK:AudioIO  > Constant
      • マルチチャネルFFT のノードの追加
      •  FFT (Fast Fourier Transform): 音声波形の周波数分析
        ノードリストパネル > HARK:MISC > MultiFFT
      • MUSIC 法による音源定位のノードの追加
      •  MUSIC (MUltiple SIgnal Classification): 音源定位手法の一つ
        ノードリストパネル > HARK:Localization > LocalizeMUSIC
      • 音源トラッキングのノードの追加
      • ノードリストパネル > HARK:Localization > SourceTracker
      • 定位結果表示のノードの追加
      • ノードリストパネル > HARK:Localization  > DisplayLocalization
  2. ノードの接続
  3. Adding nodes
    1. LOOP0 シートを選択
    2. 5つのノードを接続
      • AudioStreamFromWave の AUDIO ⇒ MultiFFT の Input
      • MultiFFT の Output ⇒ LocalizeMUSIC の Input
      • LocalizeMUSIC の Output ⇒ SourceTracker の Input
      • SourceTrackerの Output ⇒ DisplayLocalization の Input
  4. ノードの設定
      • 5つのノードのプロパティを設定
      • プロパティの設定方法は今までと同じ:次の2つの方法のどちらかで
        • ノードを右クリックし、Property を選択
        • ノードをダブルクリック
      • 以下、ノードごとに設定方法を解説
        • 多くはデフォルト値のままでよい
        • 変更が必要なものは赤字で表示
      1. 波形データの読み込み AudioStreamFromWave
      2. AudioStreamFromWaveのパラメータ
        • LENGTH = 512 1回の読込で読むサンプル数 [samples]
        • ADVANCE = 160読み込む窓のシフト幅 [samples]
        • USE_WAIT = true trueなら処理時間が実時間となるようにwaitをかける
      3. マルチチャネル信号用のFFT MultiFFT
      4. MultiFFTのパラメータ
        • LENGTH = 512 FFT点数(フレーム長) [samples]
        • WINDOW = CONJ FFTに使う窓関数:選べる関数のは
          • CONJ
          • HAMMING
          • RECTANGLE(矩形窓)
        • WINDOW_LENGTH = 512  窓長 [samples]
      5. MUSIC法による音源定位 LocalizeMUSIC
      6. LocalizeMUSICのパラメータ
        • MUSIC_ALGORITHM = SEVD  MUSIC法のアルゴリズムの選択:選べるのは
          • SEVD (標準固有値分解:Standard Eigen Value Decomposition
          • GEVD (一般化固有値分解:Gemeralized Eigen Value Decomposition
          • GSVD (一般化特異値展開:Generalized Singlar Value Decomposition
        • TF_CHANNEL_SELECTION = <Vector<int> >  入力の音声波形の使用チャネル番号
          • すべて使う設定: <Vector<int> >
          • 一部のみ使う設定: <Vector<int> 0,1,2>
        • LENGTH = 512  フレーム長 (= MultiFFTのFFT点数) [samples]
        • A_MATRIX = tamago_rectf.zip  定位用伝達関数のファイル名  今回は事前に準備したものを使用
        • WINDOW = 50 相関行列の計算に使うフレーム数 [frames]
        • WINDOW_TYPE = FUTURE 相関行列の計算に使うフレームの設定
        • PERIOD = 50 音源の到来方向推定を行うフレーム周期 [frames]
        • WINDOW_TYPE = FUTURE 相関行列の計算に使うフレームの設定
        • PERIOD = 50 音源の到来方向推定を行うフレーム周期 [frames]
        • LocalizeMUSICの水平方向
        • NUM_SOURCE = 2 定位目的音源の数(マイク数-1以下)
        • MIN_DEG = -180 音源方向の最小値 [deg]
        • MAX_DEG = 180 音源方向の最大値 [deg]
        • LOWER_BOUND_FREQUENCY = 500 定位に用いる周波数の最小値 [Hz]
        • UPPER_BOUND_FREQUENCY = 2800 定位に用いる周波数の最大値 [Hz]
        • SPECTRUM_WEIGHT_TYPE = Uniform MUSICスペクトルの周波数重みの種類
        • ENABLE_EIGENVALUE_WEIGHT = true MUSICスペクトル算出時の固有値重みの有無
        • MAXNUM_OUT_PEAKS = -1 SourceTrackerへ出力する最大音源数
        • DEBUG = false trueなら、音源定位結果を標準出力に出力
      7. 方位角と仰角を用いた音源追跡 SourceTracker
        • フレーム毎の音源定位結果を時間的に統合
        • 同じ音源には同じIDを付与
          判別ルール
        • THRESH より音源のパワーが小さければ削除
        • PAUSE_LENGTH [ms] より短い区間の無音区間は無視して同じ音源と判定
        • MIN_SRC_INTERVAL [deg] より音源方向が近ければ同じ音源と判定
        SourceTrackerのパラメータ
        • THRESH = 34  音源方向のパワーがTHRESH以下なら、ノイズとみなして音源を無視
        • PAUSE_LENGTH = 1500 音源が未観測でも追跡が継続する区間 [ms]
        • MIN_SRC_INTERVAL = 30 同じ音源方向であるとみなす範囲 [deg]
        • MIN_ID = 0 音源に振られるID番号の最初の値
        • DEBUG = false trueなら音源定位結果を標準出力に出力
      8. 方位角音源定位結果を表示 DisplayLocalization(一つ目)
      9. DisplayLocalization
        • WINDOW_NAME = Azimuth 定位結果を表示するウィンドウ名
        • WINDOW_LENGTH = 1000 音源定位結果を表示するフレーム幅
        • VERTICAL_RANGE = <Vector<int> -180 180> 縦軸に表示する値域の範囲
        • PLOT_TYPE = AZIMUTH 表示するデータの種類(上記の場合は方位角)
      10. 方位角音源定位結果を表示 DisplayLocalization(二つ目) practice1-1 では不要。付録で説明
      11. DisplayLocalization
        • WINDOW_NAME = Elevation 定位結果を表示するウィンドウ名
        • WINDOW_LENGTH = 1000  音源定位結果を表示するフレーム幅
        • VERTICAL_RANGE = <Vector<int> -90 190> trueなら処理時間が実時間となるようにwaitをかける
        • PLOT_TYPE = ELEVATION 表示するデータの種類(上記の場合は仰角)
        DisplayLocalization

入出力とループ条件の設定

  • Iterator シートは while 文のようにふるまうシートには3つの重要な端子がある
    • Input Iteratorシートをノードとして使うときの入力
    • Output Iteratorシートをノードとして使うときの出力
    • Condition Iteratorシートのwhile文の条件文  この端子に設定した出力がFalseになった時点で繰り返しが終了し、MAINシートに処理が返る
入出力とループ条件の設定
  1. Input AudioStreamFromWaveの入力端子を右クリックし、“Set as Input” を選択
  2. Output DisplayLocalizationの出力端子を右クリックし、“Set as Output”を選択
  3. Condition NOT_EOFを右クリックし、“Set as Condition”を選択

MAINシートとLOOP0シートの接続

MAINシートとLOOP0シートの接続
  1. Mainシートを選択
  2. ノードの選択
  3. ノードリストパネル > Dynamic  > LOOP0
  4. LOOP0 を InputStream に接続
  5. LOOP0 の出力端子を右クリックし,"Set as Output" を選択

Practice1-1 完成した音源定位ステムのネットワーク

完成した音源定位ステムのネットワーク

ネットワークファイルの保存

  1. Save ボタンを押して practice1-1.n というファイル名でネットワークファイルを保存する。
  2. ネットワークファイルの保存
  3. Network file name で "practice1-1.n" と入力しクリック
  4. 完成した音源定位ステムのネットワーク

ネットワークファイル practice1-1.n の中身

#!/usr/bin/env batchflow
<?xml version="1.0"?>
<Document>
  <Network type="subnet" name="MAIN">
    <Node name="node_InputStream_1" type="InputStream" x="280" y="100">
      <Parameter name="TYPE" type="string" value="" description="Type of stream: stream, fd, or FILE (default stream)"/>
      <Parameter name="RETRY" type="int" value="" description="If set to N, InputStream will retry N times on open fail"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_Constant_1" type="Constant" x="100" y="100">
      <Parameter name="VALUE" type="string" value="practice1.wav" description="The value"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_LOOP0_1" type="LOOP0" x="490" y="100">
    </Node>
    <Link from="node_Constant_1" output="VALUE" to="node_InputStream_1" input="INPUT"/>
    <Link from="node_InputStream_1" output="OUTPUT" to="node_LOOP0_1" input="INPUT"/>
    <NetOutput name="OUTPUT" node="node_LOOP0_1" terminal="OUTPUT" object_type="any" description="Dynamic"/>
  </Network>
  <Network type="iterator" name="LOOP0">
    <Node name="node_SourceTracker_1" type="SourceTracker" x="180" y="270">
      <Parameter name="THRESH" type="float" value="34" description="Power threshold for localization results. A localization result with higher power than THRESH is tracked, otherwise ignored."/>
      <Parameter name="PAUSE_LENGTH" type="float" value="1500" description="Life duration of source in ms. When any localization result for a source is found for more than PAUSE_LENGTH / 10 iterations, the source is terminated. [default: 800]"/>
      <Parameter name="MIN_SRC_INTERVAL" type="float" value="30" description="Source interval threshold in degree. When the angle between a localization result and a source is smaller than MIN_SRC_INTERVAL, the same ID is given to the localization result. [default: 20]"/>
      <Parameter name="MIN_ID" type="int" value="0" description="Minimum ID of source locations. MIN_ID should be greater than 0 or equal."/>
      <Parameter name="DEBUG" type="bool" value="false" description="Output debug information if true [default: false]"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_MultiFFT_1" type="MultiFFT" x="390" y="100">
      <Parameter name="LENGTH" type="int" value="512" description="FFT length in sample. [default: 512]"/>
      <Parameter name="WINDOW" type="string" value="CONJ" description="A window function for FFT. WINDOW should be CONJ, HAMMING, RECTANGLE, or HANNING. [default: CONJ]"/>
      <Parameter name="WINDOW_LENGTH" type="int" value="512" description="Window length of the window function. [default: 512]"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_DisplayLocalization_1" type="DisplayLocalization" x="490" y="270">
      <Parameter name="WINDOW_NAME" type="string" value="Source Location" description="Window name of the time-azimuth map [default: Window name]"/>
      <Parameter name="WINDOW_LENGTH" type="int" value="1000" description="Window length to show at the same time [sample]"/>
      <Parameter name="VERTICAL_RANGE" type="object" value="<Vector<int> -180 180>" description="Plot range of the vertical axis"/>
      <Parameter name="PLOT_TYPE" type="string" value="AZIMUTH" description="Coordinate setting for the plotting"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_AudioStreamFromWave_1" type="AudioStreamFromWave" x="100" y="100">
      <Parameter name="LENGTH" type="int" value="512" description="The frame length of each channel (in samples) [default: 512]."/>
      <Parameter name="ADVANCE" type="int" value="160" description="The shift length beween adjacent frames (in samples)[default: 160]."/>
      <Parameter name="USE_WAIT" type="bool" value="true" description="If true, real recording is simulated [default: false]."/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_LocalizeMUSIC_1" type="LocalizeMUSIC" x="580" y="100">
      <Parameter name="MUSIC_ALGORITHM" type="string" value="SEVD" description="Sound Source Localization Algorithm. If SEVD, NOISECM will be ignored"/>
      <Parameter name="TF_CHANNEL_SELECTION" type="object" value="<Vector<int> >" description="Microphone channels for localization. If vacant, all channels will be used."/>
      <Parameter name="LENGTH" type="int" value="512" description="The length of a frame (per channel)."/>
      <Parameter name="SAMPLING_RATE" type="int" value="16000" description="Sampling Rate (Hz)."/>
      <Parameter name="TF_INPUT_TYPE" type="string" value="FILE" description="Load form TF file or Input terminal."/>
      <Parameter name="A_MATRIX" type="string" value="tamago_rectf.zip" description="Filename of a transfer function matrix."/>
      <Parameter name="WINDOW" type="int" value="50" description="The number of frames used for calculating a correlation function."/>
      <Parameter name="WINDOW_TYPE" type="string" value="FUTURE" description="Window selection to accumulate a correlation function. If PAST, the past WINDOW frames from the current frame are used for the accumulation. If MIDDLE, the current frame will be the middle of the accumulated frames. If FUTURE, the future WINDOW frames from the current frame are used for the accumulation. FUTURE is the default from version 1.0, but this makes a delay since we have to wait for the future information. PAST generates a internal buffers for the accumulation, which realizes no delay for localization."/>
      <Parameter name="PERIOD" type="int" value="50" description="The period in which the source localization is processed."/>
      <Parameter name="NUM_SOURCE" type="int" value="2" description="Number of sources, which should be less than number of channels."/>
      <Parameter name="MIN_DEG" type="int" value="-180" description="source direction (lower)."/>
      <Parameter name="MAX_DEG" type="int" value="180" description="source direction (higher)."/>
      <Parameter name="LOWER_BOUND_FREQUENCY" type="int" value="500" description="Lower bound of frequency (Hz) used for correlation function calculation."/>
      <Parameter name="UPPER_BOUND_FREQUENCY" type="int" value="2800" description="Upper bound of frequency (Hz) used for correlation function calculation."/>
      <Parameter name="SPECTRUM_WEIGHT_TYPE" type="string" value="Uniform" description="MUSIC spectrum weight for each frequency bin."/>
      <Parameter name="A_CHAR_SCALING" type="float" value="1" description="Scaling factor of the A-Weight with respect to frequency"/>
      <Parameter name="MANUAL_WEIGHT_SPLINE" type="object" value="<Matrix<float> <rows 2> <cols 5> <data 0.0 2000.0 4000.0 6000.0 8000.0 1.0 1.0 1.0 1.0 1.0> >" description="MUSIC spectrum weight for each frequency bin. This is a 2 by M matrix. The first row represents the frequency, and the second row represents the weight gain. "M" represents the number of key points for the spectrum weight. The frequency range between M key points will be interpolated by spline manner. The format is "&lt;Matrix&lt;float&gt; &lt;rows 2&gt; &lt;cols 2&gt; &lt;data 1 2 3 4&gt; &gt;"."/>
      <Parameter name="MANUAL_WEIGHT_SQUARE" type="object" value="<Vector<float> 0.0 2000.0 4000.0 6000.0 8000.0>" description="MUSIC spectrum weight for each frequency bin. This is a M order vector. The element represents the frequency points for the square wave. "M" represents the number of key points for the square wave weight. The format is "&lt;Vector&lt;float&gt; 1 2 3 4&gt;"."/>
      <Parameter name="ENABLE_EIGENVALUE_WEIGHT" type="bool" value="true" description="If true, the spatial spectrum is weighted depending on the eigenvalues of a correlation matrix. We do not suggest to use this function with GEVD and GSVD, because the NOISECM changes the eigenvalue drastically. Only useful for SEVD."/>
      <Parameter name="MAXNUM_OUT_PEAKS" type="int" value="-1" description="Maximum number of output peaks. If MAXNUM_OUT_PEAKS = NUM_SOURCE, this is compatible with HARK version 1.0. If MAXNUM_OUT_PEAKS = 0, all local maxima are output. If MAXNUM_OUT_PEAKS &lt; 0, MAXNUM_OUT_PEAKS is set to NUM_SOURCE. If MAXNUM_OUT_PEAKS &gt; 0, number of output peaks is limited to MAXNUM_OUT_PEAKS."/>
      <Parameter name="DEBUG" type="bool" value="false" description="Debug option. If the parameter is true, this node outputs sound localization results to a standard output."/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Link from="node_SourceTracker_1" output="OUTPUT" to="node_DisplayLocalization_1" input="SOURCES"/>
    <Link from="node_AudioStreamFromWave_1" output="AUDIO" to="node_MultiFFT_1" input="INPUT"/>
    <Link from="node_MultiFFT_1" output="OUTPUT" to="node_LocalizeMUSIC_1" input="INPUT"/>
    <Link from="node_LocalizeMUSIC_1" output="OUTPUT" to="node_SourceTracker_1" input="INPUT"/>
    <NetInput name="INPUT" node="node_AudioStreamFromWave_1" terminal="INPUT" object_type="Stream" description="An audio input stream (IStream)."/>
    <NetOutput name="OUTPUT" node="node_DisplayLocalization_1" terminal="OUTPUT" object_type="any" description="outputsadded by the user"/>
    <NetCondition name="CONDITION" node="node_AudioStreamFromWave_1" terminal="NOT_EOF"/>
  </Network>
</Document>

Practice1-1 実験

  1. ファイルのアップロード
  2. ファイルアップロードの指示
    • ネットワークファイル: practice1-1 のアップロード
    • ネットワークファイルアップロードの確認
    • 伝達関数ファイル: tamago_rectf.zip のアップロード
    • 伝達関数ファイルアップロードの確認
    • 音声ファイル: practice1.wav のアップロード
    • 音声ファイルアップロードの確認
  3. practice1.wavを使用して実行
    1. ネットワークの実行 HARK DesignerのExecuteをクリック
    2. ネットワークファイルの実行
    3. 音源定位結果がWindowに表示される
    4. 音源定位結果の表示

ネットワークファイルの実行法

  • ターミナルを開き,practice1-1.n やtamago-tf.zip などがあるフォルダへ移動
  • $ cd /usr/lib/hark-designer/userdata/networks/ あるいは
    $ cd /home/HARK_tutorial_2023/practice1/data/ など	
  • batchflow コマンドを入力
  • $ batchflow practice1-1.n
  • 強制終了は Control-C で

 

Practice1-2 パラメータ調整のシステム開発

Practice1-2 の概要

  • 目的: Practice1-1で構築した音源定位システムのパラメータを動的に変更できるように改造
  • システムの入出力
    • 入力1 : TAMAGOで録音された 8ch のwaveファイル
    • 入力2 : GUIで動的に入力する定位のパラメータ (ここが practice1-1 と異なる。)
    • 出力 : 音源定位結果の表示
  • 必要ファイル
    • 定位用伝達関数ファイル(事前に作成済み)
      • TAMAGO用の伝達関数ファイル : tamago_rectf.zip
    • 評価用入力waveファイル
      • 水平面上にいる三話者 : practice1.wav

Practice1-2: Practice1-1からの改造点

Practice1-1からPractice1-2への変更点
  • LocalizeMUSICに入力端子を増やす
  • Source Trackerに入力端子を増やす
  • LocalizeMUSICの入力端子を増やす
  1. LocalizeMUSICの入力端子の追加
  2. LocalizeMUSICに入力端子を増やす
    1. LOOP0シートを選択
    2. LocalizeMUSICを右クリック
    3. "Add Input" を選択
    4. "PARAMS" と入力
    5. "Add" をクリック
  3. Source Trackerに入力端子を追加
  4. SourceTrackerに入力端子を増やす
    1. SourceTrackerを右クリック
    2. "Add Input" を選択
    3. "PARAMS" と入力
    4. "Add" をクリック
  5. GUIからの動的パラメータ受取部分の作成
  6. HARKParamsDynReconfの追加
    1. LOOP0シートを選択
    2. ノードの追加
    3. HARK:MISC > HarkParamsDynReconf
    4. ノードの接続
    5. HARKParamsDynReconfの接続
      • AudioStreamFromWave の AUDIO ⇒ MultiFFT の Input
      • MultiFFT の Output ⇒ LocalizeMUSIC の Input
      • HarkParamsDynReconf の LocalizeMUSIC ⇒ LocalizeMUSIC の Params
      • HarkParamsDynReconf の SourceTracker ⇒ SourceTracker の Params
      • LocalizeMUSIC の Output ⇒ SourceTracker の Input
      • SourceTrackerの Output ⇒ DisplayLocalization の Input
      • udioStreamFromWave の NOT_EOFを右クリックし、“Set as Condition”を選択

Practice1-2 完成したパラメータ動的制御の音源定位ステムのネットワーク

完成したパラメータ動的制御の音源定位ステムのネットワーク

ネットワークファイルの保存

  1. Save ボタンを押して practice1-2.n というファイル名でネットワークファイルを保存する。
  2. Network file name で "practice1-2.n" と入力しクリック

ネットワークファイル practice1-2.n の中身

#!/usr/bin/env batchflow
<?xml version="1.0"?>
<Document>
  <Network type="subnet" name="MAIN">
    <Node name="node_InputStream_1" type="InputStream" x="300" y="100">
      <Parameter name="TYPE" type="string" value="" description="Type of stream: stream, fd, or FILE (default stream)"/>
      <Parameter name="RETRY" type="int" value="" description="If set to N, InputStream will retry N times on open fail"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_LOOP0_1" type="LOOP0" x="520" y="100">
    </Node>
    <Node name="node_Constant_1" type="Constant" x="100" y="100">
      <Parameter name="VALUE" type="string" value="practice1.wav" description="The value"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Link from="node_InputStream_1" output="OUTPUT" to="node_LOOP0_1" input="INPUT"/>
    <Link from="node_Constant_1" output="VALUE" to="node_InputStream_1" input="INPUT"/>
    <NetOutput name="OUTPUT" node="node_LOOP0_1" terminal="OUTPUT" object_type="Vector&lt;ObjectRef&gt;" description="The same as input."/>
  </Network>
  <Network type="iterator" name="LOOP0">
    <Node name="node_SourceTracker_1" type="SourceTracker" x="580" y="270">
      <Parameter name="THRESH" type="float" value="34" description="Power threshold for localization results. A localization result with higher power than THRESH is tracked, otherwise ignored."/>
      <Parameter name="PAUSE_LENGTH" type="float" value="1500" description="Life duration of source in ms. When any localization result for a source is found for more than PAUSE_LENGTH / 10 iterations, the source is terminated. [default: 800]"/>
      <Parameter name="MIN_SRC_INTERVAL" type="float" value="30" description="Source interval threshold in degree. When the angle between a localization result and a source is smaller than MIN_SRC_INTERVAL, the same ID is given to the localization result. [default: 20]"/>
      <Parameter name="MIN_ID" type="int" value="0" description="Minimum ID of source locations. MIN_ID should be greater than 0 or equal."/>
      <Parameter name="DEBUG" type="bool" value="false" description="Output debug information if true [default: false]"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_AudioStreamFromWave_1" type="AudioStreamFromWave" x="140" y="100">
      <Parameter name="LENGTH" type="int" value="512" description="The frame length of each channel (in samples) [default: 512]."/>
      <Parameter name="ADVANCE" type="int" value="160" description="The shift length beween adjacent frames (in samples)[default: 160]."/>
      <Parameter name="USE_WAIT" type="bool" value="true" description="If true, real recording is simulated [default: false]."/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_MultiFFT_1" type="MultiFFT" x="480" y="100">
      <Parameter name="LENGTH" type="int" value="512" description="FFT length in sample. [default: 512]"/>
      <Parameter name="WINDOW" type="string" value="CONJ" description="A window function for FFT. WINDOW should be CONJ, HAMMING, RECTANGLE, or HANNING. [default: CONJ]"/>
      <Parameter name="WINDOW_LENGTH" type="int" value="512" description="Window length of the window function. [default: 512]"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_LocalizeMUSIC_1" type="LocalizeMUSIC" x="690" y="100">
      <Parameter name="MUSIC_ALGORITHM" type="string" value="SEVD" description="Sound Source Localization Algorithm. If SEVD, NOISECM will be ignored"/>
      <Parameter name="TF_CHANNEL_SELECTION" type="object" value="<Vector<int> >" description="Microphone channels for localization. If vacant, all channels will be used."/>
      <Parameter name="LENGTH" type="int" value="512" description="The length of a frame (per channel)."/>
      <Parameter name="SAMPLING_RATE" type="int" value="16000" description="Sampling Rate (Hz)."/>
      <Parameter name="TF_INPUT_TYPE" type="string" value="FILE" description="Load form TF file or Input terminal."/>
      <Parameter name="A_MATRIX" type="string" value="tamago_rectf.zip" description="Filename of a transfer function matrix."/>
      <Parameter name="WINDOW" type="int" value="50" description="The number of frames used for calculating a correlation function."/>
      <Parameter name="WINDOW_TYPE" type="string" value="FUTURE" description="Window selection to accumulate a correlation function. If PAST, the past WINDOW frames from the current frame are used for the accumulation. If MIDDLE, the current frame will be the middle of the accumulated frames. If FUTURE, the future WINDOW frames from the current frame are used for the accumulation. FUTURE is the default from version 1.0, but this makes a delay since we have to wait for the future information. PAST generates a internal buffers for the accumulation, which realizes no delay for localization."/>
      <Parameter name="PERIOD" type="int" value="50" description="The period in which the source localization is processed."/>
      <Parameter name="NUM_SOURCE" type="int" value="2" description="Number of sources, which should be less than number of channels."/>
      <Parameter name="MIN_DEG" type="int" value="-180" description="source direction (lower)."/>
      <Parameter name="MAX_DEG" type="int" value="180" description="source direction (higher)."/>
      <Parameter name="LOWER_BOUND_FREQUENCY" type="int" value="500" description="Lower bound of frequency (Hz) used for correlation function calculation."/>
      <Parameter name="UPPER_BOUND_FREQUENCY" type="int" value="2800" description="Upper bound of frequency (Hz) used for correlation function calculation."/>
      <Parameter name="SPECTRUM_WEIGHT_TYPE" type="string" value="Uniform" description="MUSIC spectrum weight for each frequency bin."/>
      <Parameter name="A_CHAR_SCALING" type="float" value="1" description="Scaling factor of the A-Weight with respect to frequency"/>
      <Parameter name="MANUAL_WEIGHT_SPLINE" type="object" value="<Matrix<float> <rows 2> <cols 5> <data 0.0 2000.0 4000.0 6000.0 8000.0 1.0 1.0 1.0 1.0 1.0> >" description="MUSIC spectrum weight for each frequency bin. This is a 2 by M matrix. The first row represents the frequency, and the second row represents the weight gain. "M" represents the number of key points for the spectrum weight. The frequency range between M key points will be interpolated by spline manner. The format is "&lt;Matrix&lt;float&gt; &lt;rows 2&gt; &lt;cols 2&gt; &lt;data 1 2 3 4&gt; &gt;"."/>
      <Parameter name="MANUAL_WEIGHT_SQUARE" type="object" value="<Vector<float> 0.0 2000.0 4000.0 6000.0 8000.0>" description="MUSIC spectrum weight for each frequency bin. This is a M order vector. The element represents the frequency points for the square wave. "M" represents the number of key points for the square wave weight. The format is "&lt;Vector&lt;float&gt; 1 2 3 4&gt;"."/>
      <Parameter name="ENABLE_EIGENVALUE_WEIGHT" type="bool" value="true" description="If true, the spatial spectrum is weighted depending on the eigenvalues of a correlation matrix. We do not suggest to use this function with GEVD and GSVD, because the NOISECM changes the eigenvalue drastically. Only useful for SEVD."/>
      <Parameter name="MAXNUM_OUT_PEAKS" type="int" value="-1" description="Maximum number of output peaks. If MAXNUM_OUT_PEAKS = NUM_SOURCE, this is compatible with HARK version 1.0. If MAXNUM_OUT_PEAKS = 0, all local maxima are output. If MAXNUM_OUT_PEAKS &lt; 0, MAXNUM_OUT_PEAKS is set to NUM_SOURCE. If MAXNUM_OUT_PEAKS &gt; 0, number of output peaks is limited to MAXNUM_OUT_PEAKS."/>
      <Parameter name="DEBUG" type="bool" value="false" description="Debug option. If the parameter is true, this node outputs sound localization results to a standard output."/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_HarkParamsDynReconf_1" type="HarkParamsDynReconf" x="100" y="270">
      <Parameter name="PORT" type="int" value="9999" description="Port number of audio input server."/>
      <Parameter name="ENABLE_DEBUG" type="bool" value="false" description="print debug message of this module in case of true."/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_DisplayLocalization_1" type="DisplayLocalization" x="790" y="270">
      <Parameter name="WINDOW_NAME" type="string" value="Source Location" description="Window name of the time-azimuth map [default: Window name]"/>
      <Parameter name="WINDOW_LENGTH" type="int" value="1000" description="Window length to show at the same time [sample]"/>
      <Parameter name="VERTICAL_RANGE" type="object" value="<Vector<int> -180 180>" description="Plot range of the vertical axis"/>
      <Parameter name="PLOT_TYPE" type="string" value="AZIMUTH" description="Coordinate setting for the plotting"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Link from="node_AudioStreamFromWave_1" output="AUDIO" to="node_MultiFFT_1" input="INPUT"/>
    <Link from="node_MultiFFT_1" output="OUTPUT" to="node_LocalizeMUSIC_1" input="INPUT"/>
    <Link from="node_LocalizeMUSIC_1" output="OUTPUT" to="node_SourceTracker_1" input="INPUT"/>
    <Link from="node_HarkParamsDynReconf_1" output="LocalizeMUSIC" to="node_LocalizeMUSIC_1" input="PARAMS"/>
    <Link from="node_HarkParamsDynReconf_1" output="SourceTracker" to="node_SourceTracker_1" input="PARAMS"/>
    <Link from="node_SourceTracker_1" output="OUTPUT" to="node_DisplayLocalization_1" input="SOURCES"/>
    <NetInput name="INPUT" node="node_AudioStreamFromWave_1" terminal="INPUT" object_type="Stream" description="An audio input stream (IStream)."/>
    <NetOutput name="OUTPUT" node="node_DisplayLocalization_1" terminal="OUTPUT" object_type="Vector&lt;ObjectRef&gt;" description="The same as input."/>
    <NetCondition name="CONDITION" node="node_AudioStreamFromWave_1" terminal="NOT_EOF"/>
  </Network>
</Document>

Practice1-2 実験

  1. 必要な場合のみファイルのアップロード(practice1-1と同じ)
    • ネットワークファイル: practice1-2 のアップロード
    • 伝達関数ファイル: tamago_rectf.zip のアップロード
    • 音声ファイル: practice1.wav のアップロード
  2. practice1.wavを使用して実行
    1. ネットワークの実行 HARK DesignerのExecuteをクリック
    2. ネットワークファイルの実行
    3. 音源定位パネルがポップアップし,音源定位結果が表示される
    4. Filesの右クリックメニューからdataの画面で「端末で開く」でターミナルを開き,“python sendHarkParam.py” を実行
    5. ネットワークファイルの実行
    6. パラメータパネルがポップアップするので,パラメータを自由に変更し,音源定位結果がどのように変化するかを見る

HARKコマンドでPractice1-2を実行(うまくいかないときの代替法)

  1. practice1-2.n をダウンロード
  2. practice1-2.nのダウンロード
  3. ダウンロードしたpractice1-2.n を "ダウンロード"から"practice1/data/"に保存
  4. practice1-2.nの保存
  5. Files の右クリックメニューからdataの画面で「端末で開く」でターミナルを2つ開く
  6. practice1-2.nの保存
  7. Terminal 1: “harkmw practice1-2.n”を実行
  8. 音源定位パネルがポップアップし,音源定位結果が表示される
  9. Terminal 2: “python sendHarkParam.py”を実行
  10. パラメータパネルが表示されるので,パラメータを自由に変更し,音源定位結果がどのように変化するかを見る

音源定位パラメータの変更とその効果

  • LocalizeMUSIC NUM_SOURCE: MUSIC法で考慮する目的音源数 = NUM_SOURCE
  • LocalizeMUSIC MIN_DEG: 音源方向の最小値 = MIN_DEG
  • LocalizeMUSIC MAX_DEG: 音源方向の最大値 = MAX_DEG
  • LLocalizeMUSIC LOWER_BOUND_FREQUENCY: M定位に用いる周波数の最小値
  • LocalizeMUSIC UPPER_BOUND_FREQUENCY: 定位に用いる周波数の最大値
  • LSourceTracker THRESH: 定位の閾値 = THRESH
  • SourceTracker PAUSE_LENGTH: 音源が未観測でも追跡が継続する区間
  • SourceTracker MIN_SRC_INTERVAL 同じ音源方向であるとみなす範囲
パラメータ動的制御による音源定位結果の変化

 

Practice1-3 リアルタイム音源定位システム開発

Practice1-3 の概要

  • 目的: Practice1-2で構築した音源定位システムをリアルタイムにマイクロフォンアレイから入ってきた信号を処理するように改造
  • システムの入出力
    • 入力1 : TAMAGOからのリアルタイムからの音声信号
    • 入力2 : GUIで動的に入力する定位のパラメータ (practice1-2 での追加部分)
    • 出力 : 音源定位結果の表示
  • 必要ファイル
    • 定位用伝達関数ファイル(事前に作成済み)
      • TAMAGO用の伝達関数ファイル : tamago_rectf.zip

Practice1-3: Practice1-2からの改造点

Practice1-2からPractice1-3への変更点
  1. LOOP0シートを選択
  2. AudioStreamFromWaveを削除
  3. AudioStreamFromMic を追加
  4. HARK:AudioIO > AudioStreamFromMic
  5. AudioStreamFromMicの出力Audio ⇒ MultiFFTのINPUTに接続
  6. AudioStreamFromMicのNOT_EOFの端子を右クリックし、Set as Condition を選択

AudioStreamFromMic のパラメータの設定

AudioStreamFromMicのパラメータの設定
  1. AudioStreamFromMic ノードを右クリックして,Propertyを開く
  2. DEVICETYPE がALSA となっていることを確認
  3. DEVICE 欄に plughw: + デバイス名 を入力

Mainシートの変更

  1. Mainシートを選択
  2. ConstantとInputStreamを削除

Practice1-3 完成したリアルタイム音源定位ステムのネットワーク

  • ネットワークファイルを practice1-3.nとして保存
    • HARK Designer のSaveをクリックして保存
  • practice1-3.n の中身
#!/usr/bin/env batchflow
<?xml version="1.0"?>
<Document>
  <Network type="subnet" name="MAIN">
    <Node name="node_LOOP0_1" type="LOOP0" x="520" y="100">
    </Node>
    <NetOutput name="OUTPUT" node="node_LOOP0_1" terminal="OUTPUT" object_type="Vector&lt;ObjectRef&gt;" description="The same as input."/>
  </Network>
  <Network type="iterator" name="LOOP0">
    <Node name="node_SourceTracker_1" type="SourceTracker" x="580" y="270">
      <Parameter name="THRESH" type="float" value="34" description="Power threshold for localization results. A localization result with higher power than THRESH is tracked, otherwise ignored."/>
      <Parameter name="PAUSE_LENGTH" type="float" value="1500" description="Life duration of source in ms. When any localization result for a source is found for more than PAUSE_LENGTH / 10 iterations, the source is terminated. [default: 800]"/>
      <Parameter name="MIN_SRC_INTERVAL" type="float" value="30" description="Source interval threshold in degree. When the angle between a localization result and a source is smaller than MIN_SRC_INTERVAL, the same ID is given to the localization result. [default: 20]"/>
      <Parameter name="MIN_ID" type="int" value="0" description="Minimum ID of source locations. MIN_ID should be greater than 0 or equal."/>
      <Parameter name="DEBUG" type="bool" value="false" description="Output debug information if true [default: false]"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_MultiFFT_1" type="MultiFFT" x="480" y="100">
      <Parameter name="LENGTH" type="int" value="512" description="FFT length in sample. [default: 512]"/>
      <Parameter name="WINDOW" type="string" value="CONJ" description="A window function for FFT. WINDOW should be CONJ, HAMMING, RECTANGLE, or HANNING. [default: CONJ]"/>
      <Parameter name="WINDOW_LENGTH" type="int" value="512" description="Window length of the window function. [default: 512]"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_LocalizeMUSIC_1" type="LocalizeMUSIC" x="690" y="100">
      <Parameter name="MUSIC_ALGORITHM" type="string" value="SEVD" description="Sound Source Localization Algorithm. If SEVD, NOISECM will be ignored"/>
      <Parameter name="TF_CHANNEL_SELECTION" type="object" value="<Vector<int> >" description="Microphone channels for localization. If vacant, all channels will be used."/>
      <Parameter name="LENGTH" type="int" value="512" description="The length of a frame (per channel)."/>
      <Parameter name="SAMPLING_RATE" type="int" value="16000" description="Sampling Rate (Hz)."/>
      <Parameter name="TF_INPUT_TYPE" type="string" value="FILE" description="Load form TF file or Input terminal."/>
      <Parameter name="A_MATRIX" type="string" value="tamago_rectf.zip" description="Filename of a transfer function matrix."/>
      <Parameter name="WINDOW" type="int" value="50" description="The number of frames used for calculating a correlation function."/>
      <Parameter name="WINDOW_TYPE" type="string" value="FUTURE" description="Window selection to accumulate a correlation function. If PAST, the past WINDOW frames from the current frame are used for the accumulation. If MIDDLE, the current frame will be the middle of the accumulated frames. If FUTURE, the future WINDOW frames from the current frame are used for the accumulation. FUTURE is the default from version 1.0, but this makes a delay since we have to wait for the future information. PAST generates a internal buffers for the accumulation, which realizes no delay for localization."/>
      <Parameter name="PERIOD" type="int" value="50" description="The period in which the source localization is processed."/>
      <Parameter name="NUM_SOURCE" type="int" value="2" description="Number of sources, which should be less than number of channels."/>
      <Parameter name="MIN_DEG" type="int" value="-180" description="source direction (lower)."/>
      <Parameter name="MAX_DEG" type="int" value="180" description="source direction (higher)."/>
      <Parameter name="LOWER_BOUND_FREQUENCY" type="int" value="500" description="Lower bound of frequency (Hz) used for correlation function calculation."/>
      <Parameter name="UPPER_BOUND_FREQUENCY" type="int" value="2800" description="Upper bound of frequency (Hz) used for correlation function calculation."/>
      <Parameter name="SPECTRUM_WEIGHT_TYPE" type="string" value="Uniform" description="MUSIC spectrum weight for each frequency bin."/>
      <Parameter name="A_CHAR_SCALING" type="float" value="1" description="Scaling factor of the A-Weight with respect to frequency"/>
      <Parameter name="MANUAL_WEIGHT_SPLINE" type="object" value="<Matrix<float> <rows 2> <cols 5> <data 0.0 2000.0 4000.0 6000.0 8000.0 1.0 1.0 1.0 1.0 1.0> >" description="MUSIC spectrum weight for each frequency bin. This is a 2 by M matrix. The first row represents the frequency, and the second row represents the weight gain. "M" represents the number of key points for the spectrum weight. The frequency range between M key points will be interpolated by spline manner. The format is "&lt;Matrix&lt;float&gt; &lt;rows 2&gt; &lt;cols 2&gt; &lt;data 1 2 3 4&gt; &gt;"."/>
      <Parameter name="MANUAL_WEIGHT_SQUARE" type="object" value="<Vector<float> 0.0 2000.0 4000.0 6000.0 8000.0>" description="MUSIC spectrum weight for each frequency bin. This is a M order vector. The element represents the frequency points for the square wave. "M" represents the number of key points for the square wave weight. The format is "&lt;Vector&lt;float&gt; 1 2 3 4&gt;"."/>
      <Parameter name="ENABLE_EIGENVALUE_WEIGHT" type="bool" value="true" description="If true, the spatial spectrum is weighted depending on the eigenvalues of a correlation matrix. We do not suggest to use this function with GEVD and GSVD, because the NOISECM changes the eigenvalue drastically. Only useful for SEVD."/>
      <Parameter name="MAXNUM_OUT_PEAKS" type="int" value="-1" description="Maximum number of output peaks. If MAXNUM_OUT_PEAKS = NUM_SOURCE, this is compatible with HARK version 1.0. If MAXNUM_OUT_PEAKS = 0, all local maxima are output. If MAXNUM_OUT_PEAKS &lt; 0, MAXNUM_OUT_PEAKS is set to NUM_SOURCE. If MAXNUM_OUT_PEAKS &gt; 0, number of output peaks is limited to MAXNUM_OUT_PEAKS."/>
      <Parameter name="DEBUG" type="bool" value="false" description="Debug option. If the parameter is true, this node outputs sound localization results to a standard output."/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_HarkParamsDynReconf_1" type="HarkParamsDynReconf" x="100" y="270">
      <Parameter name="PORT" type="int" value="9999" description="Port number of audio input server."/>
      <Parameter name="ENABLE_DEBUG" type="bool" value="false" description="print debug message of this module in case of true."/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_DisplayLocalization_1" type="DisplayLocalization" x="790" y="270">
      <Parameter name="WINDOW_NAME" type="string" value="Source Location" description="Window name of the time-azimuth map [default: Window name]"/>
      <Parameter name="WINDOW_LENGTH" type="int" value="1000" description="Window length to show at the same time [sample]"/>
      <Parameter name="VERTICAL_RANGE" type="object" value="<Vector<int> -180 180>" description="Plot range of the vertical axis"/>
      <Parameter name="PLOT_TYPE" type="string" value="AZIMUTH" description="Coordinate setting for the plotting"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Node name="node_AudioStreamFromMic_1" type="AudioStreamFromMic" x="110" y="100">
      <Parameter name="LENGTH" type="int" value="512" description="The frame length of each channel (in samples) [default: 512]."/>
      <Parameter name="ADVANCE" type="int" value="160" description="The shift length beween adjacent frames (in samples)[default: 160]."/>
      <Parameter name="CHANNEL_COUNT" type="int" value="8" description="The number of channels."/>
      <Parameter name="SAMPLING_RATE" type="int" value="16000" description="Sampling rate (Hz) [default: 16000]."/>
      <Parameter name="DEVICETYPE" type="string" value="ALSA" description="Device type [default: WS]."/>
      <Parameter name="GAIN" type="string" value="0dB" description="capture gain (dB)  [default: 0dB]."/>
      <Parameter name="DEVICE" type="string" value="plughw:TAMAGO03" description="Device name or IP address [default: 127.0.0.1]"/>
      <Parameter name="HARKMW.PROCESS" type="string" value="local" description="Specify a name that indicates the machine to be executed. [default: local]"/>
      <Parameter name="HARKMW.TOPIC" type="string" value="local" description="Specifies the prefix of the topic name used for data transmission and reception by MQTT. [default: local] In actual transmission, '/<terminal name>' is added to the value specified here. e.g.) 'local/VALUE'"/>
    </Node>
    <Link from="node_MultiFFT_1" output="OUTPUT" to="node_LocalizeMUSIC_1" input="INPUT"/>
    <Link from="node_LocalizeMUSIC_1" output="OUTPUT" to="node_SourceTracker_1" input="INPUT"/>
    <Link from="node_HarkParamsDynReconf_1" output="LocalizeMUSIC" to="node_LocalizeMUSIC_1" input="PARAMS"/>
    <Link from="node_HarkParamsDynReconf_1" output="SourceTracker" to="node_SourceTracker_1" input="PARAMS"/>
    <Link from="node_SourceTracker_1" output="OUTPUT" to="node_DisplayLocalization_1" input="SOURCES"/>
    <Link from="node_AudioStreamFromMic_1" output="AUDIO" to="node_MultiFFT_1" input="INPUT"/>
    <NetOutput name="OUTPUT" node="node_DisplayLocalization_1" terminal="OUTPUT" object_type="Vector&lt;ObjectRef&gt;" description="The same as input."/>
    <NetCondition name="CONDITION" node="node_AudioStreamFromMic_1" terminal="NOT_EOF"/>
  </Network>
</Document>

Practice1-3 リアルタイム音源定位ステムの実行

  • ネットワークファイルの保存
    • HARK Designer のSaveをクリックして保存
  • Practice1-3 の実行
    1. HARK Designer のExecuteをクリックして実行
    2. Filesの右クリックメニューから data の画面で「端末で開く」でターミナルを開き,"python sendHARKParam.py" を実行
    3. > python sendHARMParam.py
      Practice1-3 の実行
    4. パラメータパネルがポップアップするので,パラメータを変更しながら,リアルタイム音源定位を実行
    5. 変更できるパラメータとその意味は,practice1-2と同じ
    6. 実行の停止は Stop をクリック

 

Practice1のまとめ

  • 実習の目的 音源定位システムの構築を通して HARKDesigner による開発を体験
  • できるようになったこと
    • 音源定位システムの構築
    • パラメータ調整のシステム開発
    • リアルタイム音源定位システム開発
  • 次に学ぶこと

 

付録 Practice1-1を3次元音源定位にパラメータを調整

  • 変更部分
  • 3D音源定位への拡張
    • DisplayLocalization ノード(二つ目)はすでに追加済み
    • DisplayLocalization のパラメータもすでに設定済み
    • LocalizeMUSIC ノードのパラメータを修正
      • A_MATRIX=tamago_rectf.zip Microcone (7チャネルマイクアレイ)用伝達関数を指定
    • MAINシートのConstantノードのパラメータを修正
      • NAME=practice1-2.wav Microconeで収録された7チャネル音声ファイル
  • 実行とその結果
    • Executeをクリックして実行
    3D音源定位への実行結果

次は Practice2 に挑戦