disp(' ');
disp(' room_constant.m   ver 1.0  September 14, 2011 ');
disp(' by Tom Irvine ');
disp(' ');
disp(' This program calculates the room constant R which is a ');
disp(' modified ratio number representing direct to reverberant ');
disp(' sound. ');
disp(' ');
%
clear A;
clear R;
clear S;
clear V;
%
disp(' Select units ');
disp(' 1=English  2=metric ');
iu=input(' ');
disp(' ');
disp(' Select method ');
disp('  1=enter reverberation time, volume, surface area ');
disp('  2=enter average absorption coefficient, surface area ');
im=input(' ');
%
disp(' ');
    if(iu==1)
        S=input(' Enter surface area (ft^2) ');
    else
        S=input(' Enter surface area (m^2) ');        
    end
if(im==1)
    if(iu==1)
        V=input(' Enter room volumne (ft^3)  ');
    else
        V=input(' Enter room volumne (m^3)  ');
    end
    T=input(' Enter reverberation time (sec)   ');

%
    alpha_bar=0.05*V/(S*T);
    out1=sprintf('\n alpha_bar = %6.3g ',alpha_bar);
    disp(out1);
    if(alpha_bar>1)
        disp(' ');
        disp(' Warning: alpha_bar > 1 ');
    end
%
else
    alpha_bar=input(' Enter the average absorption coefficient ');
end
%
A=S*alpha_bar;
%
if(iu==1)
    out1=sprintf('\n Total absorption A = %8.4g ft^2',A);
else
    out1=sprintf('\n Total absorption A = %8.4g m^2',A);
end
disp(out1);
%
R=A/(1-alpha_bar);
%
if(iu==1)
    out1=sprintf('\n R = %7.4g ft^2',R);
else
    out1=sprintf('\n R = %7.4g m^2',R);    
end
disp(out1);