トップ   新規 一覧 単語検索   ヘルプ   最終更新のRSS

MATLAB Note/Data Acquisition Toolbox のバックアップ差分(No.1)


  • 追加された行はこの色です。
  • 削除された行はこの色です。
#contents

-参考
--[[Data Acquisition Toolbox のデモ:http://www.cybernet.co.jp/matlab/products/product_listing/daq/demos.shtml]]

**音声をマイクで録音しながら、リアルタイムに解析する [#w93c97f0]
-参考
--[[アナログ入力の詳細:http://dl.cybernet.co.jp/matlab/support/manual/r14/toolbox/daq/?/matlab/support/manual/r14/toolbox/daq/c5_dmai7.shtml#560573]]
--[[デバイスオブジェクトの開始:http://dl.cybernet.co.jp/matlab/support/manual/r14/toolbox/daq/?/matlab/support/manual/r14/toolbox/daq/c3_con15.shtml]]  [[デバイスオブジェクトの停止:http://dl.cybernet.co.jp/matlab/support/manual/r14/toolbox/daq/?/matlab/support/manual/r14/toolbox/daq/c3_con17.shtml]]

-パラメータを設定
#geshi(matlab){{
 fs = 10000;                             % 録音のサンプリング周波数
 rectime = 3;                            % 録音の総秒数
 plottime = 0.1;                         % 録音中、何秒に一回分析するか
}}

-音声データの読み込み
#geshi(matlab){{
 disp( strcat('録音開始...( ', num2str(rectime), ' 秒間)') );
 
 %アナログデバイスオブジェクト AIVoice を作成
 AIVoice = analoginput('winsound');
 chan = addchannel(AIVoice,1);
 %プロパティを設定
 set(AIVoice,'SampleRate', fs)
 ActualRate = get(AIVoice,'SampleRate');
 set(AIVoice,'SamplesPerTrigger', ActualRate * rectime)  % rectime 秒経過したら録音停止
 
 %録音開始 
 start(AIVoice)
}}

-分析
#geshi(matlab){{
 try 
     %録音中のデータを随時取り出して、スペクトログラムをプロットする
     alldata = zeros(3000,1);
     % 録音終了の rectime 前までプロットを続ける(数値オーバー対策)
     for count = 1 : 1 : fix(rectime / plottime)
         % fs * plottime サンプル録音できた時点で、データを data に格納
         [data, time] = getdata(AIVoice, fs * plottime);
         alldata = [alldata ; data];
         plotdata = alldata(length(alldata) - 3000 : length(alldata), : )
         figure(1); spectrogram(plotdata,30,'yaxis');  % スペクトログラム(30フレームで分析)
     end
     alldata = alldata(1000 : length(alldata), : );
     wavwrite(alldata, fs, 16, 'output_SpeechAnalysis.wav');
 catch
     stop();
 end
 
 %メモリを掃除
 waittilstop(AIVoice,2)  % AIVoiceが実行を停止していることを確認
 delete(AIVoice)         % クリーンアップ
 clear AIVoice
}}

-「10秒の録音を行ないながら、0.1秒ごとに、最新の録音データ+直前 3000 フレームをスペクトログラムに表示する」プログラムができました。
-メモリの問題でエラーが出る場合は、MATLABを再起動してください。


**反応時間測定 [#fa2ecc5a]
-&color(red){以下は編集途中のコンテンツです。};

-ハードウェア : Measurement Computing 社の PMD-1208FS を使うとします。