function [B,F,T] = compspecgram(speechdir, speechdat, winlen, ... 
    wintype, fftlen, overlap, Fs)
%
% function for matweb, computes the spectrogram of the speechdat,
% and returns the data.  Limits the dynamic range to 30 dB
% presently to improve the display, this could be changed to be
% more interactive, or just to a different setting
%
% J. Steinheider 3/8/00


%global parameters
global siglen fixedfftlen;

%Window type
switch wintype
  case 'bartlett'
    w = bartlett(winlen);
  case 'blackman'
    w = blackman(winlen);
  case 'hamming'
    w = hamming(winlen);
  case 'hanning'
    w = hanning(winlen);
  case 'boxcar'
    w = boxcar(winlen);
end

% Load the signal

eval(sprintf('s = load(''%s/%s'');', speechdir, speechdat));

% Assign the signal to x
x = s.source;

% Calculate spectrogram of the signal
[B,F,T] = specgram(x, fftlen, Fs, w, overlap);

%limit the output to a specific dynamic range
dynr = 30;
Bmin = max(max(abs(B)))/(10^(dynr/20));
B = abs(B) + Bmin;

