Prev: Matlab "File management" interface
Next: Stand alone application (gui) crashes with unexpected java error
From: rudy blabla on 7 Jan 2010 08:11 Hi, I have a problem with writing .wav files. I have this code: function [] = recwav(t, filename) Fs=8000; n=Fs*t; sample = wavrecord(n,Fs,'int16'); wavwrite(sample, filename); wavplay(sample,Fs); plot(sample); title(filename); end but somehow when i playback the written .wav files they are very distorted. I plotted the array of the written file and it looks like the whole array is clipping (the amplitude is much lower!) what can be wrong? thank you in advance
From: Jan Simon on 7 Jan 2010 08:44 Dear Rudy! > sample = wavrecord(n,Fs,'int16'); > wavwrite(sample, filename); > but somehow when i playback the written .wav files they are very distorted. Did you try to specify FS and NBITS in WAVWRITE as specified in: help wavwrite ? Kind regards, Jan
From: Jackie Caplan-Auerbach on 7 Jan 2010 12:01
"rudy blabla" <r_schuitema(a)hotmail.com> wrote in message <hi4mh9$i45$1(a)fred.mathworks.com>... > Hi, > > I have a problem with writing .wav files. I have this code: > > function [] = recwav(t, filename) > > Fs=8000; > n=Fs*t; > sample = wavrecord(n,Fs,'int16'); > wavwrite(sample, filename); > wavplay(sample,Fs); > > plot(sample); > title(filename); > > end > > but somehow when i playback the written .wav files they are very distorted. I plotted the array of the written file and it looks like the whole array is clipping (the amplitude is much lower!) > what can be wrong? > > thank you in advance If your data are floating point MATLAB will clip anything over 1. You can either normalize your data to 1 or change the number of bits to 32: wavwrite(y, Fs, 32, filename) |