Hi Rudy,
I see you've not had any response to your query. I'm not surprised. I
don't think there are many people who have programmed the ALSA interface,
and you have probably found there are not many tutorials on how to use it.
20 years or more ago I wrote a set of linux programs to generate the sort
of signals a traditional lab signal generator would do. This was before
ALSA, the kernel sound system then being the Open Sound System (OSS). It
proved fairly easy to use. When ALSA came along, I looked at converting
the programs, but it is Soooo.... complicated :-( and back then there was
even less tutorial or introductory articles. So I gave up. You just might
have got me interested in trying again.
I hope you have made progress.
Jim
> 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)
|