Re: how to use the buffer from sound card

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

I write a program that capture the sound and when the buffor of sound card is full send this by UDP to server. Then server will be calculate the FFT on this. So I need the samples. So my record_buffor function in  capture program:

static void record_buffor(const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset,int count, double *_phase)
[...]
            unsigned char *samples[channels];
[...]
            f_write = write(f_open, *(samples), PERIOD_SIZE);      // save to the local disk     
            LiczbaBajtow=sendto( Deskryptor, *(samples), PERIOD_SIZE, 0, (struct sockaddr *)&AdresSerwera, sizeof(AdresSerwera));   //send to server
            while (PERIOD_SIZE-- >0)   {
              samples[chn] += steps[chn];
             }
            
I also try to save the file to local disk in this way:
unsigned char *tmp;
size = 2;
while (PERIOD_SIZE-- >0)  {
   tmp[byte] = *(samples[chn] + byte);
   f_write = write(f_open, tmp, size); 
  }
But I have value something like this ............^.^.^............^.^.^.^.^....... 

If I use fprintf (f_open, "%u",tmp[byte])
I have only "0.0.0.0.0.0."

So I need the key how open convert this *(samples) to anything that I can work with it. Could You help me?

Best wishes
Mark





Pozdrawiam
Marek Michalak


2009/8/31 Bill Unruh <unruh@xxxxxxxxxxxxxx>
On Mon, 31 Aug 2009, Marek Michalak wrote:

Hello!

I change the pcm.c program from alsa-lib/test, and capture the sound by
asynchronic function with mmap. But when I edit recorded file I've got only
dots like: ..................
Sound files are not text files. What are you using to try to edit the file?


When I open the file in aplay I have capture sound. How converts this 'dots'
to normal value that I can use in my program?

What program?



Best wishes
Marek Michalak



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user

[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux