TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread: J* G! r$ z% }* b9 y9 a, T( G
Create a WAV file from the example file handel.mat,
% ?# O. h j' {8 M) Z" A5 Jand read portions of the file back into MATLAB.% Create WAV file in current folder.
6 x' O' k' v1 o: Bload handel.mat
a) P, e, `1 u$ O r) N% H4 G
, S; F) t3 M* v: bhfile = 'handel.wav';6 J1 b. m5 g- F
wavwrite(y, Fs, hfile)
8 W7 h% C0 X( E @clear y Fs" S' d3 b v9 S8 j: D x
( q# M3 A9 j) B
% Read the data back into MATLAB, and listen to audio." i' O: q6 G& K9 A3 J0 o
[y, Fs, nbits, readinfo] = wavread(hfile);. g3 i7 s/ R% p6 c4 P, ~3 N% l& f
sound(y, Fs);
6 Y# h6 D2 w/ n) R6 S6 ?
5 i/ O5 G' _+ | r$ K S% Pause before next read and playback operation.
% I; c5 n( ^7 ~duration = numel(y) / Fs;: Q3 y/ O3 |6 _# X( R. ^0 F
pause(duration + 2)$ Y1 r1 i5 C3 V0 q" x8 S
1 e2 I* s. c8 M) ^
% Read and play only the first 2 seconds." P' S1 g- T; M
nsamples = 2 * Fs;
) W. X$ h' c0 P2 g4 {9 W[y2, Fs] = wavread(hfile, nsamples);: J3 r4 H& ?( N) @$ f
sound(y2, Fs);/ D" W* G# p, T! C* a. [! x
pause(4)0 P% Y+ i: B! \( d
7 v0 j: j2 i( l1 X: F* Z% Read and play the middle third of the file.& |3 \* n9 O& R7 t) g# T
sizeinfo = wavread(hfile, 'size'); i6 a9 I j3 Y) p. d
9 m2 G4 E# [% W4 }; [tot_samples = sizeinfo(1);
. @1 F/ `9 `% I" E/ ]6 c kstartpos = tot_samples / 3;
2 `5 r K* e, L1 \7 r: zendpos = 2 * startpos;4 w' x7 P4 J0 ?# Z$ j) |8 P8 V( G
: G. x+ h. v& o9 Q7 M& f[y3, Fs] = wavread(hfile, [startpos endpos]);
: e2 O* P9 i9 F! b" O z. isound(y3, Fs); |
|