Ross, In my audio app (a rather special purpose one, for converting between mid-side and left-right, with volume, balance and phase controls) I have the same problem, but as I don't do it in real time it doesn't bother me. I can just scan the file for the maximum and scale down the volume so that it will just fit in ShortInt.
I won't allow clipping, for quality, so I would never use clipping code like you have below. Efficiency is fine for me. My program executes about 50 lines of code per sample, but the limiting factor is the disk I/O. (10-20MBytes/sec on my 4 year-old AMD1200 with RAID controller. I wish it was faster but cost is an issue.) BTW, I use the old Blockread and BlockWrite as they run faster on my PC. Glen -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Ross Levis Sent: Thursday, 6 October 2005 8:58 PM To: Delphi Discussion List Subject: Test Integer greater than ShortInt My audio application has a mixer for mixing multiple audio sources. I need to prevent the mixed volume to be larger than the allowed values which are -32768 to 32767. I'm currently doing the following 2 tests but I'm thinking there must be a more efficient way of doing this in 1 test. if NewVol > 32767 then NewVol := 32767; if NewVol < -32768 then NewVol := -32768; Being an audio app, it's handling lots of data continuously so the more efficiency the better. Any suggestions? Thanks, Ross. _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

