I NEED HELP WITH THIS CODE?

조회 수: 2 (최근 30일)
Mubasher
Mubasher 2012년 5월 14일
Index exceeds matrix dimensions.
Error in ==> wavplay at 56 y = varargin{1};
Error in ==> Untitled at 22 wavplay('Bird') >> clear; clc;
M=2;
freq_sep=100;
nsamp=6;
sampling_frequency=1000;
id=fopen('bird.wav');
data=fread(id,inf,'uint8');
data_bin=de2bi(data);
fsk_mod=fskmod(data_bin,M,freq_sep,nsamp,sampling_frequency);
noise=awgn(fsk_mod,10);
fsk_demod=fskdemod(noise,M,freq_sep,nsamp,sampling_frequency);
[num,rate]=biterr(data_bin,fsk_demod)
z=bi2de(fsk_demod);
a=uint8(z);
wavwrite(a,'Bird');
wavplay('Bird')
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 5월 14일
Why are you reading the bird.wav file as binary? .wav files do not encode the sound as plain binary samples: they have a lot of compression, and should be read using wavread()
Mubasher
Mubasher 2012년 5월 15일
i get same error when i use wavread

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2012년 5월 15일
wavplay(y,Fs) plays the audio signal stored in the vector y on a PC-based audio output device. Fs is the integer sample rate in Hz (samples per second). The default value for Fs is 11025 Hz. wavplay supports only 1- or 2-channel (mono or stereo) audio signals. To play in stereo, y must be a two-column matrix.
It does not appear to me that 'Bird' is a audio signal.
To be more explicit: wavplay() does not accept filenames. There is no MATLAB supplied routine for playing sound directly out of .wav files.
  댓글 수: 2
Mubasher
Mubasher 2012년 5월 16일
Does wavplay and sound performs same function? It appears that they do.
Walter Roberson
Walter Roberson 2012년 5월 16일
No. sound() always waits for the noise to finish. wavplay() has an option to continue one the noise has started. Also, wavplay() can only be used for 32 bit MS Windows systems.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by