TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread' U2 o `7 o1 E9 ], V7 @
Create a WAV file from the example file handel.mat,
2 l4 k2 |9 h* `6 d' c9 t. mand read portions of the file back into MATLAB.% Create WAV file in current folder.
) x6 z; l3 I. ]/ Vload handel.mat6 {/ S. C& m- ?4 v2 }: U
6 n p+ J: ~4 K v: h, |" J0 U
hfile = 'handel.wav';
. T5 u: c& N0 [% \wavwrite(y, Fs, hfile)8 k' e6 g7 A- i" g% g) d4 t
clear y Fs P5 }# V' R" ?0 D
5 ^0 c: }7 E+ m j6 i* ^
% Read the data back into MATLAB, and listen to audio.
9 P% x0 A' N& R* V1 {- K[y, Fs, nbits, readinfo] = wavread(hfile);
1 Z+ j. [2 E3 V+ xsound(y, Fs);9 L4 N1 S8 H( [1 J7 Z8 x
# W$ g$ k( W! f7 ]& E0 Z% Pause before next read and playback operation.
# n( @0 n3 M2 U% S" B0 tduration = numel(y) / Fs;
% q* R4 Q0 q" }" n4 kpause(duration + 2)
* q, |$ H* x ~ F, E& Z
; W' W4 C+ z) S7 @% Read and play only the first 2 seconds.
7 d0 q# C" q5 I, w9 Ansamples = 2 * Fs;. _! q* ^& c6 i
[y2, Fs] = wavread(hfile, nsamples);" a e. Z3 w* ]% V; v# r9 N
sound(y2, Fs);
' |! d% }) C" U7 O8 u' I( t( K2 ?: i1 L- ypause(4)
2 m. P% y' W* Q
) j w3 h* u2 j6 d' N) g, i- k: s% Read and play the middle third of the file.; W( ]" Q- T! p7 T$ y0 t
sizeinfo = wavread(hfile, 'size');! Z/ f( Q1 v! y( L* C: E
5 w7 g, U8 ?" t1 m, F
tot_samples = sizeinfo(1);
0 l8 D8 H; q& t: O: @2 e( d9 u9 ustartpos = tot_samples / 3;
4 t, z. v) ~) v; E, i7 Cendpos = 2 * startpos;
. y* S4 k7 t5 u9 e
( y6 [4 r" s! T[y3, Fs] = wavread(hfile, [startpos endpos]);5 }) W$ H# z; t4 i# l e9 X
sound(y3, Fs); |
|