function d = readdatafile(filename)
% d = readdatafile(filename)
%    Reads a file, can be either HTK or Matlab chrfeat file, choose
%    by extension.
%    Returns features in spectrogram mode (one column per record,
%    one row per dimensions)
% 2007-04-11 dpwe@ee.columbia.edu

if length(regexp(filename, '\.htk$')) > 0
  % regular HTK parameter file (for MFCCs)
  d = readhtk(filename)';
else
  % it's a MAT format file, and we want the variable F it contains...
  % (because that's what our beat-sync-chroma calculation routine writes)
  d = load(filename);
  if isstruct(d)
    % F is the part we want
    d = d.F;
    % chroma-specific normalization
    pwr = 0.5;
    d = chromnorm(chrompwr(d,pwr));
    % crude fixed normalization !!!
    d = d - 0.25;
    d = 6*d;
  end
end
