TA的每日心情 | 奋斗 2024-7-1 22:21 |
|---|
签到天数: 2014 天 [LV.Master]伴坛终老
- 自我介绍
- 数学中国站长
群组: 数学建模培训课堂1 群组: 数学中国美赛辅助报名 群组: Matlab讨论组 群组: 2013认证赛A题讨论群组 群组: 2013认证赛C题讨论群组 |
2#
发表于 2013-11-7 10:11
|只看该作者
|
|邮箱已经成功绑定
使用wavread
, P+ g- m. [( C1 M; hCreate a WAV file from the example file handel.mat,6 F. i) [+ j: `: j; } t% b4 O4 U7 i
and read portions of the file back into MATLAB.% Create WAV file in current folder.
* O! I/ x! U7 s+ k6 H Aload handel.mat) r v/ [2 n& H! K, v
) R; }: S0 |6 R0 e' Z- d7 |6 shfile = 'handel.wav';
7 B! }1 C! [, M' kwavwrite(y, Fs, hfile). F$ Q2 p. C7 n0 j
clear y Fs
3 U9 q+ S/ l8 s, V# R, X " M9 {; P' z3 J: Q& T( h+ X
% Read the data back into MATLAB, and listen to audio.
9 ?# v6 L l$ t: B- i" L[y, Fs, nbits, readinfo] = wavread(hfile);# L+ E7 m) k& @' Z7 V% |7 |
sound(y, Fs);
- g+ [7 u$ e4 {/ k( K5 M4 x7 j* G7 U
% Pause before next read and playback operation.3 }* B+ ^( j& r4 H6 W3 [
duration = numel(y) / Fs;( K' @" e; }& V
pause(duration + 2): n9 s6 O8 N) V
L) C$ O3 Z5 D. [
% Read and play only the first 2 seconds.1 v. B2 m }( A" G
nsamples = 2 * Fs;9 W0 M/ h" O `% I
[y2, Fs] = wavread(hfile, nsamples);
0 c: N( `; y' Q4 G* `% xsound(y2, Fs);
6 k' T1 ^; }# X6 u; Vpause(4)) v2 H( Y# @1 ?8 Y+ l
4 g& w* l3 n8 z8 Q( M8 F
% Read and play the middle third of the file.
) j' _- ]9 g* dsizeinfo = wavread(hfile, 'size');( w( L1 G) S, I' R1 i P2 H
- A: M( c- A1 X1 K. |9 rtot_samples = sizeinfo(1);
5 a$ n n' X5 i, i# X0 _startpos = tot_samples / 3;
% A$ @. R7 m/ G" Aendpos = 2 * startpos;# e4 W- r* B6 D# L
. ]3 L4 [# q% }, [[y3, Fs] = wavread(hfile, [startpos endpos]);/ g" D- s7 n0 J( H. V
sound(y3, Fs); |
|