TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread* g2 N' e/ H I8 t: b/ l
Create a WAV file from the example file handel.mat,
# B) j/ a' @. h$ Zand read portions of the file back into MATLAB.% Create WAV file in current folder.% E0 j$ q1 M1 b
load handel.mat
* M! R) F3 m- {9 {. B/ b 0 B" F' _% \/ ]8 P m0 `" b' n3 A
hfile = 'handel.wav';
1 b0 @2 A5 b+ m0 H9 V/ H- }( |wavwrite(y, Fs, hfile)3 _. ~0 m( K Y- g% R1 s$ B
clear y Fs X' h7 G$ _8 E5 X
% e% `& w1 M$ V/ [6 d. w3 K% s
% Read the data back into MATLAB, and listen to audio.5 m- s. H( }* |; ?
[y, Fs, nbits, readinfo] = wavread(hfile);
5 f! ^5 q4 q e- wsound(y, Fs);( a% R' _8 C- @& z% y# k9 x
$ {/ ^4 L% w% v1 U% Pause before next read and playback operation.
) d( y" u6 ^/ ]duration = numel(y) / Fs;
0 t3 t3 K; L+ {/ q: tpause(duration + 2)1 K# D2 c1 t' k1 o: L1 e
: ?( N" O- Z8 F! \: m/ e
% Read and play only the first 2 seconds.
8 E7 q6 J4 |' Z; b' insamples = 2 * Fs;
0 }6 ^. T( `& t7 |. u+ r[y2, Fs] = wavread(hfile, nsamples);
6 t# o/ U# Q2 isound(y2, Fs); r) Y2 t, d) g) B4 t
pause(4)
9 a) z( R+ E* G; | ; |2 Y- H @/ v0 r( Q
% Read and play the middle third of the file.
1 I0 R, K$ ]* O& [! G& d$ v7 Csizeinfo = wavread(hfile, 'size');- j0 J# g* h5 \
6 {. T- Q4 a5 D# L; v' t+ b) }
tot_samples = sizeinfo(1);* m) D% L, k: e9 g
startpos = tot_samples / 3;; ^1 z6 c+ p0 K. D
endpos = 2 * startpos;
4 a9 P. a% E1 x% @2 } 5 L5 X8 q9 C# p: j9 o/ Q- s
[y3, Fs] = wavread(hfile, [startpos endpos]);3 P' p) a) J6 a2 N- N. ?/ P5 r. @
sound(y3, Fs); |
|