4.5 Input and output considerations
In this final portion of Section 4, I shall look in outline at how text, moving pictures and sound can be input into a PC and output from it. I'll leave aside the possibility that the data has been obtained by buying a disk or downloading via the Internet and assume that the user is creating it.
I'll start by considering text, typed in at the keyboard. Pressing a key closes a contact and causes electrical current to flow. This enables the computer's keyboard input system to detect which key has been pressed. The input subsystem then generates a corresponding internal code – which is neither the PC's version of ASCII nor Unicode but which is predefined for PC keyboards – and sends this code to the processor. From now on it is up to the application to translate this special keyboard code into its own binary codes.
Box 10: Music CDs
Music CDs do rather better than the 40 000 samples per second suggested by Example 5; they are created by taking 44 100 samples every second for each of the two stereo channels, which means that the interval between samples is just under 23 microseconds per channel.
They use 16 bits to hold each sample, which is enough to make the quantisation error imperceptible to human ears when the digital sound is replayed.
The files that result from this sampling rate and number of bits are large. One of the standard sizes of music CD – the one that runs for 80 minutes – holds over 800 million bytes.
Next I'll consider the input of moving images. For this it's convenient to use a simple digital camcorder, perhaps a web cam. Such a camera produces a stream of frames, each one produced either from a CCD array, in the same way as you saw for the digital camera, or (as is becoming increasingly likely) from a CMOS detector. There is a great deal of processing to be done here (for each brightness and colour value for each pixel of each frame, and probably compression as well so that the resulting data does not take up too much space) and so the input subsystem needs to incorporate a processor. Some web cams now incorporate their own input subsystem; for others a special video capture card in the PC is used as the input subsystem.
So far as sound is concerned, the user may speak into a microphone. In this case the microphone converts the vibrations in the air which are the speech signal into an electrical signal which is fed into an input subsystem on the computer's sound card. The sound card performs the necessary sampling and analogue-to-digital conversion and produces a stream of binary codes representing the sound for the PC's processor. Alternatively, the user may feed a pre-recorded analogue sound signal directly to the sound card, which again performs the necessary sampling and analogue-to-digital conversion.
All of the above are inputs to the PC. What about the reproduction of text, moving images and sounds by the PC?
Most PCs have three ways of reproducing these sorts of data: the screen (text and moving images); a printer (text); one or more loudspeakers (sound).
To produce a display on a PC's screen it is necessary to convert the binary codes for the image into corresponding colour and brightness levels for every pixel on the screen. These colour and brightness levels are then used to produce the required display – whether of text or images. If moving images are to be displayed then the image on the screen needs to be updated often enough for the user to perceive the motion as fluid, rather than jerky. As you have already seen, this implies a minimum rate of about 20 images per second.
The task of getting exactly the right colour and brightness for each pixel on the screen is an enormously demanding one for the output subsystem, and so PCs have a video card in them which contains a processor dedicated to just this one task.
Text characters are printed on paper as patterns of tiny dots of ink. Hence to produce a page of printed text it is necessary to convert each text character to an appropriate dot pattern and thus create the dot pattern for the whole page. A laser printer puts a whole line of tiny dots onto the page simultaneously, but an ink-jet printer sweeps repeatedly across the page, producing each line dot by dot. Most output subsystems associated with printers now incorporate a processor to help with the printing tasks.
To produce sounds, the opposite process to analogue-to-digital conversion is needed, starting from the codes that represent the sounds. As you might expect, this process is called digital-to-analogue conversion or D-A conversion. A digital-to-analogue converter forms part of the output subsystem for the PC's loudspeaker(s). This output subsystem is usually located on the computer's sound card, and its analogue output signal is fed to the loudspeaker(s) to produce the sound.
Box 11: Creating drawings and paintings
To create a drawing electronically, a drawing package can be used. This will detect the user's mouse movements, together with their menu choices for colour, weight of line, etc., and use these inputs to generate a vector graphics file.
Alternatively, a paint package can be used. Here the user's mouse movements and menu choices will be detected and used to generate a bit map.
A third alternative is to draw or paint the picture on paper by hand and then scan it. In this case the scanner will divide the picture up into pixels and then work systematically across and down the picture, using CCDs with filters to capture the colour and brightness of each pixel and then digitising and encoding these values. This process will form a bit map of the picture. Most scanners then compress the image, offering the user a choice of which compression technique to use.