From: stan Subject: Re: Alsa buffer Date: Tue, 14 Jul 2009 12:10:10 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from blu0-omc3-s19.blu0.hotmail.com (blu0-omc3-s19.blu0.hotmail.com [65.55.116.94]) by alsa0.perex.cz (Postfix) with ESMTP id E181A24368 for ; Tue, 14 Jul 2009 21:09:22 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org On Tue, 14 Jul 2009 08:55:58 +0700 arif setiawan wrote: > into file and open it in Matlab. I want to know if this is correct, > because when I try saving alsa buffer on a from recording I still get > noise not the voice. > > // directly save > FILE *fp1 = fopen("sineout1", "w"); FILE *fp1 = fopen("sineout1", "wb"); > > for (int i = 0; i < periodsize; i++) > { > fprintf_s(fp1, "%d\n", data[i]); You are printing formatted text data here, it needs to be binary. fwrite > } > > fclose(fp1); > > // with bit shifting from char to short > FILE *fp2 = fopen("sineout2", "w"); FILE *fp2 = fopen("sineout2", "wb"); > > for (int i = 0; i < num_frames; i++) > { > short newval = data[2*i+1] << 8; > newval += data[2*i]; > > fprintf_s(fp2, "%d\n", newval); You are printing formatted text data here, it needs to be binary. fwrite > } > > fclose(fp2); > > return 0; > } > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel >