public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Doug Ledford <dledford@redhat.com>
To: Greg Pomerantz <gmp@alumni.brown.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: i810_audio mono troubles
Date: Tue, 18 Dec 2001 11:11:44 -0500	[thread overview]
Message-ID: <3C1F6AC0.40604@redhat.com> (raw)
In-Reply-To: <auto-000001925289@mx1.relaypoint.net>

Greg Pomerantz wrote:

> +++ drivers/sound/i810_audio.c	Mon Dec 17 23:15:19 2001
> @@ -609,6 +609,9 @@
>  	
>  	new_rate = ac97_set_dac_rate(codec, rate);
>  
> +	if ((dmabuf->fmt & I810_FMT_STEREO) == 0)
> +		new_rate *= 2;
> +
>  	if(new_rate != rate) {
>  		dmabuf->rate = (new_rate * 48000)/clocking;
>  	}
> @@ -1687,6 +1690,12 @@
>  		if (dmabuf->enable & ADC_RUNNING) {
>  			stop_adc(state);
>  		}
> +
> +		if (*(int *)arg == 0)
> +			dmabuf->fmt &= ~I810_FMT_STEREO;
> +		else
> +			dmabuf->fmt |= I810_FMT_STEREO;
> +
>  		return put_user(1, (int *)arg);
>  
>  	case SNDCTL_DSP_GETBLKSIZE:


OK, first off, Alan & Co. will shoot this one down because handling 
stereo/mono conversion belongs in user space (the agreed upon way of 
handling things evidently).  Secondly, aside from that point, this is wrong 
anyway.  You are dividing the play rate in half to compensate for the fact 
that the sound is being sent to two channels instead of one.  So, now each 
channel is playing at half speed and slightly out of phase and with much 
reduced high frequency clarity.  Instead, what you should do, is byte double 
the stream (CPU consuming).  You would need to take any input buffer and 
copy every 16bit sample.  A very simple (and non-optimized) stereo converter 
  might look like this:

short *input=&input_buffer, *output=&output_buffer;
int i,j;

for(i=0, j=0;i < input_size;i++, j+=2)
	output[j] = output[j+1] = input[i];



-- 

  Doug Ledford <dledford@redhat.com>  http://people.redhat.com/dledford
       Please check my web site for aic7xxx updates/answers before
                       e-mailing me about problems


  reply	other threads:[~2001-12-18 16:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-18  4:58 i810_audio mono troubles Greg Pomerantz
2001-12-18 16:11 ` Doug Ledford [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-12-18  4:57 Greg Pomerantz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C1F6AC0.40604@redhat.com \
    --to=dledford@redhat.com \
    --cc=gmp@alumni.brown.edu \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox