Ross, My main point was that cpu processing is not likely to be an issue, as the limiting factor will be either disk I/O or your real-time I/O.
shr, shl and masking are *very* fast, but so are comparisons. Do you actually have a performance problem, or are you just being cautious? If you want maximum performance you may be looking in the wrong place. Other things are going to be your limiting factors. Glen -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Ross Levis Sent: Sunday, 9 October 2005 5:56 PM To: Borland's Delphi Discussion List Subject: Re: Test Integer greater than ShortInt Clipping is not too much of an issue since the mixing is either used at crossfading time where one song is already at around -12db before the mixing occurs, or there can be a jingle or voice track played at the same time as a song but the song will be lowered in volume by usually -9db or more during the mix. So far I haven't heard any noticeable distortion from the clipping. I was thinking there is probably some way to check if any bits after the first 8 are set. or something like that, and fix it in one line of code. Perhaps some shr or shl? I'm not good with bits. Regards, Ross. ----- Original Message ----- From: "Glen Thompson" <[EMAIL PROTECTED]> To: "Borland's Delphi Discussion List" <[email protected]> Sent: Sunday, October 09, 2005 8:29 PM Subject: RE: Test Integer greater than ShortInt 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 _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

