TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread
7 I/ m; g$ @. ]: v% ZCreate a WAV file from the example file handel.mat,
8 n" b0 Y; D0 w+ mand read portions of the file back into MATLAB.% Create WAV file in current folder.0 {* b# o! O' w" s: H6 ^' y: E
load handel.mat" X6 j( D4 i" Z# j- p& X
; V' @. |- N1 ? _4 o
hfile = 'handel.wav';
) s# y+ E$ @% t* [* Owavwrite(y, Fs, hfile)/ v1 w4 G- s3 p1 j( u+ y# t) E
clear y Fs
: T- j3 U% g+ p# M. W
7 A: i9 V9 w7 W1 k% Read the data back into MATLAB, and listen to audio.
0 z2 S% Y6 z- D1 ^8 y5 f. R! r[y, Fs, nbits, readinfo] = wavread(hfile);5 B# Q/ b. L( j( D1 Q# C
sound(y, Fs);
/ M# n2 Y% I5 U: H7 ~, U- ~, a2 y
% Pause before next read and playback operation.
# l6 V4 @1 z$ m9 l* t; [( Aduration = numel(y) / Fs;# u' E0 Y" i8 O" b u' f
pause(duration + 2)4 d( }, @+ s' o+ M0 k
, L( A/ [: z+ M# z
% Read and play only the first 2 seconds.4 z; u/ ]8 L# M3 K/ M' Q/ b
nsamples = 2 * Fs;
5 Z- R5 e/ Z9 ?" U6 k[y2, Fs] = wavread(hfile, nsamples);3 B5 `( G6 |% M+ d
sound(y2, Fs);6 D }! w1 q7 w( S
pause(4)
8 z) H1 O# p, P% @$ M 5 z' V; B9 O4 `0 L& T" G
% Read and play the middle third of the file.
% u# \+ Y/ R! f! f8 m0 Bsizeinfo = wavread(hfile, 'size');
7 b9 a2 i7 k9 F6 _
; |0 E6 c# J- o' rtot_samples = sizeinfo(1);
# l8 w k# L6 o4 m4 R i+ Bstartpos = tot_samples / 3;+ G6 o( [- @' G4 w0 Q
endpos = 2 * startpos;9 h7 o. l& U" G5 r
* k9 i# N; g* e
[y3, Fs] = wavread(hfile, [startpos endpos]);. N# h6 i; u' E
sound(y3, Fs); |
|