All of lore.kernel.org
 help / color / mirror / Atom feed
* newbie, arecord
@ 2010-06-28 16:38 javi perez
  2010-06-28 18:06 ` Jaroslav Kysela
  0 siblings, 1 reply; 2+ messages in thread
From: javi perez @ 2010-06-28 16:38 UTC (permalink / raw)
  To: alsa-devel

I am trying to do a speech recognition system. In the aplay file I would
like to conver the unsigned char buffer
to a float buffer to be able to make comparisons the way I would like. The
floats that I am getting after the conversion are these.
How should I do the conversion from unsigned char to float array? thanks in
advance.

819 -464604244644772930012428885483847680.000000
820 -542490915911345743841838949652758528.000000
821 -495758857691688295559156595670646784.000000
822 -480181610589352498484045935735209984.000000
823 -441239146465853748477054432634208256.000000
824 -376333296573780517983308202832297984.000000
825 -503547144523165508473277153076576256.000000
826 -485374263974618640302095603012206592.000000
827 -495758501164956981369637424722870272.000000
828 -433450265423157678580401923648651264.000000
829 -415277147190123267616207592952430592.000000
830 -425662216276168008459294146874572800.000000
831 -477585818686816398859299858518376448.000000
832 -394508395510877785555942372127277056.000000
833 -472393086073387742776912597697429504.000000
834 -482778551300245054941687119339323392.000000
835 -584029726534518193323939684778246144.000000
836 -511336897075649235277643191045586944.000000
837 -558067806486950226727430438640418816.000000
838 -513933085118997906224077235982172160.000000
839 -302397753578834695235772573852631040.000000


      float* float_array;

        while (rest > 0 && recycle_capture_file == 0) {
            size_t c = (rest <= (off64_t)chunk_bytes) ?
                (size_t)rest : chunk_bytes;
            size_t f = c * 8 / bits_per_frame;

            if (pcm_read(audiobuf, f) != f)
                break;

            float_array=(float*)malloc(f);
            memcpy(float_array,audiobuf,f);
            int z=0;

            for(z=0; z<f/sizeof(float);z++){
                printf("%d %f\n",z,float_array[z]);
            }


            /*if (write(fd, audiobuf, c) != c) {
                perror(name);
                prg_exit(EXIT_FAILURE);
            }*/
            count -= c;
            rest -= c;
            fdcount += c;
        }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: newbie, arecord
  2010-06-28 16:38 newbie, arecord javi perez
@ 2010-06-28 18:06 ` Jaroslav Kysela
  0 siblings, 0 replies; 2+ messages in thread
From: Jaroslav Kysela @ 2010-06-28 18:06 UTC (permalink / raw)
  To: javi perez; +Cc: alsa-devel

On Mon, 28 Jun 2010, javi perez wrote:

> I am trying to do a speech recognition system. In the aplay file I would
> like to conver the unsigned char buffer
> to a float buffer to be able to make comparisons the way I would like. The
> floats that I am getting after the conversion are these.
> How should I do the conversion from unsigned char to float array? thanks in
> advance.

Study more C language. Hint: Forget memcpy and use the standard for loop 
to copy unsigned char samples to float array.

 						Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-28 18:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-28 16:38 newbie, arecord javi perez
2010-06-28 18:06 ` Jaroslav Kysela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.