A SIMPLE PITCH DETECTOR USING A DIGITAL SIGNAL PROCESSOR
R.E.E.Robinson
Speech, Hearing, and Language Research Centre
Macquarie University
ABSTRACT - A Real Time Pitch extraction device using the TMS32010 Digital Signal Processor is described. It is designed as a replacement for an analog Pitch extractor and performs the same function but with greater accuracy and better dynamic response. The two are compared.
INTRODUCTION
The Macquarie University has a Real Time Pitch Meter which has been performing well for a number of years. The Pitch Meter was designed by the Speech, Hearing, and Language Research Centre (SHLRC) and consists of analog circuitry. The data from it is fed to a computer where it is printed or saved to disc. The computer merely logs the data. The analog Pitch Meter is built in a modular fashion which lends itself to easy redesign and improvement as such is needed in the research field. In this case the Pitch Measurement module has been replaced by another module using a Digital Signal Processor (DSP).
EXISTING PITCH METER
The Pitch Meter consists of an analog Pitch processor and a computer for data logging . The analog circuitry consists of a Microphone Amplifier for live analysis, and a Line Amplifier for connection to a tape recorder for analysis of recorded speech. (see Figure 1 ) A Level Meter is provided to allow levels to be set up correctly. A Low Pass Filter (LPF) is used to allow only the low frequencies through, which contain the pitch information. The Filter is manually switchable to different ranges to allow for different pitch voices and to overcome second harmonic influences. The signal is then split to an Intensity measuring module and the Pitch measuring module. The Intensity module gives an analog output proportional to the signal intensity. This is displayed on the computer as an Intensity envelope and is used to distinguish voicing from nonvoicing. The Pitch module gives an analog output proportional to the period of the incoming signal. This is interpreted as the Pitch and is displayed on the computer, time aligned with the Intensity envelope. This occurs in real time.
EXISTING ANALOG PITCH DETECTOR
The existing Pitch detector is an analog device and functions very well, however there is room for improvement. It is based on the VFQ1 voltage to frequency converter Integrated Circuit (IC) by DATEL. The Input to the module is buffered and a comparator acts as a zero crossing detector (squarer) generating a square wave output at the applied frequency. (see Figure 2) The square wave then goes to the VFQ1. This IC is connected as a frequency to voltage converter. An analog output is generated proportional to the input frequency. This technique tracks the Pitch quite well but suffers from capacitor charge and discharge delays. The output from the Pitch detector is typically 30 milliseconds (mS) behind the input, as it takes this length of time for the charging waveform to allow it to reach the correct voltage output. When voicing stops, the capacitor then discharges, and this takes about 25mS. The output of the Pitch detector has some ripple and is smoothed by a 25 Hertz (Hz) LPF. Despite these shortcomings the Pitch detector works well under most conditions. To overcome these problems, a new one was designed, taking advantage of DSP technology
DSP PITCH DETECTOR
The DSP version of the Pitch detector uses the TMS32010 DSP from Texas Instruments, as the processing load in real time is quite low. The input to the DSP uses identical circuitry to the analog detector which is, a buffer, and a comparator as a zero crossing detector (squarer) to generate a square wave. Then a pulse is generated, suitable for sampling by the DSP. This is applied to the DSP on the BIO input. (see Figure 3) The DSP has 2048 words of program storage in firmware, but only 50 words are used for this simple Pitch detection algorithm. The DSP has a 20MHz clock which allows it to execute 5 Million Instructions Per Second (MIPS). The clock is divided down to provide a 50KHz interrupt to the DSP. This is used to measure the duration of the Pitch period and determines the period accuracy. There is a 12bit Digital to Analog Converter (DAC) which is used to output the Pitch value calculated from the period of the incoming pulses. A 16bit latch is provided so that a digital Pitch value can be read directly by a computer. One of these bits is used to indicate voicing.
DSP SOFTWARE
The Pitch detection software is very simple and merely measures the period between the pitch pulses supplied by the analog processing hardware. (see Figure 4) Everytime a Pitch pulse occurs, it is detected on the BIO input of the DSP. A counter is cleared and this counter is read when the next pulse comes along. The counter value is used to calculate the Pitch in Hertz and the Pitch value is output to the DAC and the latch. A computer can read the real time Pitch from the DAC or digitally from the latch. The period value in the counter is checked for range, and is discarded if it is below 50Hz or above 1000Hz. If it lies within this range, as well as being output, a bit is set to indicate voicing. The 50KHz pulse connected to the INT pin on the DSP causes an interrupt every 20 microseconds (uS). The interrupt routine increments the period counter. It also decrements a timeout counter which has two functions. It detects the out of range value for less than 50Hz, which is the maximum period allowed. Also when a valid period does occur, the timeout counter is loaded with twice the pitch period, so that when voicing stops, the Pitch is set to zero. Using this method, there is a maximum Pitch error of 1 period at the end of voicing. This is considerably better than the analog Pitch detector.
A COMPARISON OF PITCH DETECTOR CHARACTERISTICS
The analog Pitch detector uses a capacitor to store a voltage inversely proportional to the input period. This has inherent limitations. The Pitch output does not begin to occur until 5mS after the Pitch Input. (see Figure 5) The output Pitch voltage does not reach the correct value until 30mS after it has begun rising. This is independent of the Pitch period. Similarly, the output does not begin to fall until 5mS after the input Pitch stops, and it does not reach zero until about 25mS later. This makes it difficult to see variations in Pitch at the beginning and end of voicing. Short Pitch sounds are also difficult to detect. The DSP Pitch detector measures the period of successive pulses and calculates the frequency. This technique means that the Pitch output occurs on the second Pitch pulse. (see Figure 5) The end of voicing is detected by loading a timeout counter with twice the current Pitch period, and if a pulse has not occurred before maturity, then voicing has stopped and the Pitch is set to zero. This means that there will be a maximum error of 1 Pitch period. Pitch variations at the beginning and end of voicing can be detected.
ACKNOWLEDGMENTS
Thanks to all the people who helped either directly or indirectly, during the design, construction, debugging, and testing of the DSP Pitch detector:
John Clark, Robert Mannell, John Telec, Mark Stevens, and Juanita Russel.