%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% getHexAudio.m
% Finds the 2's complement hex representation of a
% value between -1 and 1.
%
% Returns a string containing the hex value.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function final_Hex = getHexAudio(negPosValue);

if(negPosValue<-1 | negPosValue>1 | length(negPosValue)>16)
	disp('Audio Sample Out of Range');
    return
elseif (negPosValue>=0)
    calcValue = round(32767*negPosValue);
else
    calcValue = round(32767*(negPosValue+1)+32768);
end
final_Hex = dec2hex(calcValue);