matlab - plotting volume-time graph of .wav file -


i'm trying volume-time graph of .wav file. first, recorded sound (patient exhalations) via android .wav file, when read .wav file in matlab has negative values. meaning of negative values? second, matlab experts please check if code below same written in comments? question. y = fft(windowarray); p = abs(y).^2; took power of values returned fft...is correct , goal of step??

[data, fs] =  wavread('newf2'); % read exhalation audio wav  file (1 channel, mono) % frequency 44100 hz % windows of 0.1 s , overlap of 0.05 seconds window_size = fs*0.1; %4410 = fs*0.1 array_size = length(data); % array size of data numofpeaks = (array_size/(window_size/2)) - 1; step = floor(window_size/2); %step size used in loop transformed = data; start =1; k = 1; t = 1; g = 1; o = 1; % performing fft on each window , finding peak of windows  while(((start+window_size)-1)<=array_size)      j=1;     =start;     while(j<=window_size)         windowarray(j) = transformed(i);         j = j+1;         = +1;     end     y = fft(windowarray);     p = abs(y).^2; %power       [a, b] = max(abs(y)); % find max , indices b       [m, i] = max(p); %the maximum of power m , indices       maximum(g) = m;       index(t) = i;       power(o) = a;       indexp(g) = b;       start = start + step;       k = k+1;       t = t+1;       g = g+1;       o=o+1;     end % low pass filter  % filtering noise: ignor frequencies less 5% of maximum frequency u=1:length(maximum)     m = max(maximum); %highest value in array     accept = 0.05* m;     if(maximum(u) > accept)         maximum = maximum(u:length(maximum));         break;     end end % preparing time of graph,  % location of peak flow rates estimated totaltime = (numofpeaks * 0.1); time1 = [0:0.1:totaltime]; if(length(maximum) > ceil(numofpeaks)); maximum = maximum(1:ceil(numofpeaks));  end time = time1(1:length(maximum)); % plotting frequency-time graph figure(1); plot(time, maximum); ylabel('frequency'); xlabel('time (in seconds)'); % plotting volume-time graph figure(2); plot(time, cumsum(maximum)); % integration on time volume  ylabel('volume'); xlabel('time (in seconds)'); 

(i answer part of question understood)

per default matlab normalizes audio wave - 1...1 range. use native option if want integer data.


Comments