Hello,
I am looking to create a function that could create a fade-in/fade-out function on a .wav file over a period of five seconds.
I found this code on the MATLAB forums but it seems the implementation was slightly wrong, although the right idea is there. It was for .WAV files of 300ms with a 10ms fade-in/out:
tenmssamples = length(soundfile)*10/300;
fade1 = linspace(0,1,tenmssamples);
fadedsound = soundfile .* ...
[fade1, ones(1,length(soundfile)-2*tenmssamples), fliplr(fade1)];
tenmssamples = length(soundfile)*10/300;
fade2 = sin(linspace(0,2*pi/4,tenmssamples));
fadedsound2 = soundfile .* ...
[fade2, ones(1,length(soundfile)-2*tenmssamples), fliplr(fade2)];
I can see what he was trying to do by trying to scale the first 10 samples of the waveform read by an increasing function using linspace, but I have tried to tinker and modify it but I cannot get it to work.
Does anyone have any suggestions please? Thank you.