TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: R.WIESER
date: 2020-01-03 12:49:00
subject: Re: ALSA sound cut short

Jim,

> I see you've not had any response to your query.

Indeed. :-\

> I'm not surprised. I don't think there are many people who have
> programmed the ALSA interface,

Not ?   In that case, how does everybody else get user-defined sounds from
their speakers ?    Is there another approach available ?

> and you have probably found there are not many tutorials on how to use it.

Indeed again.   Some code snippets, a few "compile this" programs, and a
list of pcm related functions.  Thats about it.

> but it is Soooo.... complicated

The basic setup, as presented in that linke I provided, looks fairly simple
to me.  Its just that when I make small changes (like changing the sample
rate) it refuses to work (change) in a way I can make sense of. :-\

> You just might have got me interested in trying again.

So ?    You will have the solution for me tomorrow ? :-D (yes, that was a
joke.  No, really :-) )

> I hope you have made progress.

Just this morning I tried some super-simple code using
"snd_pcm_set_params( )" and a single buffer (
https://stackoverflow.com/questions/40399046/how-to-play-short-tones-with-alsa
)
and found out that by lowering with the latency parameter value (the last
one) I could get the same "cut short" effect my origionally mentioned code
suffers from.

That made me think that maybe the internal ALSA buffer empties before a new
set of data (my programs buffer) is written into it ...    Which is as far
as I currently got.

Though no idea why, when I put a seconds long "usleep( )" before the
"snd_pcm_drain( )", the whole sound is played without me hearing any kind of
hickups.


And again, if you know of another, more dependable way to generate sounds in
a C program than I would really like to know (as in a different API).

Regards,
Rudy Wieser

P.s.
I tried to set a bigger internal buffer
(snd_pcm_hw_params_set_buffer_size_near( ) ), but could not get it to change
from 32768.

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.