TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread
+ Q- q% w3 j4 }0 U I- UCreate a WAV file from the example file handel.mat,% j, z! E. a* F) }- x
and read portions of the file back into MATLAB.% Create WAV file in current folder.
l8 j3 D8 T# @4 b1 X* F# D2 |load handel.mat- P& Q9 |' _" t* M5 ?
) k J# d" h% H4 }% n' e4 Rhfile = 'handel.wav';' H, f j3 k2 Y
wavwrite(y, Fs, hfile)
7 s5 M+ ~5 ^* _, M7 gclear y Fs
# c& W+ ^ W" I% ]1 i ; u2 K V7 N7 w3 G$ {* g4 R' f
% Read the data back into MATLAB, and listen to audio.
$ h/ Y0 j2 \/ h% O8 {; I/ z0 N! q[y, Fs, nbits, readinfo] = wavread(hfile);8 w6 \: h# a$ O# C Y& Q
sound(y, Fs);( W! o5 P0 z: G& J9 I" I% _
+ c# x; y$ E' Q4 j- k
% Pause before next read and playback operation.* k. u% h {, r$ W
duration = numel(y) / Fs;
; M+ D. O! ^( }8 a% g; n A/ e* U7 upause(duration + 2)
9 s# L- ?7 g( Q7 E% W5 a
5 G7 R$ |* \% ~2 W% Read and play only the first 2 seconds.
( F0 H: ? H2 k$ }& Bnsamples = 2 * Fs;
2 N9 J ~0 G+ n6 f7 K6 N6 p2 _. P[y2, Fs] = wavread(hfile, nsamples);
( F5 x4 U [0 I7 C1 Osound(y2, Fs);
3 G; _: y" j) l9 K( epause(4)
" k* ^2 T/ d+ ]0 C* M2 `1 a / p& I8 d+ R! l) V; D$ e
% Read and play the middle third of the file.7 L0 r( x, \1 w; X9 t* q
sizeinfo = wavread(hfile, 'size');& j e# `( j( h! w5 N* p
' x% ?5 K- W+ d# @, z% l4 Q% jtot_samples = sizeinfo(1);$ F7 f1 N9 c3 {$ U T
startpos = tot_samples / 3;
8 Z$ x. Y" K1 N) x8 b6 ~/ t8 eendpos = 2 * startpos;1 i. z9 i4 j/ u
* X. Y+ y; H. L# _[y3, Fs] = wavread(hfile, [startpos endpos]);* f% Y0 e7 `* x/ U
sound(y3, Fs); |
|