TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread! r6 P" n ^& G- {. Q
Create a WAV file from the example file handel.mat,
* J) Y& b6 b9 f% b/ ]7 L% Eand read portions of the file back into MATLAB.% Create WAV file in current folder., r0 e6 p/ m0 m0 ~8 W
load handel.mat7 l6 |, w9 T7 n# r% X* K
+ u1 J" y1 D8 ~& m! ~+ ^hfile = 'handel.wav';
& v) c4 t6 H) c" D' t3 q) j% Owavwrite(y, Fs, hfile)* f9 e, C: Q. A: J/ J* {+ k/ x3 |
clear y Fs
& N" h; A) O8 E) z+ V9 x
8 Q0 n7 @# T; r! M. ~% Read the data back into MATLAB, and listen to audio.
3 y+ x9 p6 z' G% W4 [, t5 e[y, Fs, nbits, readinfo] = wavread(hfile);" Q$ R) J. q7 v- X
sound(y, Fs);
$ e4 ?7 q [' Y- b4 b8 X
9 V# a6 Y) _6 g1 c8 H6 J% Pause before next read and playback operation.
% V* F% `1 d% f4 M& {9 ^duration = numel(y) / Fs;9 }6 g! p2 h! L8 l
pause(duration + 2)
/ I% V/ Y2 ^1 M" F& ?# X1 `: c- Z: I ' b0 k1 h9 }0 @6 Y
% Read and play only the first 2 seconds.
2 W' V" J; W$ u) ~2 s8 I( Y3 Dnsamples = 2 * Fs;: y8 U0 r9 P) I1 s$ H% C4 H* u8 B
[y2, Fs] = wavread(hfile, nsamples);. Z$ g- y" D. ~; y
sound(y2, Fs);
' o8 ?. i6 P* y0 W2 x: ?& N4 cpause(4)
1 A7 r+ n* S: u# | ) l/ N7 T" _" a& J7 ]# O* V' v
% Read and play the middle third of the file.0 ?$ D- j$ }4 |) ^
sizeinfo = wavread(hfile, 'size');& { H9 l+ o: q, j& T+ }* V
$ D) [- }* Z( \% ? V6 ~( Y! J' `tot_samples = sizeinfo(1);% n# W$ d; ^, z9 c/ |# K8 c7 I
startpos = tot_samples / 3;" J6 m3 e; n& j& h9 d1 x
endpos = 2 * startpos;
# r7 ^( G b# P* {
4 }9 ]+ s) n r# Q[y3, Fs] = wavread(hfile, [startpos endpos]);
2 q3 k- Q3 H+ _( h8 q$ O5 Jsound(y3, Fs); |
|