alsa icon indicating copy to clipboard operation
alsa copied to clipboard

VU Meter peak detection -- wrong masking operators?

Open kolstad opened this issue 9 years ago • 1 comments

I'm trying to fathom the masking operators in aplay.c (which is also arecord). I'm looking in: static void compute_max_peak(u_char *data, size_t count) which is near line 1650. I see these commands, (in this case for 8 bit samples): signed char mask = snd_pcm_format_silence(hwparams.format); c = 0; while (count-- > 0) { val = valp++ ^ mask; / <=== IS THIS RIGHT? */ val = abs(val); if (max_peak[c] < val) max_peak[c] = val; if (vumeter == VUMETER_STEREO) c = !c; }

That masking command, which often masks with 0x0 but occasionally with other values, esp. for bigger sample sizes, seems like it ought be: val = *valp++ & (~mask);

Of course, perhaps i really misunderstand what's going on in the 'silence' function, which seems on rare occasions to return 0x8000 and the like, where the '8' is in the sign bit.

What does the exclusive or do???

RK

kolstad avatar Sep 12 '16 15:09 kolstad

Sorry, I missed this issue from a week ago. Please sign up to one of the official mailing-lists and ask you question there. Probably alsa-devel would suit this kind of question.

http://www.alsa-project.org/main/index.php/Mailing-lists

markc avatar Sep 19 '16 06:09 markc