TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread
! m% Y) t- v/ M% I1 z6 Z( sCreate a WAV file from the example file handel.mat,
3 |% b0 `; B8 `! z, [+ kand read portions of the file back into MATLAB.% Create WAV file in current folder.
& B9 R- D/ ~ g- z% G; u$ B* zload handel.mat
4 ~' @* O( e- V0 k( q1 B: [ " _+ F8 L U# H1 T7 j
hfile = 'handel.wav';
' P. R0 v: \" p0 J/ b) M! y% kwavwrite(y, Fs, hfile)4 i# z% {1 b+ P+ o7 p
clear y Fs
$ z. p$ h6 G8 u* |* M) K' l
( v7 a- G4 |# G$ s% Read the data back into MATLAB, and listen to audio.
- `# t* p7 f, H7 c6 `0 d# U[y, Fs, nbits, readinfo] = wavread(hfile);6 `) M4 w+ n7 K3 P9 ]
sound(y, Fs);
) z1 `$ N$ F6 Z* W+ h" L& {) @: U! q6 G4 y% q l: b8 @
% Pause before next read and playback operation.) C2 ^0 p, v/ R* ?& k( [' O
duration = numel(y) / Fs;
3 p) A" d) N0 S- `pause(duration + 2)
- h& A: C4 p9 H2 B3 U: u* g
: K. X& w6 j* m; @% Read and play only the first 2 seconds.9 p- |6 K/ Q$ ?! P$ E6 c) K3 m
nsamples = 2 * Fs;
; z/ b8 W! a# E. ?$ y[y2, Fs] = wavread(hfile, nsamples);9 h* P' p( p7 H5 U$ s
sound(y2, Fs);
9 t3 C3 \: {: Rpause(4)8 f- ^8 b9 Y+ k/ y' a
7 x) E6 @7 a9 y7 C- [2 C/ T6 n% l% Read and play the middle third of the file.% g9 C/ s% v: q. s: J- A; v) ~- o
sizeinfo = wavread(hfile, 'size');$ D4 o" K s4 L: J* F) o& ^
9 N& L2 a: ?$ t
tot_samples = sizeinfo(1);. d4 e. u4 a+ X) K0 o8 S
startpos = tot_samples / 3;
, y [) L* B3 ]. b! lendpos = 2 * startpos;
% B* v; ?# r% g ! ~3 s; |4 Y! P' j- g( ]
[y3, Fs] = wavread(hfile, [startpos endpos]);( i K j/ _5 ?1 D. D0 @
sound(y3, Fs); |
|