function gain(filename, gainIndB, fs, bitdepth)
% GAIN amplifies the audio in 'filename' by 'gainIndB'. 
%
% by Brecht De Man at Centre for Digital Music on 21 May 2015

if nargin < 4
    bitdepth = 24;
end
if nargin < 3
    fs = 96000;
end

[audio,fsfile] = audioread(filename); % read part of file
assert(fsfile == fs); % check file has expected sampling rate
audiowrite(filename, (10^(gainIndB/20))*audio, fs, 'BitsPerSample', bitdepth);

end