home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / sounds / digvoice.zip / VOICE.DOC < prev   
Text File  |  1993-04-01  |  7KB  |  107 lines

  1.               VOICE DIGITIZATION AND REPRODUCTION ON THE
  2.                  IBM PC/XT AND PC/AT BUILT-IN SPEAKER
  3.              --------------------------------------------
  4.  
  5.                     Alan D. Jones        July 1988
  6.  
  7.  
  8.     The speaker on the PC and its associated driver circuitry is quite
  9. simple and crude, having been designed primarily for creating single
  10. square-wave tones of various audio frequencies. This speaker is typically
  11. driven by a pair of transistors used as current amplifier which is in turn
  12. driven directly by the output of a TTL gate. This results in only two
  13. possibilities of voltage across the voice coil: 0 volts and 5 volts. Any
  14. sound to be reproduced by this system must be reduced to an approximation
  15. in the form of a stream of constant-amplitude, variable-width rectangular
  16. pulses.
  17.     Examination of a speech waveform on an oscilloscope display quickly
  18. tells us that it is not going to be possible to even remotely mimic this
  19. waveform under the above restrictions. Much of the information contained
  20. in the waveform is in the form of amplitude variations, and this is the
  21. one attribute we cannot reproduce. It is initially tempting to try to
  22. use the technique of the "class D" amplifier to create the waveform, using
  23. high-speed pulse width modulation and depending on the mechanical
  24. characteristics of the speaker and those of the human ear to provide the
  25. missing low-pass filtering. Assuming the sampling rate to be 8 KHz (based
  26. on the Nyquist criterion) and, to conserve memory, assuming the samples
  27. to contain only 4 bits of amplitude information (16 levels), we can see
  28. that data accumulates at a rate of 4k bytes per second, which is certainly
  29. acceptable. The problem comes when we try to play back the sound. Pulses
  30. occur at intervals of 125 microseconds, which doesn't seem too bad, but
  31. since each pulse can have 16 possible widths, it is necessary to time the
  32. pulses with a resolution of well under 8 microseconds. This is only a
  33. couple of instruction times on a 4.77 MHz XT, and even on a fast 80386
  34. it doesn't give the CPU much time between bits to shift bits, read and
  35. increment a pointer, check the pointer to see if it's done yet, etc., not
  36. to mention the difficulty of servicing unrelated interrupts.
  37.     The search for simpler (but still usable) and less CPU-intensive
  38. methods of reproducing speech leads to the question of what information
  39. in the waveform we can discard without an unacceptable loss of
  40. intelligibility. My experiments with running speech signals through
  41. a graphic equalizer revealed that the lower-frequency components, those
  42. which are most visible to the eye on the oscilloscope, are actually of
  43. minimal importance in understanding speech. This is also demonstrated by
  44. the fact that a whisper is just as understandable as normal speech, but
  45. does not make use of vibrating vocal chords, which are the primary source
  46. of low-frequency components in the voice.
  47.     The schematic created by printing the file SCHEMATC.PRT arose partly
  48. from the above observations and partly from trial-and-error. The circuit
  49. consists of two stages of voltage amplification with some high-pass
  50. filtering built into the coupling capacitors, followed by a differentiator.
  51. The output of the differentiator is fed to a voltage comparator, thus
  52. producing an output which has approximately the following relationship
  53. to the input from the microphone: If the derivative of the speech waveform
  54. if positive, then the output is logic zero; If the derivative of the speech
  55. waveform is negative, then the output is logic one. The transition timing
  56. at the output is entirely analog in nature; there is no synchronizing
  57. clock signal anywhere in the circuit.
  58.     If the output of this circuit is connected directly to a speaker, the
  59. resulting sound will still be an understandable version of the input.
  60. Since the output consists of nothing but a digital bit stream, the job
  61. of the computer becomes that of simply recording and accurately reproducing
  62. this bit stream.
  63.     The trimpot at the input of amplifier U3 is used to set the DC idle
  64. voltage output from the differentiator to somewhere near the threshold
  65. of comparator U4. There will be a considerable amount of noise at the output
  66. of U3, originating at the microphone and within the input circuitry of U1,
  67. and highly amplified by U1 and U2. The trimpot should be adjusted so that
  68. the comparator threshold is just outside the normal excursion of the noise
  69. signal ("off to one side"), otherwise "silence" at the microphone will
  70. become, at the speaker output from the computer, a loud hiss with a strong
  71. component at half the sampling frequency.
  72.     I used LF356's for U1, U2, and U3, and an LM393 for U4. Everything is
  73. powered by +12 and ground. All amplifiers should have power supply bypass
  74. capacitors (not shown). The microphone is a 600 ohm dynamic type. The 12
  75. volt power supply should be quiet and well-regulated; the one in the PC is
  76. too noisy unless you use heavy filtering.
  77.     The two programs, RECORD and PLAY, are used as follows: Attach the
  78. circuit to the CTS input on one of the PC's COM ports. Then type:
  79. RECORD <number> <filename>    where <number> is the COM port number
  80. and <filename> is the name of the disk file to contain the voice data.
  81. RECORD will respond with "Press a key to start and stop." Press the space
  82. bar and start talking. Press the space bar again to end recording and write
  83. the data to disk. Play it back with PLAY <filename>. The sampling rate is
  84. about 16.5k bits per second. This means that about 30 seconds of voice will
  85. make a 64k disk file. This is a simple program; it runs out of steam at 64k.
  86. The programs both operate by reprogramming the 8253 time chip to produce
  87. hardware interrupts at the 16.5 KHz rate. The interrupt service routine then
  88. manipulates the NAND gate driving the speaker based on bits read from the
  89. file. The 16.5 Khz rate was chosen by trial-and-error; this is the audible
  90. "point of diminishing returns", where a further increase in sampling rate
  91. didn't produce enough of an improvement to warrant the increased memory
  92. usage.
  93.     This technique is somewhat limited in its usefulness. It necessitates
  94. the writing of a "badly behaved" program which not only reprograms the timer
  95. chip but also totally hogs the CPU for the duration of the voice output.
  96. Nevertheless, it demonstrates a few interesting things about how humans hear
  97. speech. I first developed this circuit over a year ago as a rebuttal to
  98. someone who said "it couldn't be done". Not only can it be done, it is
  99. actually quite simple. Certainly the curcuit could be improved, at the
  100. possible expense of increased complexity. I'm waiting to hear from some of
  101. you. If anyone has questions, especially about my sloppy code, I check
  102. for messages on CIS every three or four days.
  103.  
  104.                                                         - Alan
  105.  
  106.                                                           74030,554
  107.