function soundout = wavresample( fname, q, fnameo)
%+++++++++++++++++++++++++++++++++++++
%++ Reading digital sound

%fname = 'mars-kms-sm.wav';
%fnameo = 'mars-kms-sm-8k.wav';

%-- subsampling factor
%q = 5; 

[sound, fs, bits]=wavread( fname ); 
slength = length(sound);
disp(['Processing ' fname ]);
disp(['            ' num2str( bits) ' bits']);
disp(['            ' num2str( fs ) ' Hz']);
disp(['            ' num2str( slength / fs) ' s']);

soundout = sound(1:q:slength);
newfs = fs/q;

disp(['Resampled ']);
disp(['            ' num2str( bits) ' bits']);
disp(['            ' num2str( newfs ) ' Hz']);
disp(['            ' num2str( length( soundout) / newfs) ' s']);

if nargin > 2
  disp(['Writing file ' fnameo]);
  wavwrite( soundout, newfs, bits, fnameo)
end


