function out = da_ad_siml_revised(sig);

% DA and AD simulation for IHC Criteria 2014
%    revised not to use Picola


wfile = [tmpnam, 'w.wav'];
rfile = [tmpnam, 'r.wav'];
sf = 44100;

[c, r] = size(sig);
maxamp = max(abs(sig));
if maxamp > 1
  error('Amplitude range should be from -1 to 1');
end

wgn = randn(c, r);
nlevs = 10*log10(mean(wgn.^2));

for ch=1:2
  sig(:,ch) = sig(:,ch) + wgn(:,ch)*10^((-nlevs(ch)-80-3)/20);
end
sig = sig * 10^(-2/20);

for k=1:ch
  wavwrite(sig(:,k), sf, rfile);
  system(sprintf('ResampAudio -s %d %s %s >& /dev/null', round(sf/0.999), rfile, wfile));
  tmp = wavread(wfile);
  out(1:length(tmp),k) = tmp;
end
system(['rm ', wfile, ' ', rfile]);





