Re: C program for playing sound

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

 



     Hello together!

On Wed, 24 Jun 2020 17:37:46 -0300
Sleep <ireallyhatespam@xxxxxxxxxx> 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
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