TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread
. f8 R- C* I4 }4 L8 ?Create a WAV file from the example file handel.mat,2 a! `' M$ [3 ^$ v5 F% ?2 p
and read portions of the file back into MATLAB.% Create WAV file in current folder.
- x* S8 Y0 q4 [3 x$ sload handel.mat# W+ p* a, `6 ~0 q3 {* a
7 j2 Y4 @7 y. F i" ~4 G# s
hfile = 'handel.wav';% B: o( D! p: M" r* w8 z% N# `
wavwrite(y, Fs, hfile)
; a8 p" ^0 Z, c) u2 _clear y Fs
9 ?3 d' e5 I" B
8 b( j8 M. m) B% Read the data back into MATLAB, and listen to audio.+ n+ N+ z/ k& w5 S+ W
[y, Fs, nbits, readinfo] = wavread(hfile);
5 Z4 {0 G/ U5 x2 ]! E' i; @ n9 z% s9 ssound(y, Fs);+ {, P; W& A! Q) [( {
9 j# s* Y- v) f6 h% Pause before next read and playback operation.! r$ X j) f, U6 L' |9 ?$ s8 v! b
duration = numel(y) / Fs;2 ~# T5 S7 s) q5 s
pause(duration + 2)$ h. }% L9 g6 T" ^5 }- v' e8 t6 p- w
# |' N' o: X$ c1 [; a
% Read and play only the first 2 seconds.
0 x* m4 l9 d" a4 w& j0 ?8 x2 r# Fnsamples = 2 * Fs;
# U4 V+ Y$ s# b- Q: H5 b" S[y2, Fs] = wavread(hfile, nsamples);
* g2 S v# f! h5 b4 w; q6 Esound(y2, Fs);( V4 w, y) T1 d: j, x/ M; Q
pause(4)
2 H# i& o$ m% S9 A. J+ u
# }- s& G% `6 w9 O1 y1 B9 B) }% Read and play the middle third of the file., a6 y; r) q& n$ q# F0 `, ?
sizeinfo = wavread(hfile, 'size');
: I' P0 Y" {8 C1 V9 [2 _% n. O
8 v y8 K$ c3 x3 I3 htot_samples = sizeinfo(1);* p b3 L( H5 U$ ?
startpos = tot_samples / 3;
3 [* H) ? d! mendpos = 2 * startpos;
& Z4 N! B7 ?$ U : K9 N3 \8 U: g; D
[y3, Fs] = wavread(hfile, [startpos endpos]);
3 O5 |# j' a" ^sound(y3, Fs); |
|