[alsa-devel] [PATCH utils] aplay: fix VU meter for S24_LE etc formats

Takashi Iwai tiwai at suse.de
Wed Sep 23 16:28:59 CEST 2015


On Tue, 15 Sep 2015 13:10:00 +0200,
Ricard Wanderlof wrote:
> 
> 
> When recording or playing back audio in a format where the number of 
> significant bits is less than the physical width (e.g. S24_LE), the VU 
> meter code needs to consider the number of significant bits in the samples 
> rather than the physical sample width (e.g. 24 vs 32 bits). Otherwise the 
> resulting VU meter display will be far too low and it will just indicate 
> 0% all the time.
> 
> Tested with a device supporting the S24_LE format.
> 
> Signed-off-by: Ricard Wanderlof <ricardw at axis.com>

Applied, thanks.


Takashi

> ---
>  alsa-utils/aplay/aplay.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/aplay/aplay.c b/aplay/aplay.c
> index e58e1bc..19b6a92 100644
> --- a/aplay/aplay.c
> +++ b/aplay/aplay.c
> @@ -124,7 +124,7 @@ static int fatal_errors = 0;
>  static int verbose = 0;
>  static int vumeter = VUMETER_NONE;
>  static int buffer_pos = 0;
> -static size_t bits_per_sample, bits_per_frame;
> +static size_t significant_bits_per_sample, bits_per_sample, bits_per_frame;
>  static size_t chunk_bytes;
>  static int test_position = 0;
>  static int test_coef = 8;
> @@ -1344,6 +1344,7 @@ static void set_params(void)
>  		snd_pcm_dump(handle, log);
>  
>  	bits_per_sample = snd_pcm_format_physical_width(hwparams.format);
> +	significant_bits_per_sample = snd_pcm_format_width(hwparams.format);
>  	bits_per_frame = bits_per_sample * hwparams.channels;
>  	chunk_bytes = chunk_size * bits_per_frame / 8;
>  	audiobuf = realloc(audiobuf, chunk_bytes);
> @@ -1745,7 +1746,7 @@ static void compute_max_peak(u_char *data, size_t count)
>  		}
>  		return;
>  	}
> -	max = 1 << (bits_per_sample-1);
> +	max = 1 << (significant_bits_per_sample-1);
>  	if (max <= 0)
>  		max = 0x7fffffff;
>  
> -- 
> 1.7.10.4
> 
> 
> -- 
> Ricard Wolf Wanderlöf                           ricardw(at)axis.com
> Axis Communications AB, Lund, Sweden            www.axis.com
> Phone +46 46 272 2016                           Fax +46 46 13 61 30
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel at alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 


More information about the Alsa-devel mailing list