Re: C program for playing sound

Gerhard Wolfstieg <[email protected]>
Newsgroups gmane.linux.alsa.user
Message-ID <[email protected]>
     Hello together!

On Wed, 24 Jun 2020 17:37:46 -0300
Sleep <[email protected]> schrieb:

>      // Insert samples to framebuffer.
>      wav = fopen("pcm1611s.wav", "r");
>      fseek(wav, 0L, SEEK_END);
>      size = ftell(wav);
>      fseek(wav, 0L, SEEK_SET);
>      buffer = malloc(size);
>      fread(buffer, sizeof(int16_t), size, wav);
>      fclose(wav);
>      size /= sizeof(int16_t);
> 
>      // Set ptrbuffer 46 bytes ahead to skip the header.
>      for (int16_t *ptrbuffer = buffer + 46; size > ptrbuffer - buffer; 
> ptrbuffer += FRAMEBUFFERSIZE * STEREO * BITS)
>      {

I would:

avoid the #defines as far as possible and fetch the values out of the
RIFF-header;

first read the RIFF-header and with its contents calculate starting
point and length of data.

It is not guaranteed that the line with „for(“ (always) works – this as
a qick response …

     Grüße, Gerhard




_______________________________________________
Alsa-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.