From mboxrd@z Thu Jan 1 00:00:00 1970 From: Clemens Ladisch Subject: Re: Create a stereo sound with alsa Date: Sat, 28 Jul 2012 11:36:08 +0200 Message-ID: <5013B288.7030304@ladisch.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by alsa0.perex.cz (Postfix) with ESMTP id 7B2E5265020 for ; Sat, 28 Jul 2012 11:36:51 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Luca Longhi Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org Luca Longhi wrote: > Hi. I've written a code to play two different sine wave (same amplitude and > f1=440Hz f2=600Hz) one on the left channel and the other on the right > channel. It seems to be working. I've tried doing the same thing using two > different sounds file (stereo) but the result is wrong. > err=snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_S16_LE); //16bit per campione=2byte per campione > ... > char * buffer1; > char * buffer2; > char * risultato; > ... > {v1=buffer1[j1];} > {v2=buffer2[j2];} > risultato[i++]=v1; > risultato[i++]=v2; The device expects 16-bit samples, but you write 8-bit values. Regards, Clemens