PC Speaker Driver for BeOS V1.0
-------------------------------

Install
-------
Run install.sh and restart the media server. Thats all.....

Configuration
-------------
The driver will automatically determine the correct latency for the quality you have selected. To select the quality, go to the media prefs, pcsp Out and change the Mixer slider. The best quality is at the top, the worst at the bottom. The higher the quality, the more CPU will be used by the driver. You can check the impact on the system by running the Open GL Teapot demo and noting the framerate. Basically, keep sliding the slider up until the crackling disappears. The crackling is caused by interrupts (such as the mouse) and will affect the sound quality. When you move the slider, the driver takes a second or two to calculate the correct latency for your system - if you are listening to something (eg an MP3 file), the pitch seems to dip then rise. This is the auto calibration. If you want, you can mute the pcsp by muting the mixer on pcsp Out. When the driver is in mute mode, is uses very little CPU, ie. if you want to do some serious processing, mute the sound!

Some programs may use a lot of CPU (eg. 3D Mixer) and the sound seems to jump (or sound bad in any case). It may seem strange, but LOWER the quality of the driver and things will actually improve (the CPU is not fast enough to use the latency for the selected quality).

The CD Volume control acts as a tone control. When the slider is at the top, then the sound is unchanged - the further down the slider is, the more BASS is added to the sound. The reason for adding this is that PWM tends to make the sound have a bit too much treble. Different speakers will need different values to sound good (its actually to do with the momentum of the speaker cone).

The Line Volume control determines the time after all sounds have finished that the driver is placed into suspend mode (ie uses the same CPU as if it were muted). The higher the slider, the longer the wait (at the very top, it is infinite - no suspend). If you play sounds with a lot of silence, then you probably should put the control at the top. There will be a click when the driver is placed into either mute or suspend mode.

The pcsp in device is a simple loopback. If you use the SoundRecorder program, whatever is playing at the moment is recorded. It is a good idea to lower the quality of playback so less CPU is used for the sound - the recorded sound is still full quality and won't have any of the crackles as it is a copy of the input. The input device is always 22050Hz, 16 bit stereo.

The only program that won't run is the CD played as this expects a tunnel to the audio card. You can still listen to CDs by mounting them, and playing the files in the WAV directory.

Version 1.1 will have:
   o Native CD support,
   o Hopefully better controls (when I learn a bit more about the media preference panel :^)


***** NOTE ******
    o If your machine is very slow, the driver will not work - in this case the speaker will buzz (annoyingly :), so just mute it and delete the driver (in ~/config/add-ons/kernel/drivers/bin).

    o When connected to the internet via a modem, the interrupts from the modem are longer than the sound driver can handle, so you will hear quite bad crackles.  There's not much we can do here, so either mute the sound when you are on the net, or just put up with it :P  (severe floppy access also does this)

Technobabble
------------
For those interested, the driver implement a Pulse Width Modulation algorithm at 22.2kHz (45 microsecond period). The latency is required because the timer is not completely accurate as it can be interrupted. The latency is a time taken to perform an interrupt. So we set a timer for the period minus the latency, then spin until the desired time inside code with interrupts disabled.  This of course sucks CPU cycles - hence the quality. If you don't mind a few crackles from interrupts, then lower the quality and use less CPU. If you want the top quality, you use more CPU. The mute simply stops the spin code and slows the timer so virtually no CPU is used. The latency is constantly monitored, so that the sound quality should be constant no matter what is running (unless the latency goes above the maximum).

The maximum latency is set at 23 microseconds, meaning the CPU has just 22 microseconds to work in - so a slow computer at maximum quality will be about 2 times slower than normal. A fast machine may only have a latency of 5 micro seconds at maximum quality (my p3 500 laptop has about 10 -15 micro seconds).

The type of speaker is a big factor in the sound quality, and PWM doesn't work at all on Piezeo speakers. If you have desktop speakers, the sound quality at maximum is quite acceptable (FM radio). The sound quality out of tiny laptop speakers is about AM radio, but still good enough to listen to. If you have good speakers, turn the trebble down as there will be a slightly audible 11kHz (the Nyquist frequency) overtone. Good speakers will pick this up, however run of the mill computer ones normally won't.

The BASS adjustment implements a simple first layer digital filter ranging from an infinite cutoff (ie. none) to a cutoff of about 1kHz.

If no sound comes out, but you get the device in the media prefs, then you have probably run the personal edition from WINDOWS and your sound card has disabled the PC speaker (naughty WINDOWS). You can either boot from a floppy, set your sound card before booting BeOS, or buy the PRO version.

Good luck,
Jeff
jeff@jpashaw.force9.co.uk


PS. You obviously use this driver at your own risk.