数学建模社区-数学中国
标题:
matlab怎么提取音频
[打印本页]
作者:
﹏便是晴天ヾ
时间:
2013-11-6 21:05
标题:
matlab怎么提取音频
matlab怎么提取音频
作者:
madio
时间:
2013-11-7 10:11
使用wavread
) a/ ^$ F L" D! j/ H
Create a WAV file from the example file handel.mat,
/ q+ u4 S1 ?7 t9 X$ K0 p J7 u
and read portions of the file back into MATLAB.% Create WAV file in current folder.
N) l) }! d6 Y3 a
load handel.mat
+ _" e( _' @2 x9 L* \! s T! O
% z" m% @2 K* F6 _; D! Q# I
hfile = 'handel.wav';
/ X3 P, D7 v4 e" {" i: {! S# d
wavwrite(y, Fs, hfile)
/ W. @9 v6 h% z- G3 W
clear y Fs
" F$ ]$ M) X, O8 L2 C/ E
( R& e! r+ o3 S6 R2 \) S
% Read the data back into MATLAB, and listen to audio.
, U- \* Q# j! s" E& \! p# i
[y, Fs, nbits, readinfo] = wavread(hfile);
; a& p3 V) h/ f. {: f8 g
sound(y, Fs);
6 r9 H- q6 z+ P) @2 z& R
7 l: z) D" I% q- S( W; X
% Pause before next read and playback operation.
7 v0 L: g, z2 ^# n; @' }
duration = numel(y) / Fs;
$ S# C9 `; M; U$ h6 P
pause(duration + 2)
& b2 U& q+ ?7 M9 Y5 z! Z( f7 ~
3 Z! e5 l( Y8 r& Z/ J8 ?/ o
% Read and play only the first 2 seconds.
& e$ }: h* H& C4 Z9 M
nsamples = 2 * Fs;
8 F# z- e" j6 V2 ^5 x
[y2, Fs] = wavread(hfile, nsamples);
3 ^, j7 T$ G' R9 A
sound(y2, Fs);
2 G% }1 t. ]- p' {
pause(4)
8 c! N' l/ c3 B( c1 v9 M* X
" z2 U+ n2 W8 _1 W# X
% Read and play the middle third of the file.
3 v6 C* y U0 {, L4 H
sizeinfo = wavread(hfile, 'size');
! M* y8 g2 F0 a2 k e# V
, ~. u7 `6 z/ g% w
tot_samples = sizeinfo(1);
, c7 S4 p2 P' G6 A5 l5 p
startpos = tot_samples / 3;
% R$ @7 s/ s$ G8 P. U0 w' v! K2 U6 k
endpos = 2 * startpos;
. K [& [7 f9 n; X" _
' t8 a* H# `' C, e% E' Z/ F; M
[y3, Fs] = wavread(hfile, [startpos endpos]);
) e7 J7 V* f+ n/ a
sound(y3, Fs);
作者:
陌上,烟雨遥
时间:
2013-12-12 09:54
欢迎光临 数学建模社区-数学中国 (http://www.madio.net/)
Powered by Discuz! X2.5