Windowed CF

% input X, mono audio
% any fs value wil do

basewin = 0.47 * fs; lX = length(X);

% get RMS
numwin = floor(lX / basewin);
for k = 1:numwin
window = X([ round((k-1) * basewin1 + 1) : round( k*basewin1 ) ]);
myRMS(k) = sqrt(sum(window.^2)/basewin1);
end
myRMS = 20*log10(myRMS);

% get peak
aX = abs(X);
numwin = floor(lA / basewin2);
for k = 1:numwin
tocomp = aX([ round((k-1) * basewin + 1) : round( k*basewin ) ]);
mypeak(k) = max(tocomp);
end
mypeak = 20*log10(mypeak);
mypeak(isinf(mypeak)) = - 96; % assuming 16bit audio

%
myCF = mymax - myRMS;

0.47s windowing is discussed in the paper, section 2.4.2.

Windowed RMS

% input X, mono audio
% any fs value wil do

basewin = 0.47 * fs; lX = length(X);

numwin = floor(lA / basewin);
for k = 1:numwin
window = X([ round((k-1) * basewin1 + 1) : round( k*basewin1 ) ]);
myRMS(k) = sqrt(sum(window.^2)/basewin);
end
myRMS = 20*log10(myRMS);

0.47s is derived from crest factor algorithm.

Windowed loudness

Windowed PRRC

PRRC principle is discussed in the paper, section 2.5.