基於matlab的音訊波形實時採集顯示 v0.1
阿新 • • 發佈:2019-02-02
robj = audiorecorder(44100,16,1); %設定取樣頻率、取樣位數、通道數 recordblocking(robj,1); %採集初步資料(1s長度) rdata = getaudiodata(robj); %獲取音訊資料 plot(rdata); %繪製波形 axis([1,44100,-0.1,0.1]); %設定固定座標軸 drawnow %重新整理顯示 n = 100; %設定後續的取樣更新次數,n與m可聯合計算後續更新時間長度 m = 0.1; %設定更新間隔,m越小波形越連續 while n>1 recordblocking(robj,m); rlen = length(rdata); %獲取資料長度 olddata = rdata(floor(rlen*m):rlen,1); %保留的舊資料 rdata = [olddata ; getaudiodata(robj)]; %待顯示的資料 = 舊資料 + 新資料 plot(rdata); axis([1,44100,-0.1,0.1]); drawnow n = n-1; end