Here is an example:
Program SaturationDemo;
{ example for saturation, scales data (for example audio) with 1.5 with rounding to negative infinity } uses mmx; var audio1 : tmmxword; i: smallint; const helpdata1 : tmmxword = ($c000,$c000,$c000,$c000); helpdata2 : tmmxword = ($8000,$8000,$8000,$8000); begin { audio1 contains four 16 bit audio samples } {$mmx+} { convert it to $8000 is defined as zero, multiply data with 0.75 } audio1:=(audio1+helpdata2)*(helpdata1); {$saturation+} { avoid overflows (all values>$7fff becomes $ffff) } audio1:=(audio1+helpdata2)-helpdata2; {$saturation-} { now mupltily with 2 and change to integer } for i:=0 to 3 do audio1[i] := audio1[i] shl 1; audio1:=audio1-helpdata2; {$mmx-} end. |