Hi!

I have just ported the pcm-sound demo to rtai.
you can download it here:

http://www.rcs.ei.tum.de/~kuhn/rtlinux/rtai_pcmsound-19991219.tgz

maybe it is usefull for somebody

Bernhard





here's the README-file:

Syntax:
   insmod pcmsound.o [soundfifo=<number-of-soundfifo>] [\
                      period=<period-in-nanoseconds>] [\
                      oversampling=<oversampling>] [\  
                      gain=<gain>] [\
                      gainfifo=<number-of-gainfifo>]

Decription:

This demo was inspired by the original "rtl-sound demo"
from Michael Barabanov, but instead of just
altnating the level of the PC-speaker according
to positive or negative waves (aka 1-Bit DA-Converter),
here we do an oversampled pulse width modulation.
As a PC-Speaker acts like a low pass filter, the
disturbing base-frequence will be unhearble.



Therory of operation:

The sound data will not only be converted to "0" or "1"
every period like it is in the original example, but
into a pulse width modulated signal (PWM):

value  t_off   t_on
====================
-127  100.0%    0.0% 
-126   99.6%    0.4%
 ...    ...     ...
  -1   50.4%   49.6%
   0   50.0%   50.0%
   1   49.6%   50.4%
 ...    ...     ...
+126    0.4%   99.6%
+127    0.0%  100.0%

Consequently, sound quality is (or at least: should be)
much better, maybe comparible to a DAC with 8Khz and
6 Bit - but your mealage may vary :-)

Note: with a beeper, the sound is rather bad, since
it doesn't act as a low-pass filter like a real speaker.

Installation:

Just edit the Makefile and do a "make". 
Then, insmod the new module and send some *.au-files
to /dev/rtf0, like you would do it with the original
PC-Speaker sound example included in RTL2.0:

cat linux.au > /dev/rtf0

BTW: "linux.au" has rather bad quality ... so try some more files
to recognice the accustical difference between /dev/audio and
/dev/rtf0 (both, (RTL2.0-)sound.o and pwmsound.o).
Be sure that you have write access to the fifo.

Before sending a *.au-file to a fifo, check if it is
in ulaw, 8KHz, mono format with "play" (is part of the
sox-package): play -V <soundfile.au>


Controling Volume:

do a

echo -ne "\040" > /dev/rtf1  # or selected gainfifo

to change the volume ("\010" is nominal).
--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/

Reply via email to