TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread
1 P& P# p9 z! |! D; g3 j( }Create a WAV file from the example file handel.mat,
: [* D$ u* [, t X2 l% hand read portions of the file back into MATLAB.% Create WAV file in current folder.
2 K* Y0 c* e. M6 V5 D- |load handel.mat
1 S" e3 k2 ^9 y6 L& L+ Z 5 B& V# @( m; O2 a
hfile = 'handel.wav';9 K& r7 u2 f- o: F5 m
wavwrite(y, Fs, hfile)
3 w2 D& a; Z3 R" b0 `clear y Fs
8 R# \. Z! ?" Q 0 X( G& Z$ C( ^& y4 R% H. W6 ^
% Read the data back into MATLAB, and listen to audio.3 k5 c/ P( B% t
[y, Fs, nbits, readinfo] = wavread(hfile);
7 R- [% Q2 l. k) Isound(y, Fs);; p# r1 c; ~3 T+ E6 }, m7 f
3 O9 U5 b$ L, s+ V% Pause before next read and playback operation.
7 r' N4 r* A9 o+ aduration = numel(y) / Fs;
3 c$ G6 D" y6 a+ O/ U8 spause(duration + 2)
$ @9 h8 [7 u/ m! q- V6 | 7 Y9 Y. T& z; i8 [6 ^
% Read and play only the first 2 seconds.' }% w2 v' N; y
nsamples = 2 * Fs;
2 J0 y* k4 w H5 W1 b5 h5 o5 r[y2, Fs] = wavread(hfile, nsamples);
6 s, `, ]4 r: d7 C3 C" Fsound(y2, Fs);) l% D5 b$ \- V
pause(4)# z' ?- S5 C' L" J
# l! y6 A* k: G3 y# W2 y9 o6 N% Read and play the middle third of the file.3 | v& h2 S$ [: _; i
sizeinfo = wavread(hfile, 'size');
5 |# Q8 A0 I' V0 D6 b & Y! k- r d3 s7 a: _, R" ~5 G1 C! O
tot_samples = sizeinfo(1);2 q3 ~/ p) f. l2 a; i: N+ P. l. K
startpos = tot_samples / 3;" S5 h% S* U. o3 d$ _& C
endpos = 2 * startpos; Q! q: F* P; e' Z: B3 {/ A
( U0 L, b; P0 ^1 Z9 w; {# x- e
[y3, Fs] = wavread(hfile, [startpos endpos]);. B" ^9 o+ h3 i" `+ |/ h' e
sound(y3, Fs); |
|