Hello all,
I'm trying to generate a simple beep, and am heavily basing it on an example
found here:
http://www.linuxjournal.com/article/6735?page=0,0 Listing 3. Simple Sound
Playback
I've removed the reading from stdin and replaced it with filling the buffer
with a simpel square wave.
The problem is that when I set a sample rate of 8000 (instead of 44100*) the
sound only lasts for just less than a single second, instead of the in the
code specified 5. I've checked both the "period time" (32 ms) as well as
the "loop" count (156), and it all adds up to aprox. 5 sec.
*not sure if 44100 has the same problem, just that is was /very/ noticable
using 8000.
Inserting a "snd_pcm_nonblock(handle,0)" before the "snd_pcm_drain(handle)"
doesn't seem to change anything. However, putting a long-enough
"usleep( )" before the above "snd_pcm_drain( )" does show that the written
sound is indeed 5 seconds long (the beep ends some time before the time
delta* code is executed and printed)
*times are retrieved using "gettimeofday( )".
Remark: moving the delay to /after/ "snd_pcm_drain( )" (to see if the
"snd_pcm_close( )" was maybe to blame) still cuts the sound short. No idea
why though.
Question: How do I make the program wait until the full length of the
written sound has been played - without resorting to throwing some
best-guess "usleep( )" hacks into into it I mean. In other words: what is
missing from the example program I've been using ?
Regards,
Rudy Wieser
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|