TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread& O3 a8 v8 q# T% ~
Create a WAV file from the example file handel.mat,3 D+ H ^- M& J/ Q+ L
and read portions of the file back into MATLAB.% Create WAV file in current folder.
8 g& y) o, [& Q3 ?load handel.mat* [$ y) S. U; l, e9 C
h2 Y9 [7 n( d+ N9 J# Jhfile = 'handel.wav';1 h4 `; k, R1 E8 u9 o% r0 B& N
wavwrite(y, Fs, hfile)8 a3 j4 d s5 T8 Y2 l
clear y Fs& ?" C: x7 y; T4 X; ?
+ R& Y7 b v/ A, P& y0 l
% Read the data back into MATLAB, and listen to audio.
9 n5 s! D) d8 m: a9 o( ?) @0 j1 v[y, Fs, nbits, readinfo] = wavread(hfile);
3 k" l9 X1 L, N! b( S' X ^) Jsound(y, Fs);# s# I- w' Y- X
* J q" F6 O5 o/ u# Q' |6 C% Pause before next read and playback operation.' w& R) {3 z2 C3 O0 v7 s8 m& e
duration = numel(y) / Fs;% z. l5 z8 W- T5 U# L& D
pause(duration + 2)5 ~& V# S1 j' i% y ?
, S( A3 z" A0 m' S9 }! V% Read and play only the first 2 seconds.2 E6 n( v- O! w1 a4 j
nsamples = 2 * Fs;
2 I( e; m: }, _8 ^; Y! ?[y2, Fs] = wavread(hfile, nsamples);5 ~) M. q, P. Z0 q ^" H+ i0 x
sound(y2, Fs);
2 ?' w7 U5 |" ^; _, |$ kpause(4)
) ]5 D. j- h, m% v: `$ i
- ?) w& W- s* j& X3 p+ C% ^% Read and play the middle third of the file.) L5 u0 W. U) F- T3 A2 O
sizeinfo = wavread(hfile, 'size');
3 J7 H9 M7 m0 }# p: x& n3 u
: k0 g2 N! Y/ w, }tot_samples = sizeinfo(1);0 ^$ w& }% _; j5 ]( W
startpos = tot_samples / 3;
6 F" _3 X" Z% J# a% m% bendpos = 2 * startpos;
7 K# Y+ |/ ~% D% u' O# F, [. f( c 1 q3 h6 {( {, ]
[y3, Fs] = wavread(hfile, [startpos endpos]);
- q3 r' w1 [* ^! j# Psound(y3, Fs); |
|