From alsa-devel-owner@alsa.jcu.cz  Thu Aug 20 20:30:04 1998
Received: from kawoserv.kawo2.rwth-aachen.de (root@kawoserv.kawo2.RWTH-Aachen.DE [137.226.146.2])
	by marvin.jcu.cz (8.8.8/8.8.8) with ESMTP id UAA15850
	for <alsa-devel@alsa.jcu.cz>; Thu, 20 Aug 1998 20:29:58 +0200
Received: from phoenix.kawo2.rwth-aachen.de (root@phoenix.kawo2.rwth-aachen.de [137.226.251.161]) by kawoserv.kawo2.rwth-aachen.de (8.8.0/8.6.9) with ESMTP id UAA03896 for <alsa-devel@alsa.jcu.cz>; Thu, 20 Aug 1998 20:30:11 +0200
Received: from localhost by kawo2.rwth-aachen.de
	via sendmail with smtp
	id <m0z9ZTt-0006Q0C@phoenix.kawo2.rwth-aachen.de> (Debian Smail3.2.0.101)
	for <alsa-devel@alsa.jcu.cz>; Thu, 20 Aug 1998 20:30:41 +0200 (CEST) 
Date: Thu, 20 Aug 1998 20:30:41 +0200 (CEST)
From: Maximilian Bisani <bisani@kawo2.rwth-aachen.de>
To: alsa-devel@alsa.jcu.cz
Subject: Detecting ADC Overload
Message-ID: <Pine.LNX.3.96.980820194827.231A-100000@phoenix.kawo2.rwth-aachen.de>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list


Hello!

Since I am new on this list I would like to express my admiration for what
you have achieved so far.

I am currently writting a tiny alsa-native program to automatically adjust
the mixer setting of the selected recording source, similar to the auto
rec-level feature of my tape deck.  The method is very simple:  Increase
the record level until the signal exceeds the permissible input range of
the ADC (I think this is called "overloading") then drop it slowly
until no more overloads occur (for several seconds).

My problem: How do I detect overloading?  From my experiments I found that
peaks get truncated to a certain maximum value.  When I record with
SND_PCM_SFMT_S16_LE and SND_PCM_OPEN_RECORD a signal too high gives +32767
(0x7fff) and a signal too low signal gives -32768 (0x8000), which I had
expected.  When I switch to SND_PCM_OPEN_DUPLEX (for "after tape
monitoring") however, the values range from -32640 to +32640 only. 

So I have three questions:
 - Is there a better way to detect ADC overloading, than looking for 
   peak values?
 - Why are the maximum and minium values different in DUPLEX mode?
 - If maximum and minimum values are mode (and posibly hardware; btw I
   have an SB 32 AWE) dependent, shouldnt there be a library function,
   so that an application such as mine, can find out?

Waiting for your answers,
   Max


P.S. Are you still in need of someone to improve the API documentation?


