UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

Warnsis ii : A warning signal identification system for the hard of hearing 1995

You don't seem to have a PDF reader installed, try download the pdf

Item Metadata

Download

Media
ubc_1995-0214.pdf [ 5.92MB ]
Metadata
JSON: 1.0064798.json
JSON-LD: 1.0064798+ld.json
RDF/XML (Pretty): 1.0064798.xml
RDF/JSON: 1.0064798+rdf.json
Turtle: 1.0064798+rdf-turtle.txt
N-Triples: 1.0064798+rdf-ntriples.txt
Citation
1.0064798.ris

Full Text

WARNSIS II A WARNING SIGNAL IDENTIFICATION SYSTEM FOR THE HARD OF HEARING Kim Dotto, P.Eng. B.Sc. University of British Columbia, 1979 BA.Sc. University of British Columbia, 1982 A THESIS SUBMITTED IN PARTIAL FULFILMENT OF T H E REQUIREMENTS FOR THE DEGREE OF MASTER OF APPLIED SCIENCE in T H E F A C U L T Y OF GRADUATE STUDIES DEPARTMENT OF ELECTRICAL ENGINEERING We accept this thesis as conforming to the requirecr-SFandard T H E UNIVERSITY OF BRITISH COLUMBIA March 22 1995 © Kim Dotto, P.Eng., 1995 In presenting this thesis in partial fulfilment of the requirements for an advanced degree at the University of British Columbia, I agree that the Library shall make it freely available for reference and study. I further agree that permission for extensive copying of this thesis for scholarly purposes may be granted by the head of my department or by his or her representatives. It is understood that copying or publication of this thesis for financial gain shall not be allowed without my written permission. Department of The University of British Columbia Vancouver, Canada Date DE-6 (2/88) Abstract Having examined a number of common warning signals such a telephone rings, microwave oven alarms and continuous tone alarms, a software method, eliminating the need for specialized hardware, was developed for both recognizing known warning signals and learning new signals. The method, called WARNSIS II was first implemented on a PC-compatible computer using a Creative Labs signal acquisition board which provided a base for graphical signal analysis and for the development of algorithms. The algorithms were also implemented on the Texas Instruments TMS320C30 Evaluation Module (EVM) digital signal processing board to demonstrate that the algorithms can be easily ported to smaller, more cost effective platforms. The WARNSIS II system operates in two modes: learning and recognition. In the learning mode a template for a signal is constructed by analysing the signal for spectral and temporal information. The frequency at which the maximum peak in the signal's spectral energy occurs is determined and this value is saved in a template. The duration of the signal burst, as well as the interval time between signal bursts for repetitive signals, are determined and are also saved in the template. In the recognition mode, the spectrum of the incoming real-time signal is analysed to determine if any of its spectral components match those found in the template. If a match is found, timing information is then applied to rule out transients which would generate false alarms The system has demonstrated the ability to recognize warning signals in high background noise environments and to correctly identify multiple overlapping warning signals. ii Table of Contents Abstract " List of Tables • • vi List of Figures vii List of Abbreviations viii Acknowledgement i x 1.0 Introduction 1 1.1 Background 1 1.1.1 Threshold Detectors 2 1.1.2 Hard-wired / Dedicated Devices 3 1.1.3 Hearing Ear Dogs 5 2.0 The WARNSIS Project 6 2.1 WARNSIS I 7 2.1.1 WARNSIS I Recognition Scheme 8 2.1.2 Evaluation of WARNSIS I 10 2.1.2.1 Recognition Scheme 10 2.1.2.2 Hardware Implementation 12 2.2 WARNSIS II Objectives 12 iii 3.0 Sound and Signal Recognition Schemes 13 3.1 Speech Recognition Schemes 13 3.1.1 Dynamic Time Warping 13 3.1.2 Hidden Markov Modelling 14 3.2 Warning Signal Characteristics vs Voice/Word Characteristics 15 4.0 Spectral Analysis Methods 22 4.1 WARNSIS II Spectral Analysis 23 4.1.1 Fast Fourier Transform . . . . 2 4 4.1.1.1 FFT and Spectral Power Estimation 26 4:1.1.2 Data Windowing 28 4.1.1.3 Maximum Entropy Method 31 4.1.2 Discrete Hartley Transform 33 4.1.3 Discrete Cosine Transform 34 4.1.4 Finite and Infinite Impulse Response Filters 34 4.1.5 Wavelet Transform 35 4.2 Evaluation of Computational Methods for Spectral Analysis 37 5.0 WARNSIS II Design 38 5.1 Overview 38 5.2 Learning Mode 38 5.3 Recognition Mode 43 6.0 WARNSIS II Implementation and Evaluation 55 6.1 PC Based System 55 6.1.1 Results of PC Based Implementation 57 iv 6.1.2 Other Results 67 6.1.2.1 8 Bit vs 16 Bit Digitization 68 6.1.2.2 FFT Size, Frequency Resolution and Sampling Rate . . . 69 6.1.2.3 Sampling Window Effects 70 6.1.2.4 Speed Considerations 71 6.2 TMS320C30 Based System 76 6.2.1 Program Size 78 6.2.2 Results of DSP Based Implementation 78 6.2.2.1 Performance Measurements 79 7.0 Conclusions and Recommendations 88 7.1 Future Work . 89 7.1.1 Improved Learning Mode 90 7.1.2 Improved Recognition Mode 91 7.1.3 Additional Features 91 7.2 Other Applications 92 References 94 Appendices 97 Appendix-A WARNSIS IITMS320C30 Assembly Language Code 97 v List of Tables 6.1 Single Warning Signal vs Noise Sound Level Measurements 84 6.2 Dual Warning Signal vs Noise Sound Level Measurements 85 vi List of Figures 3.1 "Hello" Spectral Analysis 17 3.2 Electronic Ringing Signal Spectral Analysis 18 3.3 Mechanical Ringing Signal Spectral Analysis 19 3.4 Microwave Alarm Signal Spectral Analysis 20 4.1 FFT Bit Reversal Recombination 27 4.2 Parzen, Welch & Hanning Window Functions 30 4.3 Leakage for Parzen, Welch & Hanning Window Functions 32 5.1 Short Time Average Absolute Amplitude (STAAA) for Burst Determination 40 5.2 Flowchart for WARNSIS II Learning Mode Algorithm 44 5.3 Typical Warning and Noise Signal Power Spectra 48 5.4 Flowchart for WARNSIS II Recognition Mode Algorithm 54 6.1 Results of Learning Mode for Electronic Telephone Ringing Signal. . . . 58 6.2 Composite and Individual Warning Signal Analyses 61 6.3 Effect of Sampling Window Function on Power Leakage 72 6.4 Effect of Sampling Window Function, Background Noise Power Spectrum 74 6.5 Performance Test Measurement Setup 80 6.6 Panasonic PD-2300 Electronic Ringing Signal Spectral Analysis 81 6.7 2200Hz Continuous Tone Spectral Analysis 82 6.8 Test Background Noise Spectral Analysis 86 6.9 Combined Warning Signal A and B Spectral Analysis 87 vii List of Abbreviations AIC Analog Interface Circuit DAT Dynamic Amplitude Threshold DCT Discrete Cosine Transform DFT Discrete Fourier Transform DHT Discrete Hartley Transform DSP Digital Signal Processor DST Discrete Sine Transform DTW Dynamic Time Warping E V M Evaluation Module FFT Fast Fourier Transform FHT Fast Hartley Transform H M M Hidden Markov Modelling M B D Minimum Burst Duration M E M Maximum Entropy Method MIAT Maximum Inter-Arrival Time PC Personal Computer STAAA Short Time Average Absolute Amplitude STFT Short Time Fourier Transform V O C Creative Voice File WARNSIS - Warning Signal Identification System WT Wavelet Transform Acknowledgement I would like to thank my supervisor, Dr. C A . Laszlo for his encouragement and advice during this project, and for his belief in my abilities from the start which allowed my to undertake this project. I would also like to thank my wife Patricia for her support and understanding and my children, Alexander and Laura for their unending diversion. This project was funded by NSERC Operating Grant OGP0006701 ix Chapter 1 1.0 Introduction 1.1 Background In everyday life we are constantly bombarded with information about our environment. Although humans are visually oriented, much of the important information, that which requires immediate attention, is transmitted by sound. Warning sounds such bells and buzzers are part of our everyday life both waking and asleep. Unlike visual information, which is not processed while asleep, auditory information is processed by the ear and brain continuously. Approximately eight percent of the general population suffers from some level of hearing impairment. Approximately 70 out of every 1000 people are "hard of hearing", another 6 out of every 1000 are classified as late deafened adults, and 1 out of every 1000 are deaf [1,2]. Hard of hearing people are those who use speech as their main method of communication but have some impairment in their ability to hear. Such impairment may range from mild to profound. Late-deafened adults are those who have suddenly become deaf later in life usually due to accident, illness or medication related causes. This group still uses speech, but also must rely on speech reading or written aids such as transcription to understand what others say. Some late deafened adults also sign as a means of communication. People who are deaf from birth usually use signing as their main method of communication. Signing is a distinct language apart from any written or spoken language and promotes an independent culture just as the use of English or French does for speakers of those languages. Those who consider themselves to belong to this cultural group define themselves as Deaf. There are also Oral Deaf people, people who have been deaf from birth or an early age but have been taught to speak, rather than sign as their main method of communication. They may also rely on sign 1 Chapter 1 - Introduction occasionally but they rely on speech and speech reading as their main methods of communication. Members of all groups are placed at various levels of disadvantage by their hearing loss, depending on the environment or situation. Such disadvantage can even be life-threatening, such as failing to hear a smoke detector, fire or burglar alarm. Even missing a phone call can have serious consequences. To help overcome this disadvantage many devices and approaches have been designed in the past to alert a Deaf or hard of hearing person to the presence of specific warning sounds. These fall into 3 main categories, threshold detectors, hard-wired or dedicated devices and hearing ear dogs[3]. 1.1.1 Threshold Detectors Most warning signals are designed to be heard above a general ambient noise level and, as such, are louder than most other sounds that one might encounter in a given environment. Threshold detectors function by exploiting this fact. They are designed to detect any increase in sound amplitude over a preset limit or set point. This can work reasonably well in an isolated environment where the device is required to identify a single warning sound. It can also be useful when multiple warning signals need to be monitored and all that is required is to alert the user that one of them has occurred without being specific as to which one. One of the main drawbacks of threshold detectors, however, is that sounds which are louder than the preset limit but originate from sources other than the alarm or alert will also trigger the detector, giving a false positive indication. For example, a threshold detector set to detect a telephone ring may be erroneously triggered by a doorbell or a fire alarm or even the passage of a noisy truck. 2 Chapter 1 - Introduction Another disadvantage of a threshold detector is the need for adjustment when moving it from one location to another. If the detector were set to function correctly when in the same room as the telephone, the amplitude of the sound that reaches the detector if the user moves it to a different room may not be loud enough to trigger the detector. Adjusting the set point to a lower value may not be possible due to a greater ambient noise levels in the new location. The detector would then give a number of false positives that would render the device virtually useless. Threshold detectors have been designed to operate on signal sources other than sound. For example, detectors for magnetic fields emitted by telephones exist, but the detectors must be located very near the telephone in order to pick up the relatively weak fields generated. This greatly reduces the range and effectiveness of such devices. Additionally, many newer telephones do not use electro-mechanical ringers and therefore generate no detectable magnetic fields. 1.1.2 Hard-wired / Dedicated Devices Hard-wired or dedicated devices can overcome many of the problems found with the threshold detection devices described above. Hard-wired devices are electrically, and often mechanically, connected to the device they are designed to detect. The signalling device may also be hard-wired, although radio-operated remote pagers which use lights or vibration to signal the wearer are becoming popular [4]. For the telephone, rather than listening for an increase in ambient noise level, the detector is electrically connected to the telephone and monitors the incoming ringing signal from the telephone exchange. When the ringing signal is detected, the device signals the user by triggering the pager or flashing a lamp on and off. 3 Chapter 1 - Introduction There are three main disadvantages to this method: i) a separate detector is required for each device that is being monitored; ii) installation requirements can be prohibitive; and iii) the devices lack portability. The detectors for these types of devices are usually designed for a specific piece or type of equipment. For example, it is unlikely that a telephone detector would be suitable for connection to a door bell. In addition, many devices that a hard of hearing person would like to monitor, such as a microwave oven or smoke detector do not have commercially available detectors. In those cases where a suitable specific detector is available, its installation may require expert assistance, or modification of the monitored equipment. This is both inconvenient and expensive for the user and can be hazardous should the installation be done incorrectly. Lack of portability is a major drawback for the user with hard-wired devices. People are more mobile now than any time in the past and travel away from the home or office is much more common than ever before. For some jobs, especially at higher levels of responsibility, it is a major requirement of the job. Lack of mobility for the hard of hearing person can be a major impediment to career advancement. Business is more often conducted by phone and facsimile these days than by personal meeting. When travelling, the hard of hearing person will not be able to modify all, if any, of the devices that they would normally rely on at home with hard-wired detectors. Even a simple change of office or building could require significant time and expense to set up. 4 Chapter 1 - Introduction 1.1.3 Hearing Ear Dogs Like Seeing-Eye-Dogs, Hearing-Ear-Dogs are available for all hearing impaired people. These dogs are very useful, but they are also quite valuable and in short supply. It takes many months of training to prepare a dog and a reasonable "training" period for the recipient as well. In addition, dogs require regular "refresher" training. As training is a lengthy and difficult process, it is often not possible or practical to update the animals skills once the have been placed with the hearing impaired owner. In addition, just as for Seeing-Eye-Dogs, not all hearing impaired people would be able to utilize such a dog. The hard of hearing person may not physically be able to care for a dog due to age or other disabilities or they may not wish to own a dog. A dog may not be suitable for other reasons such as living arrangements and there is increased cost and difficulties involved in the transportation of the dog when travelling. 5 Chapter 2 2.0 The WARNSIS Project The objective of the WARNSIS (WARNmg Signal identification System) project is to develop a device that would overcome the problems and deficiencies noted with the devices and solutions described previously. As such, the device: i) would be required to reliably recognize warning sounds for hard of hearing and deaf people in the presence of background noise, such as radio music, conversation and machinery; ii) must be portable and not require any special connections to the warning signal generating sources; iii) must have the ability to not only discriminate between different signals sources but must also have the ability to easily learn and recognize previously unknown signals. In addition, it is an explicit long-term objective of the project to minimize the cost of manufacture in order to make the device accessible to as many users as possible. There have been attempts previously to design devices with these capabilities in the past [5,6], but these devices have suffered from limitations in their abilities to learn a wide variety of signals or to discriminate between signals with similar timing and spectral characteristics. 6 Chapter 2 - The WARNSIS Project 2.1 WARNSIS I To date there have been two phases of the WARNSIS project. In the initial phase of the WARNSIS project (WARNSIS I) much of the study was devoted to the characterization of the various types of warning signals in everyday life. WARNSIS I also produced an initial prototype device. In WARNSIS I it was determined that the majority of signals that the device would encounter fell into two categories: i) either single or repetitive burst signals ( such as telephone rings ); ii) continuous signals (such as produced by fire alarms and smoke detectors). It was also found that the warning signals examined in the study had at least one characteristic frequency or main harmonic above 900 Hz and below 5000 Hz [7]. Ambient noise was also characterized to be broad band with most of its spectra energy below a frequency of 300 Hz. This is common, as ambient noise in the usual office and home environments is generated by machinery such as fans and passing automobiles. The frequency range between 300 Hz and 900 Hz was found to possess both noise and signal components. Most notably, warning signals from automobile horns (electric) and truck horns (air) fell into this category with their dominant frequencies in the 300 Hz to 500 Hz range. The human voice possesses energy at frequencies both inside and outside this range but most of the energy in the human voice is contained within this frequency range. The human voice rises about 5 dB from its base value in the range from 100 Hz to 600 Hz and then falls by approximately 6 dB, 9 dB, 12 dB and 15 dB in succeeding higher octaves [8]. 7 Chapter 2 - The WARNSIS Project The general recommendation for the design of warning devices is that such a device should be capable of producing an output sound level pressure (SPL) of at least 85 dB (with reference to 20 u Pa) at a distance of 10 ft from the device [9]. Additionally the warning signal should be at least 10 dBA SPL above the ambient noise level for warning devices in the home environment or 15 dBA SPL for those in public places [10]. This is a difficult condition to satisfy in real environments as most warning devices are preset at the time of manufacture or installation but the ambient noise levels where the device are used tend to vary with time. 2.1.1 WARNSIS I Recognition Scheme The WARNSIS I recognition scheme relied on a two-part analysis [7]. The first part of the analysis was a timing analysis, the second was a spectral analysis. A signal was "recognized" only if both parts of the analysis were successful. In WARNSIS I, the timing analysis was performed first in order to speed processing. This was significant, because processing power was limited by the microprocessors available in the market at that time (1986-88). The timing analyser included the following three processes: i) the Dynamic Amplitude Threshold (DAT), ii) the Minimum Burst Duration (MBD), iii) the Maximum Inter-Arrival Time (MIAT). The purpose of the DAT process was to identify a signal that may be of "interest" in order to start the recognition process. The DAT process continuously monitored the input signal level and updated a threshold level. If the input signal amplitude increased to twice the threshold level, a "signal of interest" was assumed to be present. The threshold was 8 Chapter 2 - The WARNSIS Project continuously updated by averaging the previous threshold with the incoming signal amplitude. The threshold thus tracked an increase or decrease in the ambient noise level. The MBD process was used to filter spurious burst noises before they reached the later recognition steps. The timing analyser monitored the incoming signal and measured the amount of time the input signal strength was above the threshold. If the MBD was less than a preset value the signal was ignored. If the MBD was longer than the preset limit a "valid" signal was assumed. If the MBD was longer than 4 seconds a continuous warning sound was assumed, if the signal was less than 4 seconds but longer than the preset minimum, a repetitive signal was assumed. For repetitive signals the MIAT process was used to determine if the signal was in fact repetitive or a collection of random noise bursts of duration longer than the MBD. If two burst occurred in a time period less that the MIAT they were considered to belong to the same warning signal occurrence. If they occurred outside the MIAT they were considered to have been produced by separate warning events. The timing analysis was followed by spectral analysis to determine if the identified burst was a valid signal. The spectral analyser was based on a NEC chip set designed to perform Dynamic Time Warping speech analysis and was implemented via an NEC //PD7761 and //PD7762 Pattern Matching Processor and Controller combination. The input signal was analysed by passing it through an eight frequency range filter bank and extracting the average energy contained in each of the eight frequency ranges between 100 Hz and 5000 Hz. The spectral analysis was then performed by comparing the output from these eight filters with pre- stored templates. If the output pattern from the filters matched one of the pre-stored templates, the signal was then considered to be validated and a warning to the user was issued. Similar filter bank approaches have been tried by other researchers as well [11]. 9 Chapter 2 - The WARNSIS Project 2.1.2 Evaluation of WARNSIS I 2.1.2.1 Recognition Scheme Although the two part system combining a timing analyser and spectral analyser seemed to give satisfactory results in low background noise cases, it produced a relatively higher number of false alarms in noisy environments and failed to detect a number of key signals. In fact, experience has shown that the failure of the device to recognize key signals in noisy environments was due to the sequence of the two-part timing and spectral analysis scheme . In particular, as already noted, in WARNSIS I, the MBD detection process, used to determine if a burst was a warning signal or a transient, was applied before the spectral analysis to determine if the signal was worth examining. This meant that timing, not spectral energy content, was the main feature that the device detected. This, in combination with the MIAT measurement, caused the device to fail to detect repetitive signals in noisy environments. The original WARNSIS I device would identify a signal burst and then wait for the second in a series of supposed repetitive bursts. If a noise burst (or other warning signal) occurred during the waiting period, the original signal would be rejected because the M B D or MIAT did not match the template value. The spectral content of the intermediate burst was not examined, so there was no way for the device to differentiate if the intermediate burst was a true signal burst or if it was simply due to noise. In an attempt to streamline processing, the original recognition scheme included three other compromises that made its real world use unsatisfactory. Firstly, the WARNSIS I device required at least one repetition to identify a repetitive signal. Since there is no guarantee in the real world that a repetitive signal will repeat, such signals should be identified on the basis of 10 Chapter 2 - The WARNSIS Project a single appearance. For example, in an emergency situation the warning device could be damaged before giving the second warning burst or the phone, or the postman, "may only ring once". Thus, this recognition scheme would ignore the original burst since it detected no repetitions. Secondly, the WARNSIS I recognition scheme based its initial signal determination on the increase in the average total signal amplitude (energy). This meant that from the time the beginning of a signal burst was identified, until the time that signal burst ended, the device could not recognize other warning signals. Thus, if a noise burst occurred and triggered the timing functions before a true signal burst occurred, the signal burst would be completely ignored, or added into the noise bursts timing. Also, if the device was monitoring a valid signal and another valid signal occurred, overlapping with the first, the second signal's timing characteristics would again be added to the first and neither signal would be successfully detected. This could quite easily occur in an office environment where a number of phones could ring simultaneously. Rather than giving a false positive, as would be the case for the threshold detector, the device would give no indication of any activity at all. Lastly, although the DAT function successfully tracked the increase in ambient noise level to prevent false positives, this actually had the effect of "deafening" the device in high noise environments. For the start of a burst to be detected, an increase of twice the threshold limit was required. As the ambient noise level would rise, the threshold would rise. However, the absolute amplitude of the warning signal, such as the telephone ringer volume, would remain the same. Thus, the detection requirement of twice the threshold limit could not be met by the warning signal at high ambient noise levels. 11 Chapter 2 - The WARNSIS Project 2.1.2.2 Hardware Implementation The WARNSIS I system consisted of approximately 80 components including 4 microprocessors and a number of specialty NEC spectral analysis chips. Given the level of complexity of the hardware, multiple processors, specialty chip sets, and the requirement of an additional PC to coordinate the overall function of the device, it would have been impossible to turn the prototype into a practical device due to reliability and price considerations. However, the WARNSIS I project determined that it was possible to detect and recognize warning sounds in real time, and although the design of the device had several shortcomings, the WARNSIS I project provided the basis for the evaluation of the usefulness of the timing and spectral information in the detection of this class of signals. 2.2 WARNSIS H Objectives Given the above analysis of WARNSIS I, the objectives of WARNSIS II are: 1. Redefine the detection and recognition algorithms to improve the performance in noisy environments and overcome the deficiencies in the original scheme; 2. Reduce the hardware requirements so that a viable, cost effective production device can be made. 3. Produce a system that is both easily learned and used by the end user 4. Produce a system that can be easily maintained and upgraded in the manufacturing environment. 5. Provide an overall system design, from both a hardware and software perspective, including support tools for further development and commercialization of the project. 12 Chapter 3 3.0 Sound and Signal Recognition Schemes Currently most speech recognition systems are based on one of two basic mathematical models: Dynamic Time Warping (DTW) [12,13,14] or Hidden Markov Modelling (HMM)[12,13,15]. Both of these approaches are statistically based and are used because of the need to allow for the variations in speech that occur for the same word or words when spoken by various speakers or the same speaker at various times. 3.1 Speech Recognition Schemes 3.1.1 Dynamic Time Warping Dynamic Time Warping is a useful technique when matching spectral patterns between a known signal (template) and a unknown incoming signal, which may contain timing differences. When a signal is" learned" and a template is created, the incoming signal is divided into smaller time segments. For each of these time segments a spectral analysis of the incoming signal is performed by a filter bank. The number of outputs from the filter bank depends on the spectral resolution required (For example: for WARNSIS I, this was eight outputs covering a frequency range between 100 Hz and 5000 Hz). The outputs from the filter bank give an estimation of the energy content in the spectral region covered by each of the filters in the bank. The outputs from these filters are stored in the templates for each time segment created during the learning process. During the recognition process, the incoming signal is again divided into smaller time segments and the same spectral analysis is performed by the filter banks. For each time segment the output from the filter bank for the incoming signal is compared to the values stored 13 Chapter 3 - Sound and Signal Recognition Schemes in the templates. If the output and template values match within a set of statistical parameters a match is indicated for that particular time segment. The "Dynamic Time Warping" comes into effect by allowing for the misalignment of time segments. For example, if we wish to be able to recognize the word "hat", we would first analyse the voice of a speaker saying the word "hat". The length of time to say the word "hat" during the learning process may be 10 milliseconds and the learning process would divide this into 50 time segments. During the recognition phase, the speaker would again repeat the word "hat". However, because of changes in intonation and emphasis, which are normal during the speaking process, the new occurrence of the word hat may take 15 milliseconds to say. The analysis process would divide this occurrence into 75 time segments. Since there can not be an exact one to one correspondence between the original 50 segments stored in the template and the newly acquired 75 segments, allowances for time "slippage" must be made. The allowance for slippage is achieved by "Dynamic Time Warping". A more complete mathematical model for DTW can be found in the literature and will not be repeated here [13]. 3.1.2 Hidden Markov Modelling Hidden Markov Modelling is a statistical method which also models the variations in the way a speaker pronounces a word. Each word is divided into states and a probabilistic determination is made on the likelihood of transitions from one state to another. The states in a typical application are generated by filtering and digitizing the input signal, then segmenting it into smaller overlapping blocks which are fit to a linear predictive coding model [13]. Once this has been done a template is created for each word or sound that must be recognized and the incoming signal is analysed and compared to the pre-existing templates. However because the H M M is a statistically based process, the templates must be built from a number of repetitions by the speaker during the learning process [13]. For a given word to be learned 14 Chapter 3 - Sound and Signal Recognition Schemes it may require 40 or more repetitions of the word to be spoken in order to produce a template which accurately maps the possible state transitions [16]. Although there are differences between the DTW and H M M methods, good implementations of either of the two processes can result in good speech recognition systems. The trade offs between the two methods come from the decreased learning time require for the D T W method versus the shorter processing time required for the H M M method. D T W algorithms are computationally expensive, since each incoming signal pattern must be compared to those stored in all of the templates [12]. 3.2 Warning Signal Characteristics vs Voice/Word Characteristics The two methods described above have been designed to learn and recognize human speech. This is a much more complicated process than what is required for the recognition of warning sounds. Human speech is not uniform between speakers or even for the same speaker. It is formed by the interaction of the vocal cords, the pharynx, mouth, nose and sinus cavities. The tongue, teeth and lips also interact to produce the sounds we recognize as speech. The same word will sound different depending on its use, the mood of the speaker and even the time of day. Warning sounds, on the other hand, are mechanically generated and must remain relatively constant in frequency composition and duration over their lifetime in order to perform their intended function. For example, phone rings are recognized throughout Canada and the United States regardless of geographical location because their frequency and timing characteristics are held within narrow limits. The warning sounds generated by other equipment also have characteristics which, in general, do not change significantly, if at all, after installation. Figure 3.1 shows the spectrum for three occurrences of the word "hello", spoken 15 Chapter 3 - Sound and Signal Recognition Schemes by the same speaker. Figures 3.2 through 3.4 shows the spectrum for a number of electronically and mechanically generated warning signals. These graphs show why the learning and recognition processes for warning sounds should be much less complex than those for speech, and why the methods such as DTW and HMM, although well suited to speech recognition, are not the ideal processes for warning sound recognition. The warning signals shown in Figures 3.2 through 3.4 have characteristic peaks that remain well defined and constant in frequency. They also have burst and interval durations that remain constant in time. From examining these graphs it is possible design a warning signal recognition algorithm. In order to detect a warning signal we must correctly identify the three characteristic features of the signal. For all warning signals, the first feature, the signals characteristic peak frequency, must be detected. Next we must identify the timing characteristics of the signal. For burst type signals, the burst duration must be determined and if the signal is of repetitive burst type, the interval time between bursts. Should a warning signal be of the continuous type, then we must determine if the signal we are detecting is actually continuous or simply due to noise by ensuring that the signal is detected for a long enough time period. The third characteristic of a signal is its energy content. Additional information about a warning signal is conveyed by the amount of energy contained in the signal. A louder signal is, in general, considered to be more urgent or important than a softer one. This is a matter of perception, and is highly dependent upon the surrounding environment since "loudness" is usually compared to some arbitrary background noise level. Often just the presence of an increase in sound level can be enough to alert us that something has occurred. 16 Chapter 3 - Sound and Signal Recognition Schemes 1.00 - i © 0.80 H iiii|itii!iiii1iiii]iiji|iirit«iii|rii<iiiti|jiiJiiiiir<)t*[i)>itii*tl'i''l<iii|tiiiiiiiiiii)iiiiii|ifii| ® 0.20 0.00 ' | ' i '' | ' ' " | " ' ' | '' ' ' | ' '" | ' ' ' ' | " ' ' |' ' ' ' | ' " 1 I 1 1 " I " " I" " I !1 " I " 1i |Tii 1  i i i i | 1  i i 11 1000 2000 3000 4000 5000 Relative F F T Peak Intensity (0 - 5000 Hz) frequency (Hz) Figure 3.1 - "Hello" Spectral Analysis 17 Chapter 3 - Sound and Signal Recognition Schemes <D 1.00 •o 0.75 - B 0.50 - c 0.25 - g> 0.00 - 3 -0.25 - _ -0.50 - r? "0-75 - 0 1 -1.00 -> 6178 msec Relative Magnitude vs Time time 1.00 - i © 0.80 0.60 - | cn 5 0.40 ® 0.20 H 0.00 itiiiiiit]iirijiiii|tiii|iiif|ipit|ttii|tiii|fiitjfiif[iitt|tttt|(tii|itii|iiii|fiiijittt|iiii|iiii|iiii|ii'i ......... j | ,T>l|ll ll | l l^ | l , . , | .rn |l^h|., .r | . . l . |i . . T . . i |„.. r TT,,| 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 -j. ® 0.80 - ••§ 0.60 - cn I 0.40 - ® 0.20 - |IIII|IIII|IIII|UII|MII|4--U I I I l| I I I I |l I I I | I II I | 11 II | 11 I I |l 11 I | II I I | I III | I I I l| I I I I | II I I | I II I 11 I I l| I I II | 0.00 1593 Hz Average Peak Intensity i.*iArsiA i h • i::. 17 ,7, j,|.',>i|n n|i|^,|,,,, vA^n[ n.r,,,,.,... n . . . . ( . . . . r . . , , , , , , ̂ ss 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) Figure 3.2 - Electronic Ringing Signal Spectral Analysis 18 Chapter 3 - Sound and Signal Recognition Schemes <D 1.00 •o 0.75 B 0.50 k 0 25 g» 0.00 § -0.25 - -0.50 -I £ -0.75 -A -1.00 - 1 Relative Magnitude vs Time 1.00 - i i i | i i i i | i i i i , i i i i , i i i i | i i i i , , , j , , , , , , ( , I M , l l M | l l l l | I M l | l l l l | P I I I M l l l | M l l I l l l l | l M l | | | I l | l l ^ 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 © 0.80 H "§ 0.60 H O) ^ 0.40 H ® 0.20 0.00 l l l l | l l l l | M I I | l l l l | | l | , , , , , I H ^ I M , I M I j l l l | j M M I l l l | | ) | | , j | | | | ( l | I | | t ( | I | | , | | | | t l | | | | | | ^ 1658 Hz "'I1'"!""!""!"1' 1000 Average Peak Intensity PJ. .TTTI, , , , , , .,,,,,, i"" r~TT-irrT 7rr77t,,7r T7777 T7rrT^ 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) Figure 3.3 - Mechanical Ringing Signal Spectral Analysis 19 Chapter 3 - Sound and Signal Recognition Schemes o> 1.00 •o 0.75 H 3 0.50 0-25 g> 0.00 5 "025 -J - -0.50 H f? - ° - 7 5 ^ -1.00 616 msec 1281 msec '•lIKJIiMIHIn'Jl' time Relative Magnitude vs Time 1.00 - i © 0.80 • | 0.60 H 5 0.40 ® 0.20 H 0.00 [tit|itii|itri|tiii|ir[f|iiti|iiti|iiiigtiii]iiitjifii|Tiii|ftit|riii|iiii|titi|iiii|tii«jiiit|iiii|ii«ijiiitj |iin,.ii.,...,Tnii|ii li|..ii| i,|,iM,,i,r 1000 2000 3000 4000 Relative FFT Peak Intensity (0 - 5000 Hz) 5000 frequency (Hz) 1.00 © 0.80 f: 0.60 O) ^ 0.40 ® 0.20 0.00 [»• > f F t r 1111 r i j 11111111 r j J 11 j 11111 j i i—»11  F 1111111 j 111111111 [ 1111 j 1111 j 1111 j i i 1111111 j 11 j 111 j 11 j 11111 •»i • 1981 Hz Average Peak Intensity .[....!••..,. .|. i . , . . . 11 i I. , . . . . . . . . . . . . . | n - , . . ,., . . . . . . . . . . . . . . , ,[,,,, | 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) Figure 3.4 - Microwave Alarm Signal Spectral Analysis 20 Chapter 3 - Sound and Signal Recognition Schemes This leads us to a 3-part analysis scheme for our recognition algorithm, one part for spectral analysis, a second for timing analysis and a third for energy content analysis. The important question here is: in what order do we perform these analyses? Although frequency , timing and energy characteristics are important, which is most important for recognizing a warning signal? When a telephone initially begins to ring, one is alerted to that fact by the presence of the ringing sound. Before the ringing burst finishes, it can be determined that a telephone call is incoming. If one is unsure that the telephone actually rang, one can wait for the burst to end or a second burst to repeat for confirmation. It is, however, the presence of the characteristic ringing frequency, where there was none before, that gives the first alert. Similarly, in an office or home, if two closely placed different phones ring simultaneously, the only way to tell them apart is by the different sound of the two ringers. Even for an unknown warning signal, it is often the presence of a new spectral component in the background noise that gives the warning. When a component of a vehicle breaks down, there is often a new "sound" to the vehicle that is a direct result of the fault. For example, should a bearing wear out, it is often accompanied by a screeching sound. One may not have heard the sound before, but it is immediately obvious that something has happened. It would appear that a significant amount of information required to recognize a warning signal is contained in the spectral and energy characteristics of the signal. Also, although additional information is contained in the timing characteristics of a warning signal, those characteristics would appear to be secondary. For these reasons, for WARNSIS II, we shall approach our algorithmic design with the intention of performing the spectral and energy analyses first. 21 Chapter 4 4.0 Spectral Analysis Methods For WARNSIS II, it was decided to implement as much of the analysis as possible, including the spectral analysis, in software. The reasons for this are three-fold. First, by relying on software for as much of the recognition scheme as possible, the overall chip count for the device can be minimized. This allows for lower overall cost for both design and manufacture. By reducing the number of chips or specialty chip sets, both the number of parts and the overall size of the board can be reduced. This in turn will also lower assembly and testing costs. By reducing the parts count the time required to design and layout the circuit is also greatly reduced. Eliminating the use of specialty chips is important. The use of specialty chips would limit the functionality and flexibility of the device because, should improvements to the recognition algorithm be developed in the future, they would not be easy to incorporate into the existing hardware. With software, this is not problem. Secondly, implementing WARNSIS U in software means that large economies of scale can be applied to the production of the final device. With no specific hardware requirements, any commercially available platform with enough processing power could be used. For example, a PC sound card with production volumes of millions of units per year could be used as the basis for implementing some versions of the WARNSIS II system. Lastly, although the WARNSIS II project is intended to produce a design which can be implemented as a stand-alone device, the functionality of the WARNSIS II recognition scheme could provide useful features to be incorporated into other devices such as medical monitoring equipment. A software approach makes this "generalization" much easier. 22 Chapter 4 - Spectral Analysis Methods 4.1 WARNSIS II Spectral Analysis For WARNSIS II we propose to perform the spectral analysis via a computational method. There are a number of reasons for this approach. First, by using a computational method, such as the Fast Fourier Transform (FFT), the number of frequency ranges and the total frequency range covered can be adjusted by software on an individual signal or implementation basis. This allows for a multilevel spectral analysis, if required. For example, an incoming signal could first be examined for energy content above or below a given value in order to reduce the search path and execution time. Alternatively, the FFT approach would allow for finer or coarser frequency determinations in changing noise environments. The use of a computational spectral analysis method also allows for some type of noise cancellation. The spectra for the templates obtained during training of the device are likely to be obtained in the "best" conditions available. This could mean no, low or modest noise environments, depending on where the signal was "learned". The spectra of signals detected in the real world are likely to have a large noise content. Noise cancellation on both training and analysis would give the cleanest signal both for the templates and for comparison, and should improve the ability of our scheme to recognize a signal in noisy environments. There are a number of computational frequency analysis methods in addition to the FFT, mentioned above, which can be used for spectral analysis. Other computational methods such as the Wavelet, Hartley and Cosine transforms, and Finite and Infinite Impulse Response filters (FIR and IIR) are available. These will be compared in the following sections to determine which method best fits the WARNSIS II requirements. 23 Chapter 4 - Spectral Analysis Methods 4.1.1 Fast Fourier Transform [17,18,19,20,21] The FFT, first popularized by J.W. Cooley and J.W. Tukey in 1965 [18,21], is currently one of the most common and successful methods for performing spectral analysis on digitized data. Suppose we a sample a continuous function of time h(t) so that we have N consecutive values, where N is even, with a sampling interval of A. K s > h > k = °>l>2> - > N~l If we are attempting to find the Fourier transform for this function, then having N input values we can produce no more than N independent output values. This means that we can I = , n = - — , . . . , — - — = — (4.2) J n /VA 2 2 2 2 obtain estimates only for those frequencies at discrete values or bins. We approximate the Fourier integral by the sum + 0° 7V-1 N-\ „) = fhWe2**''* - Y,hke2lttf'''A = A Y.K^iknm ( The final summation in equation (4.3) above is known as the Discrete Fourier Transform (DFT). The DFT requires N 2 complex multiplications and is an 0(N2) process. Using the 24 Chapter 4 - Spectral Analysis Methods FFT algorithm, the Discrete Fourier Transform can be calculated on the order of 0(Nlog2N), which is an enormous difference. The FFT is derived as: (N/2)- 1 (N/2)- 1 £ e2*tkQj)iN j Q j ) + e 2 n i k { 2 j + X ) I N f(2j + \) 7=0 7=0 (N/2)- 1 (N/2)- 1 7=0 7=0 f + wk F ° where W k = e''1™ , sometimes referred to as the "twiddle factor" " F k denotes ftte k component of the Fourier transform of length N/2 formed from the even components of the original fl]) and Fk° is the corresponding transform of length N/2 formed from the odd components. The fact that this formula can be used recursively means that, for transforms for which N is an integral power of 2, it can be repeatedly broken down until we have only to calculate transforms of length 1. A Fourier transform of length 1 is simply the identity operation that copies it input value to its output slot or bin. This means that every length 1 transform in the series corresponds to one of the input values. The correct input value can be determined by bit reversing the index j for the original function. If you take the original data sequence and rearrange it so that the values are in order not of j, but in order of the numbers obtained by reversing the bits of j written as a binary number, you have the correct relation between the inputs and the length one transforms. For example, if j=3 for a length 8 transform then the correct output bin for the length one transform would be given by: j = 4 1 0 = 1002 yielding bin # = 0012 = 110 (4.5) 25 Chapter 4 - Spectral Analysis Methods From this it is a simple matter of calculating the combined transforms of size 2, 4, N in recursive stages. Figure 4.1 shows a length 8 transform being bit reversed and then recombined. 4.1.1.1 FFT and Spectral Power Estimation [19] Since we are trying to determine if a signal being analysed by WARNSIS II has a spectral component at a given frequency, we are interested in the energy content of a signal at that frequency. This means that rather than using the Fourier Transform itself, as we would if we were required to perform a cross-correlation with a second signal, we require only the signal's power spectrum. This can be done using the FFT. Rather than matching the power at a particular frequency fk that would be obtained from calculating the continuous Fourier transform, the power given by the FFT is an "average" or expected value for the frequency bin centred at fk extending over a narrow window . Historically this has been called a periodogram. For an N-point sample of a function c(t) using the FFT 7Y-1 ce iTZijkIN k = 0,...,N-l (4.6) the periodogram estimate of the power spectrum is defined as 1 P(0) =/Vo) = —AC{ J_ N2 L C, + 1 c N-k N/2 N * = l , 2 , . . . , ( i l - l ) (4.7) 26 Chapter 4 - Spectral Analysis Methods Figure 4.1 - FFT Bit Reversal Recombination 27 Chapter 4 - Spectral Analysis Methods where fk is defined only for the zero and positive frequencies k (4. For the periodogram defined above, the narrow window over which the average is taken, as a function of 5 the frequency offset in bins, is described by This window has side lobes that contribute significant amount of "leakage" a number of bins away. 4.1.1.2 Data Windowing Performing a Fourier transform on a given function of time assumes an infinite sequence of input values for the integral. The FFT, which is used for discrete data, is always performed on a sample size somewhat less than this. By performing an FFT on a finite sample size we are in effect convoluting an "infinite" sequence with a square window function which is 0 except during the finite sampling time. The overall effect of the finite sample is to cause "leakage" in the power spectrum from the true frequency to other frequencies a number of bins away as described above. The "leakage" can be substantial even at frequencies a large number of bins away from the frequency of interest because the square window function, in effect, turns on and off instantaneously. 1 sin (re s) 2 W{s) = /V2 I sin(TLs/7V) (4.9) 2 8 Chapter 4 - Spectral Analysis Methods To overcome this leakage problem it is possible to modify the sampling window function by multiplying the input signal data Cj, j - 0, ... N- l by a windowing function w. There have been a number of alternative window functions proposed [19]: the Parzen window, w. - 1 -j ( 4 . 1 0 ) the Welch window, w. = 1 -j ( 4 . 1 1 ) and the Hanning window, w. = — J 2 COS ( - ) N-l ( 4 . 1 2 ) Each of these window functions is shown in Figure 4.2 [19]. The effect that each of the windowing functions have on the "leakage" between bins is different. These effects are usually given "figures of merit" that can be used to describe the narrowness of the peaks. The tradeoff between different window functions is between the narrowness of the peak and the fall off of the tails. In general it is recommended, that if a windowing function is required, the 29 Chapter 4 - Spectral Analysis Methods Bin Number (0 to 255) Figure 4.2 - Parzen, Welch & Parzen Window Functions 30 Chapter 4 - Spectral Analysis Methods Parzen or Welch windows be used. The larger computational effort required for the cosine function in the Hanning window gives minimal additional value [19]. Figure 4.3 shows the effects of the three windowing functions in comparison to the square sampling window [19]. 4.1.1.3 Maximum Entropy Method [19,32] As stated earlier, when performing a spectral analysis using the FFT there is a relationship between the number of samples that must be used to produce a given frequency resolution for a given sampling rate. The finer the frequency resolution, the larger the number of samples that must be considered. This can lead to prohibitively large sample sizes which can consume large amounts of memory while processing. The Maximum Entropy Method (MEM) [19,32] for power spectrum estimation allows one to perform a parametric (model based) spectral analysis which will provide a better frequency resolution for a smaller sample size. The M E M is an auto-regressive method which characterizes a known signal in terms of a finite number of poles that best represents its spectrum in the complex plane. The MEM can produce a better spectral resolution for a smaller number of samples than the standard FFT methods. The M E M does, however, have a few disadvantages. Firstly, it exhibits line splitting at high signal to noise ratios. Secondly, at higher orders the M E M can introduce spurious peaks. Thirdly, for sinusoidal signals in noise, which would encompass a large number of the warning signals of interest to a WARNSIS device, there is a frequency shift in the signals spectrum that is dependant on the initial phase of the signal which we are trying to recognize. For these reasons and because the M E M requires extra computational effort to calculate the parametric coefficients, this method was not used for WARNSIS II. 31 Chapter 4 - Spectral Analysis Methods Offset (in Frequency Bins) Figure 4.3 - Leakage for Parzen, Welch & Hanning Window Functions Chapter 4 - Spectral Analysis Methods 4.1.2 Discrete Hartley Transform [17,22,23] The Discrete Hartley Transform (DHT) is applicable to real valued signals and is closely related to the FFT, in fact the DHT and the FFT can be derived from each other . The DHT is defined as: N - l H(K) = 5Zx(n)cos(27Tkn/N) + x(n)sin(2Ttkn/N) k = 0,...,N-l (4.13) n=0 N - l x(n) = 1/N SH(k)cos(27ikn /N)+H(k)sin(2Tckn /N) k = 0,...,N-l (4.14) k=0 where x(n) is the real valued sequence. There have been a number of claims that the Fast Hartley Transform (FHT) implementation of the DHT is more efficient than the real-valued FFT for computing the power spectrum for real-valued sequences with N =2P. The two most recent comparisons of the two methods have concluded that the FFT is in fact a more computationally efficient algorithm [22,23]. The time required for computing the FFT vs the time required for computing the DHT give a ratio of processing times of 1:1.04 for a size 512 transform [24]. For the TMS320C30 processor used in WARNSIS II, the ratio of processing time between implementations of the FFT and DHT on the same signal processor is approximately 1:1.98 in favour of the FFT which is a significant difference [17]. 33 Chapter 4 - Spectral Analysis Methods 4.1.3 Discrete Cosine Transform [17,19,24] The Discreet Cosine Transforms (DCT) also arises from the FFT. The DCT is given by: N - l . F(K) = x(n) cos(xck n / N) k = 0,..., N - l (4.15) n=0 where x(n) is the real valued sequence. Although the DCT appears to be simply the real part of the Fourier Transform, it differs by a factor of 2. The DCT and Discrete Sine Transforms (DST) are more useful when applied to boundary value problems than for generating the power spectrum information that we require. Although new, more efficient, direct computation algorithms have been proposed for the DCT and DST [24], the FFT is still superior for our purposes. The ratio of processing time for implementations of both the FFT and DCT on the TMS320C30 signal processor is approximately 1:1.91 in favour of the FFT for a size 512 transform [17]. 4.1.4 Finite and Infinite Impulse Response Filters [17,19,20] Rather than using the FFT or other similar transform, it is possible to duplicate the process used in WARNSIS I where the frequency spectrum was divided into 8 ranges by the filter bank by the use of linear digital filters. If we assume that the signal x(n) is applied to a bank of complex filters with impulse response h^expfjco^) where (j\ is the centre frequency of any filter, and h(n) is the response of an ideal lowpass filter with bandwidth u>h. If the real part of the filter output is squared, doubled and bandlimited to 2<oh, then the resulting analysis is the same as the square of the magnitude of the Short-Time Fourier Transform of x(n) for 20^ <|co k|< Tt-2wh[20]. 34 Chapter 4 - Spectral Analysis Methods The generic linear filter is formed by taking the sequence of inputs x„ and producing a series of outputs yn such that M N k=0 7=1 where q and dj are fixed coefficients which define the filter response. If N=0 so that the second sum does not contribute to the filter response, then the filter is said to be non-recursive or a finite impulse response filter (FUR). If N<>0 then the filter produces a response from not only the current input values but from its own previous output as well. In this case the filter is said to be recursive or an infinite impulse response filter (IIR). The main drawback of using these methods is in the calculation of the coefficients. There are a number of methods for calculating the coefficients q and dj depending on whether one is implementing an FIR or IIR. The Remez Exchange Algorithm produces the best Chebyshev approximation for a fixed number of filter coefficients for an FIR and one useful technique for ITR's is the bilinear transformation method [19]. The drawback is that all of the methods for calculating the coefficients require large amounts of processing time. This would then require WARNSIS II to use higher speed and higher cost processors to implement the spectral analysis component of the WARNSIS II algorithm. A second drawback of the filter approach is that even though new IIR algorithms are available for tracking sinusoidal signals in noisy environments, the algorithms all exhibit "rather erratic" convergence behaviour [25]. 4.1.5 Wavelet Transform [26,27,28] The Wavelet Transform (WT) is an alternative time-frequency representation that can 35 Chapter 4 - Spectral Analysis Methods be used for spectral analysis. The time-frequency version of the WT is defined as where y(t) is the "analysing wavelet" and is a real or complex bandpass function centred around time t=0 and f0 is the centre frequency of y(t) [26,28]. In principle the wavelet transform and the Fourier transform are very similar in their approach to time-frequency representation, as both can be represented as inner products. In fact the WT is just a special case of the generalized STFT [27]. There are two essential differences between the wavelet and Fourier transforms. The first is the choice of a linear time-shift/frequency-shift operator for the Fourier transform versus a time-scaling/time-shift operator for the wavelet transform. The second is that the equivalent y(0 function for the Fourier transform is a lowpass function instead of a bandpass function for the wavelet transform. Both transforms suffer from similar time-frequency resolution limits. Thus, neither transform can provide arbitrarily good time resolution and frequency resolution simultaneously. For example using the Fourier transform with a given sampling rate, if one wishes to increase the frequency resolution of the power spectrum, one must increase the number of samples taken, thus producing a power spectrum covering a longer time period. However, the Fourier and Wavelet Transforms are different regarding their time-frequency resolution in ways which are important for the WARNSIS II algorithm. In particular, for the Fourier Transform the time-frequency resolution is the same for all frequencies. For the Wavelet Transform, however, the time-frequency resolution is not constant, higher frequencies are analysed with better time resolution, but with poorer frequency resolution [28]. This is unacceptable for the WARNSIS II algorithm since it is essentially the higher frequencies that are of interest. The (4.17) 36 Chapter 4 - Spectral Analysis Methods time-frequency resolution should be constant over the entire frequency range of interest since we have no way of predicting a priori which frequencies will be relevant when the device is actually in use. 4.2 Evaluation of Computational Methods for Spectral Analysis The FFT approach to frequency analysis was chosen over the WT for the reasons explained above. The FFT is also preferred to the Hartley, and Cosine Transforms and the FIR and IIR filter methods because of the time comparison factors as discussed in sections 5.1.2, 5.1.3 and 5.1.4, as well as other reasons. Firstly, the FFT is one of the best understood computational methods and optimized code for performing the FFT is available for most computer languages and systems available on the market today. Also, because of its popularity, many of the "off-the-shelf signal processing chips are architecturally designed to exploit fast addressing schemes which provide for a further increase in FFT processing speed. Additionally, further speed increases can be gained by exploiting specialized implementations of the FFT algorithm which are known as RADIX-2 or RADIX-4 versions. When the number of input values for the FFT is n 2 or n 4 then the FFT processing speed can be increased by reducing the number of stages used. Also for the WARNSIS II algorithm we are digitizing real signals, hence the input to the FFT routines will be real values with no complex parts. This allows us to take advantage of the ability to double the FFT processing speed by substituting real values for complex values in the input array. The FIR and IIR methods were not considered as the number of filter banks required to implement a fine enough frequency resolution would be computationally prohibitive. 37 Chapter 5 5.0 WARNSIS n Design 5.1 Overview The WARNSIS II warning sound recognition system is a set of software algorithms which can be implemented on any hardware platform with sufficient processing power to perform the required real-time FFT analysis and template matching algorithms. The system consists of a number of functional modules which allow the WARNSIS II system to operate in two modes: learning mode and signal recognition mode. In the learning mode, a template for a warning signal is "learned" by analyzing the signal for spectral and temporal information. The frequency(s) at which the maximum peak(s) in the signal's spectral energy occur are determined and these values are saved in a template. Timing information, specifically, the duration of a warning signal burst and the interval time between warning signal bursts (for repetitive signals such as telephone rings) are determined and also saved in the template. In the recognition mode, the spectrum of the incoming real time signal is continuously analysed. The analysis determines if any of the incoming signal's spectral components match those stored in one of the "learned" templates. If a spectral match is found, timing information is then applied to rule out transients which could generate false alarms. 5.2 Learning Mode As stated earlier, the drawbacks of the devices commercially available today are their lack of flexibility causing difficulties when moving from one location to another and their lack of the ability to accommodate new types of warning signals. To overcome these deficiencies a WARNSIS II device must include the capability for the automatic "learning" of a new signal. 38 Chapter 5 - WARNSIS II Design When the learning mode is entered, a signal learning algorithm begins. The input signal is continuously monitored until an increase in the Short Time Average Absolute Amplitude (STAAA) is found. The STAAA is calculated by averaging the absolute value of the input amplitude over a period of 512 samples (63.9 ms at 8,012 Hz sampling rate). This is sufficient to eliminate short noise bursts which would interfere with the second stage of the signal detection algorithm. When the learning mode is first entered a sample of the background sound level is taken and its STAAA is calculated. This level then becomes the value against which all later STAAA's are compared in order to determine if an increase in signal amplitude due to a warning signal has occurred. If a future STAAA is greater than 1.5 times the background level value then a valid amplitude increase has been detected. To actually detect the beginning of a valid signal, the signal acquisition algorithm requires that two consecutive STAAA's 1.5 times greater than the background level be detected. If a valid STAAA is detected, but the next STAAA fails to exceed 1.5 times the background value, then the first STAAA is ignored. This differs from the original WARNSIS I algorithm in that there is no Dynamic Amplitude Threshold (DAT) and that two consecutive valid STAAA's are required to initiate the learning process. Although this algorithm would be affected by an overall increase in ambient noise levels, causing it to falsely detect the start of a warning signal, it should be possible in most cases to "learn" a signal in a low noise environment. For example, it is possible to lower the ambient noise level in a home or office for a short period of time by temporarily eliminating the noise sources. Figure 5.1 shows the learning mode process described above. 39 Chapter 5 - WARNSIS II Design 1.00 0.75 0.50 0.25 0.00 0.25 — -0.50 r? "° 7 5 ^ -1.00 CO 2286 msec 6088 msec time Relative Magnitude vs Time Single STAAA Below Minimum Level Not Detected As Burst End Point Minimum STAAA Level time Short Time Average Absolute Amplitude (STAAA) vs Time Figure 5.1 - Short Time Average Absolute Amplitude (STAAA) for Burst Determination 40 Chapter 5 - WARNSIS II Design Once two consecutive STAAA's have been detected, the signal acquisition algorithm sets the start of valid signal flag and begins the spectral analysis. The spectral analysis at this stage of the learning process is performed by continuously calculating the FFT on the incoming signal in 512 sample intervals. As each set of 512 samples are collected the FFT is processed and the magnitude of the FFT for each bin in the power spectrum is calculated and added to the total sum of all magnitudes calculated for each bin from all of the previous 512 sample interval since the start of the warning signals acquisition. This process continues until the warning signal is "lost". The signal is lost if two consecutive STAAA's fail to exceed 1.5 times the background STAAA value. If a single STAAA fails to exceed the background STAAA limit but the STAAA from the next 512 sample interval does exceed it, then the signal is not lost. Once the warning signal has been lost, the spectral analysis is ended, the FFT magnitude sum is preserved and the warning signal burst duration is calculated as the time from the detection of the first of the two initial STAAA's to the time of the first of the two consecutive STAAA failures. Monitoring of the input signal continues until one of two events happens. If two new consecutive STAAA's above the background value are detected before the learning mode "times out", then a valid signal repetition is deemed to have been detected and the signal interval time is calculated as the time from the detection of the first of the two initial STAAA's at the beginning of the initial burst to the time of the first of the two consecutive STAAA at the beginning of the repetition. If a repetition is detected then the learning mode signal acquisition phase ends. Alternately, if no repetitive burst is noted before the learning mode times out (after approximately 30 seconds) the signal acquisition phase is ended anyway. If the learning mode times out while the signal is still being acquired then a continuous signal, such as that from a smoke detector, is deemed to have been detected. 41 Chapter 5 - WARNSIS II Design Once the signal acquisition phase ends and the burst duration and interval have been determined, the FFT magnitude sum is examined to determine the main spectral peak(s). The centre frequency for the bin which has the greatest magnitude sum among those bins for frequencies above 900 Hz is deemed to be the dominant spectral peak for the acquired signal. The peak is detected by an algorithm similar to the algorithm used for detecting the beginning and end of the signal during the signal acquisition phase. The FFT magnitudes are examined and the start of a peak is determined by two consecutive increases in FFT magnitude when compared with the previous adjacent FFT bin magnitude. There is no preset value for the peak increases to exceed as it is only the increase that is relevant, not the absolute value of the increase. As peak detection proceeds, the FFT magnitude values are compared for each bin within a peak. The maximum magnitude found for each peak during this examination process is saved as the peak maximum. The bin number corresponding to the maximum magnitude found is taken as the centre frequency of the peak. Peak detection continues until the peak maximum is detected, again this is determined by two consecutive decreases in FFT magnitude for adjacent bins. The "down slope" of the peak is monitored until the FFT magnitude exhibits either two more consecutive increases, indicating the start of another peak, or two consecutive equal magnitudes, indicating the "bottom" of the peak. The width, centre frequency and maximum magnitude are thus determined for each peak in the FFT magnitude spectral sum. Once the entire spectrum has been scanned and all peaks have been identified, the characteristic peak for the warning signal is determined to be the peak with the greatest peak magnitude. The maximum peak magnitude is used, rather than the peak "area", as warning signals tend to have narrow peaks and noise tends to be broad band covering a larger number of bins. A noise peak may contain more total energy than a warning signal peak, but that energy is spread over a greater frequency range for the noise peak than for the signal peak. 42 Chapter 5 - WARNSIS II Design The warning signal is thus characterised by three attributes: i) a characteristic peak frequency (bin number), ii) burst duration time iii) burst interval time (if required). The peak magnitude and width are not currently used for signal recognition and are not stored in the learned warning signal's template. Figure 5.2 shows the flowchart for the generalized WARNSIS II learning algorithm. 5.3 Recognition Mode The recognition mode in WARNSIS II operates much in the same manner as learning mode, except that, rather than simply using amplitude increases and decreases for identifying the beginning and ending of signal bursts, it is the presence or absence of a signal's characteristic peak frequency that determines the beginning and ending of a burst. While operating in recognition mode, the input is continuously monitored and the FFT of the incoming signal is continuously calculated in the same 512 sample size intervals as for the learning mode. It is important that the same sample size and sampling rate be used for both the learning mode and the recognition mode as changing the sample size or sampling rate changes both the size and centre frequency of the bins. Once the FFT has been calculated for a 512 sample interval, rather than summing the FFT's output for an extended period as in the 43 Chapter 5 - WARNSIS II Design Enter Learning Mode Sample Background Level Calculate Background " p T A A A Collect Next 512 Sample's Calculate Current " i T A A A Y e s Y e s Is This •pecond Consecutive J b T A A A Failure?,, Y e s Calculate B u r s t Duration Hna 1 Character ist ic Peak And 'bave In Template Y e s Learning Mode H a s Timed Out Without Identifying Any Warning Signal " i ta r t B u r s t Timer Calculate F F T and "jum Calculate Interval Time And ' iave in Template Exit Learning Mode Find Character ist ic Peak 'se t Du rs t Duration to Indicate Continous Signal Y e s 'bave Template h"fo: Character ist ic Peak Durs t Duration N o Interval Time t Figure 5.2 - Flowchart for WARNSIS II Learning Mode Algorithm 44 Chapter 5 - WARNSIS II Design learning mode, the spectral analysis is performed on the individual 512 sample intervals. As each 512 sample segment is processed, all peaks present in that time interval's spectrum are identified using exactly the same peak detection algorithm as was used in the learning mode. Each peak above 900 Hz present in the current segment's spectrum that is greater in magnitude than a minimum limit and that is also greater in magnitude than 25% of the magnitude of the largest peak is compared to the characteristic peak frequencies stored in the templates for the various signals that have been learned. The input signal's peak magnitudes are compared to both a preset minimum peak energy value and the 25% limit in order to eliminate false peak detection. Since the energy content in the background signal at frequencies above 900 Hz is generally due to transients and higher harmonics, the magnitude of these peaks are generally lower than those for true warning signals. By only looking at the significant peaks in the spectrum we can eliminate the peaks due to transients. Transient signals are eliminated by this method because signals that are of short time duration with respect to the sampling period, and are of limited power do not contribute as much to the power spectrum as do longer duration, higher intensity signals. The WARNSIS II algorithm is only interested in the spectrum above 900 Hz and takes no account of any spectral components below 900 Hz. This means that if no warning signal is present, the spectrum of the incoming signal above 900 Hz will be filled with peaks generated by the background noise. Since there will be no large magnitude peak due to a warning signal, the largest peak above 900 Hz will belong to the background noise spectrum and the 25% limit will be set relative to the background noise. This means that noise peaks would then be considered as possible candidates for recognition. 45 Chapter 5 - WARNSIS II Design The 900Hz lower frequency limit and 25% magnitude limit were chosen by examining the frequency spectrum from a number of digitized background samples. It was found that in almost all cases the magnitude of peaks in the frequency spectrum decreased significantly at frequencies greater than 900 Hz and that, in general, noise peaks above 900 Hz had magnitudes less than 25% of the magnitude of the signals that we were examining. These are not fixed limits. Since these values as well as all other limits for the WARNSIS II algorithms are set in the software, different implementations of WARNSIS II could use different limits. To overcome this problem WARNSIS II uses a 2-part level analysis. In addition to ignoring peaks which are less than 25% of the maximum peak detected, WARNSIS II, as stated earlier, also ignores any peak which is lower in magnitude than a preset minimum value. By only "acknowledging" peaks with at least a minimum energy content we can eliminate those which do not contain energy substantially above the background level. This is more effective than using a total signal amplitude threshold approach since in a typical noisy environment that the device may be used, most of the background noise signal's total energy is generated by voices, radio or television broadcasts and will be found below 900 Hz. This 2-part analysis allows a warning signal to be successfully detected by its characteristic frequency peak even in a very noisy environment. There is one drawback to this 2-part analysis method. If two warning signals occur at the same time, the peak magnitudes will be normalized with respect to the stronger signal. If one of those signals is significantly weaker than the other, so that the weaker signal's peak does not exceed the 25% threshold, the detection of the weaker signal would be suppressed. This means that a signal with a fixed magnitude may not be detected in the presence of a significantly stronger warning signal, even though it would be successfully detected if it 46 Chapter 5 - WARNSIS II Design occurred by itself. However, this is the case for the human ear as well, a ringing telephone at a given volume will be detected above the general office or home background noise level, but not above the ring of a fire alarm bell. Figure 5.3 (a) and (b) show the power spectrum for typical warning signals (in this case a microwave oven alarm (a) and a mechanical telephone ringer (b)). Figure 5.3 (c) shows the power spectrum for typical background speech and music. For each figure, the top graph shows the digitized input signal's magnitude vs time. The second graph in each figure shows the relative magnitude between peaks for the complete power spectrum for the input signal from 0 to 5000 Hz. The third graph in each figure shows the relative magnitude for those peaks in the power spectrum above 900 Hz. As can be seen from figure 5.3 (a) the majority of the spectral energy content in the warning signal is in the range above 900 Hz. Notice the narrowness of the characteristic peak and the lack of secondary peaks. This is common for warning signals that are generated electronically. Warning signals generated mechanically, such as the ring of a telephone bell, generally show a slightly broader characteristic peak as well as multiple harmonic peaks as shown in figure 5.3 (b). For the general background noise case shown in figure 5.3 (c), in this example F M rock music and voices, although there are secondary peaks at frequencies above 900 Hz, most of the energy content and the main peaks in the power spectrum are at frequencies well below the 900 Hz range. The third graph of figure 5.3 (c) shows why, if we selectively look only at those peaks in the power spectrum above 900 Hz, we require the preset minimum limit for peak detection. When the low frequency energy content is eliminated from the peak detection process, the 47 Chapter 5 - WARNSIS II Design <D 1.00 —I •D 0.75 - \ 3 0.50 £ 0-25 g» 0.00 5 -0.25 -i _ -0.50 ® -0.75 0 1 -1.00 616 msec 1281 msec Relative Magnitude vs Time time -00 t • • • • | i i i i | i i i i | i i i t | f i i f | i i i i | t i i i ' | j i i i | i i i f | i t i i | i t i f | i i i i j i i i i | i i i i | i i i i j i i i i | i i i i | i i l l . | i t i t | t t ( f | i i i i | i i ( i | © 0.80 =| 0.60 - | O) g 0.40 - \ ® 0.20 H 0.00 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 - i © 0.80 - \ • | 0.60 H | 0.40- ® 0.20 - 0.00 M l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l • l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l | | H | l | l l l l | I I U | l l l l | 1981 Hz Average Peak Intensity ' ' ' I "'•'I'"" I"" I | , , , | , , , , , , , , , ,|. 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) (a) Microwave Oven Alarm Spectral Analysis Figure 5.3 - Typical Warning and Noise Signal Power Spectra 48 Chapter 5 - WARNSIS II Design © 1.00 - i •D 0.75 H 3 0.50 - \ c 0.25 g» 0.00 5 -0.25 H _ -0.50 H S -0.75 -1.00 Relative Magnitude vs Time 1.00 - | © 0.80 - j =| 0.60 cn 2 0.40 © 0.20 or i i i | u i i | M i i | i n i | i i i i | i n i | i i i i | i i i i | i i i i | i i u | n i i | i i i i | i i i i | i i i i | i i i i | i i i i | i i i i | n H | M i i | i i n | i n i | i i i i | 0.00 A . A - 1000 2000 3000 4000 Relative FFT Peak Intensity (0 - 5000 Hz) 5000 frequency (Hz) 1.00 © 0.80 - \ % 0.60 cn 2 0.40 H © 0 20 or II 11111 ti 11 II i | 11111 II 11 ("'HH"' > " | " 1 1 1 ' 1 |*M • i M 1 1 1 1 1 • • | ' 1 1 1 1 " " I"" 111 " I " 1 1 1 , M 1 1 1 " 1 1 " "1 1 1 1 11 o.oo 1658 Hz Average Peak Intensity 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) (b) Mechanical Telephone Ringer Spectral Analysis Figure 5.3 - Typical Warning and Noise Signal Power Spectra 4 9 Chapter 5 - WARNSIS II Design < D 1.00 - i •o 0.75 - 2 0.50 - c 0.25 - §» 0.00 5 -0.25 H _ -0.50 - S -0.75 - -1.00 - 1 time Relative Magnitude vs Time 1.00 © 0.20 0.00 i n i | l l l ! | l l l l | l ! l l | l l l l | l l l l | l l l l | l l l l | M I I | I M I | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l ! i i . . ! . . . . ! . • . . ( • i • 11 •• i • ! . •• • I. i • .[ . • • • | . • • H • •• • ! . • I • • • . [• • • • I •• • • t • i •• l • • i •) • i • • I •• • • I • • p i • H • • I 'I I 1000 2000 3000 4000 Relative FFT Peak Intensity (0 - 5000 Hz) 5000 frequency (Hz) 1.00 - i © 0.80 ••§ 0.60 CJ) £ 0.40 © 0.20 0.00 11111 II 11111 II 1111 II 11111 II 1111 II 11111 ij 1111 | i 11111 II I I II I III I II I I I I II II I I l l l l I I I II I I I I I II I I I I III I I I I II I I I I | Average Peak Intensity i • ' i ' • i " ' " i " ' • i •• • • i • •• • i • • " i • • • ' i " • • i • 1 " i ' 1 " i 1 1 1 • i " 1 1 1 " " i " " i 1 1 " i " " i " " i " ' 1 1 1 1 1 ' i 1 " 1 1 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) (c) Typical Background Noise (FM Rock Music & Voices) Spectral Analysis Figure 5.3 - Typical Warning and Noise Signal Power Spectra 50 Chapter 5 - WARNSIS II Design relatively minor noise peaks become dominant in the high frequency power spectrum. This could lead to erroneous spectral matches. These matches are not likely cause warnings to be issued to the user since a particular noise spectrum is unlikely to persist long enough to match the timing criteria of the timing analyser. However, by eliminating the noise peaks at this stage, we can increase the overall processing speed of the WARNSIS II algorithm. In the recognition mode, if one of the detected peaks in the input signal's spectrum matches the characteristic peak of one of the learned signals in one of the templates, then a signal match is deemed to have been made for that template. For the recognition mode acquisition algorithm, as for the learning mode signal acquisition algorithm, two consecutive signal matches are required in order to determine if a "candidate" warning signal has been identified. A "candidate" signal is one for which further spectral and timing analyses shall be performed to determine if indeed an actual warning signal has been successfully detected. Unlike in the learning mode, however, in the recognition mode, a warning signal's candidacy is based on energy content at its characteristic frequencies and not on total energy (amplitude) increases. Once the "candidate" signal is associated with a given template, the start-of-burst indicator flag is set and the burst start time is recorded. The WARNSIS II algorithm uses multiple templates, one for each learned signal, and each template has its own set of timing records and flags. Thus, it is possible for WARNSIS II to identify multiple warning signals overlapping in time. Provided that the characteristic peak of each of the different warning signals in the input to WARNSIS II are at a different frequencies, and that each of the warning signals in the input possesses enough energy to meet the minimum energy (magnitude) criteria stated earlier, the peak for each individual warning signal in the combined signal will be detected by the algorithm. 51 Chapter 5 - WARNSIS II Design Once a warning signal's candidacy has been determined, that is a spectral template match has been found, the burst duration timer is kept running until the warning signal's peak is no longer detected (lost). In the recognition mode, losing the signal requires two consecutive absences of the given warning signal's characteristic peak in the input signal. Once the signal is lost, the burst duration is calculated as it was in the learning mode, from the time of detection of the first of the two initial matches between the input signal's spectral peaks and the warning signals characteristic peak stored in the template to the time of the first of the two consecutive peak losses. At this point a determination can be made as to whether a spectral and burst timing match can be made between the input signal and a previously learned signal whose characteristics are saved in the template. A "match" between an incoming signal and a template requires both the spectral characteristics and the burst duration timing of the input signal match the corresponding template values within pre-defined limits. In particular, the burst duration comparison algorithm allows a burst duration match to fall within a time window of variable length. From examining the variation in a number of real input signals, it was determined that the input signal's burst duration need only match the template values within +/- 10%. This means that the detected burst can be up to ten percent longer or ten percent shorter than the value stored in the template. Similarly, the spectral peak comparison algorithm was determined to require a tolerance of +/-1 frequency bin (+/-15.6 Hz for 512 sample intervals @ 8012 HZ) in order to successfully match a peak from the input signal to a characteristic peak in a template. Both tolerances can be defined on either a template to template basis or as an overall tolerance limit for WARNSIS II and, as for all other WARNSIS II limits, can be changed on an implementation to implementation basis. If both the timing and spectral characteristics have been matched between the input signal and one of the learned warning signal templates, a burst recognition flag is set indicating a valid burst match for that warning signal. 52 Chapter 5 - WARNSIS II Design For continuous signals, the burst duration must only be longer than the minimum burst duration that is stored in the template, rather than actual burst duration. If WARNSIS II is trying to recognize a continuous signal, once the minimum burst duration is exceeded a continuous recognition flag is set. For a continuous signal, the recognition flag can be maintained for the duration of the signal, or it can be cancelled automatically after some period of time and re-issued if the warning signal remains on long enough to exceed the minimum burst duration a second or third time. WARNSIS II also has the ability to further validate repetitive signals such as telephone rings by waiting for a second occurrence of the warning signal to appear. When in the learning mode, we assume that the second increase in amplitude indicates a second signal burst. In the recognition mode, WARNSIS II requires a second complete burst to occur before it can attempt to match the interval times of the incoming signal with that of the template's. Rather than just waiting for a second burst to start, the entire second burst must occur and match the same timing and spectral characteristics as the first. This means that noise bursts, as well as intervening signals from other valid warning devices will not affect the interval timer. The interval timer also allows a +/-10% variation in interval time between the input signal and the warning signals template value for a valid match to occur. If an interval timing match is found an interval recognition flag is set. The use of the various recognition flags will depend on the implementation of WARNSIS II in an actual device. In some cases a notification to the user that a warning signal has been detected could be issued, in others the recognition flag may be used to trigger further processes in an existing medical device. Figure 5.4 shows the flowchart for the generalized WARNSIS II recognition algorithm. The DSP code for both the learning and recognition modes can be found in Appendix A. 53 Chapter 5 - WARNSIS II Design Enter Recognition Mode Collect : Next 512 Samples -^Calcu la te F F T Power 'jpectruttj Find Peaks in Spectrum Over q O O H z ' " Figure 5.4 - Flowchart for WARNSIS II Recognition Mode algorithm 54 Chapter 6 6.0 WARNSIS H Implementation and Evaluation The WARNSIS II project has resulted in two separate implementations of the WARNSIS II algorithms. Much of the initial design and testing was performed on a PC as a MS-Windows compatible program. This allowed for rapid modification and testing of the algorithms as well as providing a rich graphical environment for displaying and analyzing results. Once the basic algorithms had been designed, the system was then implemented on a Texas Instruments TMS320C30 Digital Signal Processing Evaluation Board. This provided the platform for testing the algorithms in real-time on a lower cost system. Finally the two implementations were integrated to allow PC control of the algorithms operating on the DSP board. 6.1 PC Based System The PC version of the WARNSIS II algorithms were written in Turbo Pascal for Windows Version 1.5 to run under Microsoft Windows on any IBM compatible PC system. In addition to performing the WARNSIS II algorithms, the PC based program also provided a number of additional routines that were used to display and analyse digitized input signals. This was very useful in the early stage of development and lead directly to the development of a number of the WARNSIS II algorithms. By visually examining the digitized signals and their Fourier transforms, it was possible to determine what features made the warning signals distinct from other types of input signals. Indeed, many of the WARNSIS II algorithms are implementations of the pattern recognition "routines", such as picking out distinct peaks from the background, that were originally performed visually. 55 Chapter 6 - WARNSIS II Implementation and Evaluation The PC based system also provides a "toolbox" environment for testing and refinement of new algorithms in the future. As new types of recognition algorithms are designed they can easily be added in a modular fashion to the existing PC program and then tested. This helps to meet one of the objectives of the WARNSIS II project, namely to provide a method for easily maintaining and upgrading the WARNSIS II system. To allow the maximum flexibility of the PC-based system, again rather than relying on an implementation specific format, digitized signals are input to the WARNSIS II program in VOC format. This is a standard PC format originally created by Creative Labs for their "Sound Blaster" series of signal processing boards. This allows any PC based sound acquisition board to function as the input system for a PC-based WARNSIS II system. For this portion of the project a Creative Labs Sound Blaster16 was used to provide the digitized input signals. Using the standard VOC file format and a non-specific input device also provides two other useful features for WARNSIS II development. Since the V O C format provides for the storage of input signals in digital format as a file, new algorithms can be tested against existing digitized signals. This means that comparison of the new algorithms can be made against existing algorithms on the same signal. Even the best quality tape recordings will deteriorate over time whereas the digitized files can be used over and over. The second advantage comes from the ability to use VOC files from any source. If a test of a specific warning signal is required, a V O C file for the warning signal can be easily sent via modem or network from a remote location. 56 Chapter 6 - WARNSIS II Implementation and Evaluation 6.1.1 Results of PC Based Implementation Figure 6.1 (a) and (b) show an example of the results of the WARNSIS II learning mode algorithms. The top graph shows the input signal amplitude versus time for approximately 6.33 seconds of telephone ringing signal generated by an electronic, rather than mechanical bell, ringer. The entire first burst of the telephone ringing signal is shown, but only the beginning of the second ringing burst is shown as learning mode does not require the entire second burst for interval determination. Additionally, the top graph shows vertical lines indicating the beginning and end of the first burst and the beginning of the second burst calculated by the STAAA method. The burst duration and interval times calculated using the STAAA method for this signal were found to be 2.189 seconds and 6.178 seconds respectively which is in agreement with the telephone standards [29]. The middle graph shows the overall FFT power spectrum for the input signal for the time period between the vertical lines indicating the start and end of the first ringing burst. As stated earlier, this is the combined power spectrum totalling each of the FFT magnitudes calculated for the 46 individual 512 sample FFTs performed during the burst. The bottom graph shows the combined power spectrum for frequencies above 900 Hz and also shows the peaks in the power spectrum identified by learning mode. The small vertical lines at the bottom of each peak show the width of the peak as detected by the peak detection algorithm as well as the centre frequency for each peak, shown by the small vertical line at the top of the peak. The characteristic peak is highlighted at the top of the third graph by a horizontal line showing the width of the characteristic peak. Although, at present, the width of the characteristic peak is not used in recognition mode (nor calculated in the DSP version), it is included as a feature in the PC version of the learning mode in order to supply more spectral information when 57 Chapter 6 - WARNSIS II Implementation and Evaluation © 1.00 - i •o 0.75 -3 0.50 - "c 0.25 g> 0.00 5 -0.25 _ -0.50 - r? -0.75 - 0 1 -1.00 - 1 6178 msec time Relative Magnitude vs Time 1.00 - i CD 5 0.40 H ® 0.20 H i f i i ] f i f i | i i i i | i i i i | i i i i j t f i i | i B i i | i i i i | f i f i | i i i i | i i i i | r t i i | t i i i ] i f t t | i i i i | r i i i | i i ( i | i r i i | i i i i j f i j i | i i f i | i t i t | n i ' ' i i i i i ' i i i ' M i i ' M ' ' ' M ' ' ' M ' ' ? M ' ' i M i i ^ i i i ' M ' r t V ^ i , i ' n ' ' , M i ' ' n ' ' i M ' i ' ' f i ' i M , ' ' i i ^ , , ' i 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 - © 0.80 - fz 0.60 Jj 0.40 - ® 0.20 - 0.00 • • i i f i > i i j t i i i | t i i i | i t t i | r i i i j-t-i-t-i- | i i J i | i t i i f i t t i | i i i i | t i i i | i i i i j i i i i j i i i f | i i i i | i i i i | i i i i | i i i i | i i i f | i t i i | i i i i j 1593 Hz Average Peak Intensity ' i " " i " " i " * ' i , , ' l r " , r , " i " ' w , r i l " " l 1000 2000 3000 ^ T | , " l r ' ^ > T f ' ^ , l " " , l " " r " T " ' i " " f . . . i f s ^ j 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) Figure 6.1 (a)- Results of Learning Mode for Electronic Telephone Ringing Signal 58 Chapter 6 - WARNSIS II Implementation and Evaluation 1.00 - i <D • o C cn (0 0.80 H <D 0.60 0.40 H 0.20 o.oo l 'l 11111111111111111 j 111111111 |_L1JLL j > 1 < < | • • ' • (< < > • | • • 1111 (1111111111111 M 111111111111 {1111 f 111 f 1111111111 p 1 11 1593 Hz 1000 2000 Average Peak Intensity • I •' '• I" •" I I rQ-rn 11 ITTT, 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) Figure 6.1 (b) - Results of Learning Mode Electronic Telephone Ringing 59 Chapter 6 - WARNSIS II Implementation and Evaluation developing new algorithms. For the telephone ringing signal shown in this set of graphs, the characteristic peak frequency was determined to be 1,593 Hz with a width of 275 Hz from 1,458 Hz to 1733 Hz. The centre frequency is in close agreement with the frequency of 1575 Hz measured by oscilloscope and is within the accuracy limits for the FFT at the sample rate of 11,025 Hz and 512 samples. The horizontal line near the bottom of this graph shows the average peak power above 900 Hz and again is shown as a development "tool" rather than as one of the parameters for signal recognition. Figure 6.2 (a) shows graphically the overall results obtained by the WARNSIS II recognition mode algorithms from a complex signal. The graph in Figure 6.2 (a) shows 7.64 seconds of digitized signal. The signal is a composite of four separate signals: i) Background Noise (FM rock radio and voices) ii) Warning Signal A, microwave oven alarm iii) Warning Signal B, electronic tone telephone ringer iv) Warning Signal C, mechanical bell telephone ringer Figure 6.2 (b), (c) and (d) shows the individual digitized warning signals without the background noise signal. For each of the warning signals in Figure 6.2 (b), (c) and (d) the values showing the characteristic peak frequency, burst duration time and interval time were obtained from the WARNSIS II learning mode algorithm. Figures 6.2 (b) and (c) show multiple bursts so that interval times can be shown, whereas the composite signal shown in. Figure 6.2 (a) contains only a single repetition of signals B and C. 60 Chapter 6 - WARNSIS II Implementation and Evaluation Mechanical Ringer Microwave Alarm Electronic Ringer 1.00 0.75 0) TJ 2 0.50 c o> 0.25 a 3 a 0.00 at 6 c -0.25 -0.50 -0.75 -1.00 r 'VI'IW l l f l c b a Ii L. .1 'V l^|l, ll | I " " " " ' I ' " j I ' V ^ L ^ V ^ I ' I ^ V ^ K V Jjî  i i' i1, "i IS i Background Only . Jii a,I [IF IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIM I I I I II I l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l I l l l l l l l l l l l l l III11II11II11 I l l l l l l l l l l l l l Each Line indicates a Successful Spectral Match Relative Magnitude vs Time Burst Duration: Interval: 1: 650 ms (microwav.wtp) 2: 2043 ms (mech_phn.wtp) 3: 604 ms (microwav.wtp) 4: 139 ms (mech_phn.wtp) 5: 13? ms (mech_phn.wtp) 6: 13? ms (mech_phn.wtp) 7: 650 ms (microwav.wtp) 8: 2090 ms (elec_phn.wtp) 1254 ms 1207 ms Dur. Match: microwav.wtp bur. Match: mech_phn.wtp Dur. Match: microwav.wtp Int. Match: microwav.wtp Dur. Match: microwav.wtp Int. Match : microwav.wtp Dur. Match: elec_phn.wtp (a) - Results of WARNSIS II Analysis of Composite Signal Figure 6.2 - Composite and Individual Warning Signals Analyses. The figure above shows the results of the PC-based recognition mode analysis. The central graph of the figure shows a combined signal consisting of background noise and three different warning signals: a - Microwave Oven Alarm, b- Electronic Telephone Ringer, c - Mechanical Telephone Ringer. The set of horizontal lines at the top of the graph, indicated as a, b and c, show the position of each of the individual warning signals in the composite signal, as determined by the recognition mode analysis. The small vertical lines at the bottom of the graph, indicated as c, b and a, show each successful spectral match for each warning signal in the composite. Each vertical line corresponds to one 512 sample period. Each of the horizontal lines above the graph corresponds to one set of vertical lines below the graph are arranged symmetrically around the central time axis. ( 61 Chapter 6 - WARNSIS II Implementation and Evaluation < D 1.00 •o 0.75 H 3 0.50 c 0.25 -I ro 0.00 2 "025 - \ - -0.50 E -1.00 6088 msec Relative Magnitude vs Time 1.00 - i © 0.80 H ~ 0.60 - | cn 5 0.40 —I © 0.20 H 0.00 i t i i | t t f i | i t t i t f i i i j r i r t | i r i i | i f B t | i i t i | t t i i | i i i f | i i t i j i i i i | i i f i | f i i i | « t i i | i i i i | i i j i | i i i f j i i i f | i i i i | i i i f | t f f f | | M , , | I , , , R I , , , , I , , | , r r r p - r w q > n , f , , , , , , , , , , , , , , rjT7rriTrrrrrrT,p-pr^ 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 - i © 0.80 •"§ 0.60 cn § 0.40 ® 0.20 0.00 * i (> | • • < 11 < * f 111 r f 11 r i e 11111 f J - 4 -^ - '*~T~1''1 (1' •1 [' 1 1' ] 1 1 > * | 1 1'' | • >(* ] 1 > <' | < < • • | < • < • | < < < ̂  j • • • < j < > •' j * < i • | • • 111 • • • • | 1658 Hz Average Peak Intensity .|....l....|..'.rivrr;|,J..|,M.|,.lTrrX,|.Vrrrrrw^^ 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) (b) - Mechanical Telephone Ringer Signal and Spectral Analysis Signal C Figure 6.2 - Composite and Individual Warning Signals Analyses 62 Chapter 6 - WARNSIS II Implementation and Evaluation < D 1.00 —i •o 0.75 3 0.50 g* o.oo -H 2 -0.25 - - -0.50 - ® -0.75 K -1.00 6178 msec Relative Magnitude vs Time ii^TWUHanraninriii time 1.00 - i M M | i i i i | i , , , , , , , l | , , l I | I I I I | l . I I | l I l l M n i M l l l | l l l l | l l , l J l l I l j f I | l | l l | l | i : t l l J | | | i j | | i i | | M i | i i M ® 0.20 H i " " i " " i " " i " " i " i " 1 1 1 " ' * i 1 I n ifO> 11 II 11111 n 1000 2000 Relative FFT Peak Intensity (0 - 5000 Hz) l " " r T r ' ' , | l " " l " " l " " T ' " | " " f " " i " " i f r i " l 3000 4000 5000 frequency (Hz) LOO n ' " ' r " | . i i i | n H | , . . . | l , . i | j | u | , l M | . . M r © 0.80 H f 0.60 CD | 0.40- ® 0.20 - 0.00 1593 Hz Average Peak Intensity ' - • i • 1 *' • •• i • -J'-r̂ " i • n T...|....f.., l,...f5s 3000 4000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) 1000 2000 3000 4000 5000 (c) -Electronic Telephone Ringer Signal and Spectral Analysis Signal B Figure 6.2 - Composite and Individual Warning Signals Analyses 63 Chapter 6 - WARNSIS II Implementation and Evaluation < D 1.00 - i •o 0.75 - 3 0.50 - c 0.25 - g> 0.00 — § -0.25 - _ -0.50 - r? - ° - 7 5 - 0 0 -1.00 816 msec —\ 1281 msec time Relative Magnitude vs Time 1.00 —11111111111111111 M 1111111111 1111111111 I © 0.80 TO =§ 0.60 - i CD 2 0.40 — I © 0.20 0.00 1111111111 in 1111 n i II 11 |i m i n 111 n n 11111111111 II 1111 n 11 II 1111111 | ' i " | " " | ' " ' i | l l l l | l l , , | , , , , | , > . , | , l l l | l , l l | . , , , | , . , i | . . . i | , i i , | , i , r , , . , . , . . . i , , r i i , i . i . | | i i . i | 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 © 0.80 ••§ 0.60 - | CD 5 0.40 — I ® 0.20 H 0.00 H|IIII|IIII|IIII|IIII|IHI|IIII|IIII|IIII|IIII|IIII|IIII|IIII|IIII| 1981 Hz Average Peak Intensity M ' , ' M ' T M ' ' ' M ' ' ' - r - - M ~ ' L M ' l ~ M ' ' ' ' H " ' M ' ' , M , ' ' M ' l M r ' , M ' , ' T l ' l ' M ' , ' M ' ' ' M l ' ' M ' ' ' M r i i ~ 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) (d) - Microwave Oven Alarm Signal and Spectral Analysis. Signal A Figure 6.2 - Composite and Individual Warning Signals Analyses 64 Chapter 6 - WARNSIS II Implementation and Evaluation Figure 6.2 (a), produced directly by the PC based implementation, shows the combined results of the timing and spectral analysis algorithms. For each warning signal in the composite signal, the spectral matches between the peaks in the FFT power spectrum for the composite signal and the characteristic peaks stored in the templates for each of the warning signals is shown by a small vertical line below the digitized signal. Each vertical line corresponds to a spectral match for one 512 sample time interval. The spacing between each vertical line is not constant due to the resolution limits of the display screen, but the timing is identical for each of the 512 sample intervals. The timing analysis for each warning signal burst is shown by the horizontal lines above the digitized signal. The corresponding spectral and timing indication lines are symmetric about the horizontal axis at the centre of the digitized signal, shown by labels a-a, b-b etc.. Thus the first set of spectral match lines below the digitized signal correspond to the first horizontal timing line above the digitized signal. Below the graph, the calculated burst duration and interval times as well as burst duration and interval match messages are shown for the warning signals in order of their recognition. Thus, although warning signal C started before warning signal A, the burst for signal A ended before that for signal C, allowing A's burst duration to be calculated and the user message for signal A to be generated before signal C ended. The spectral matching acquisition algorithm's requirement for two consecutive matches or losses can be clearly seen in the spectral match lines for warning signal B. Approximately half way into signal C's spectral match series a single spectral match for signal B is shown on the graph. Since this was a single occurrence, the two consecutive spectral match criteria was not met and the signal's candidacy was not successful at this stage. Approximately 6 time segments later signal B was successfully determined to be a candidate. The signal remains a 65 Chapter 6 - WARNSIS II Implementation and Evaluation candidate until the end of the warning signal burst, even though there are two occasions indicated by missing vertical lines when a spectral match for a single 512 sample interval is not found for signal B. This is one of the key features of the spectral analysis algorithm. It allows the temporary loss of the signal without interrupting the timing analysis. The two consecutive loss algorithm can be extended to three or more consecutive losses for determining candidacy or loss of a signal. This could allow the WARNSIS II signal recognition algorithm to operate in a higher noise environment than for the standard two match/loss algorithm. For example, for the two consecutive loss algorithm, a signal would be lost after being masked by background noise for only two time periods. If a signal requires three or four consecutive losses to end the signal's candidacy, then in a very noisy environment the signal could be masked by background noise for up to four time periods without being lost. This would allow noise bursts to be longer in duration without interrupting the timing analyser. This would also, however, have the effect of lengthening the time after the warning signal ends before the burst recognition flag is set, since three or more time intervals, instead of two, would be required to elapse after the end of the signal burst. This would not necessarily cause a problem as the time intervals are on the order of 64 msec (sample rate for the PC version of WARNSIS II was 11,025 Hz) and 4 time intervals would only amount to 1/4 of a second delay. A greater problem would occur from linking spurious noise bursts into a single long duration burst. The higher the number of dropouts allowed in the signal matching algorithm, the greater the likelihood that a series of noise burst would be grouped into a single burst. This could cause a false positive message to be issued, especially for continuous signals where a timing match only requires exceeding a minimum burst duration time. 66 Chapter 6 - WARNSIS II Implementation and Evaluation Figure 6.2 (a) also shows why a two part spectral and timing analysis is required. Although the WARNSIS II spectral analysis correctly identifies the spectral matches for the initial occurrence of warning signal C, after warning signal C ends, the spectral matching algorithm continues to find a number consecutive spectral matches between the input signal and the characteristic peak for warning signal C. These are listed in the burst duration calculation tables shown below the graph as 139 ms duration bursts. However, because these bursts do not match the timing requirements of the timing analysis algorithm, no burst duration or interval time match message is issued to the user. If only spectral information had been used, the recognition of the signal by the spectral analyser alone would have issued an erroneous message. As can be seen in Figure 6.2 (a), the use of both spectral and timing analysis in combination with the use of multiple templates (one for each warning signal learned) allows the WARNSIS II system to detect multiple overlapping warning signals in a noisy environment. Figure 6.2 (a) shows at one point the simultaneous occurrence of the three warning signals in addition to the background noise. It should also be noted that the characteristic peaks of warning signals B and C are at frequencies of 1658 Hz and 1593 Hz respectively. This is a separation of only 65 Hz or 3 bins for a sample rate of 11,025 Hz. Since the spectral matching algorithm allows for a variation of plus or minus one bin for a valid spectral match, this is very close to the operational frequency resolution limits of WARNSIS II. 6.1.2 Other Results As the spectral analysis for WARNSIS II is performed in software by the using the FFT, it is important to determine the effects of digitization, sampling rate, and the data sampling 67 Chapter 6 - WARNSIS II Implementation and Evaluation window on our algorithm. The PC-based implementation provides not only a basis for implementing the WARNSIS II algorithms but also for testing the effects of various parameters and features of the WARNSIS n algorithms. The following sections detail the results of those investigations and their effects on the WARNSIS II algorithm. 6.1.2.1 8 Bit vs 16 Bit Digitization The VOC format provides for the storage of digitized signals in both 8 and 16 bit data sizes. Initially both 8 and 16 bit data formats were used for digitizing the input signal when testing the WARNSIS II algorithms. An 8 bit digitization allows for 256 levels of input signal (+/- ~ 0.4%), a 16 bit digitization allows for 65536 levels (+/- -0.002%). Calculating the STAAA's averages the input signal's magnitudes over a time period of 512 samples. If we assume a maximum error of Vi of a bit between the real and digitized input signals for each of the 512 samples then the maximum error for 8-bit digitization is 512* 1/2 bit = 256 bits. For 512 samples this would give a maximum error of 256/512 = Vi bit maximum error after the average is taken. The result is the same for 16-bit digitization. Since the STAAA process requires a increase of 50% in the input signal amplitude above the background level to start the learning process, the difference between 0.4% and 0.002% is irrelevant. As the spectral analysis relies only on relative magnitude differences in the FFT power spectrum, the extra resolution provided by the greater number of input bits is of no extra value. Since peaks lower in magnitude than 25% of the largest peak found and lower than a preset minimum are ignored, the extra resolution is lost in the background. Given these results, it was found that when performing either the STAAA analysis or the FFT analysis that the data digitization at either 8 or 16 bits had no effect on the function of the WARNSIS II algorithms. 68 Chapter 6 - WARNSIS II Implementation and Evaluation 6.1.2.2 FFT Size, Frequency Resolution and Sampling Rate For the FFT the relationship between frequency resolution, sampling rate and sample size is given by, Af=R/N ( 6 . 1 ) where A/is the frequency resolution between adjacent bins, R is the sampling rate and N is the size of the FFT. The larger N, the FFT size, becomes, the smaller A/becomes. However, the larger N becomes, the longer the period of time a single FFT power spectrum covers. These are the time-frequency resolution limits described earlier in section 4.1.5. There is no theoretical limit on sampling rate and size, and time-frequency resolution for WARNSIS n. The WARNSIS n algorithms can be implemented at any sampling rate. The trade-off, again is between the time and frequency resolution. For a WARNSIS II device to operate successfully it must be able to meet the two following criteria. Firstly, to discriminate between multiple overlapping signals, the characteristic peak frequencies of the two signals must be resolved separately from each other. In order to do this the frequency resolution of the FFT must be fine enough to place the characteristic peaks from two separate signals into different bins. Secondly, if two warning signals have identical characteristic frequencies, then they can only be successfully recognized if they do not overlap in time, and they have different burst and/or interval times. This means that the time-frequency resolution issue must be solved on a practical basis such as the processor memory requirements or expected signal characteristics. If the sample 69 Chapter 6 - WARNSIS II Implementation and Evaluation size was set so that only a few bins covered the entire spectrum, then the frequency performance of the WARNSIS II algorithm would suffer accordingly. Conversely, if the sample size is too great then the memory requirements and the time resolution would be similarly effected. For the WARNSIS II algorithms, the size of 512 samples was chosen for two main reasons. First, choosing a sample size of 512 we can achieve a frequency resolution of approximately 21.5 Hz covering a period of 46.4 msec for a sampling rate of 11,025 Hz for the PC based implementation. This provides a reasonably good resolution for both frequency and time. Secondly, a sample size of 512 allows the DSP implementation to maintain two separate FFT sample arrays and processing code in the processor's internal memory. This greatly increases the speed of the DSP FFT algorithm [17]. By maintaining the same sample size for both implementations it is easier to compare algorithms between the two platforms. More important than using a specific sample rate or sample size, is the requirement that the same sample rate and size be maintained both in the learning mode and in the recognition mode. Since not only the frequency resolution, but also the centre frequencies of the bins (hence the bin #) changes with sampling rate and size, a signal learned at one sample rate and size will not have the same centre frequency or bin number if the recognition algorithm operates at a different sample rate and size. 6.1.2.3 Sampling Window Effects Section 4.1.1.2 discussed the effect that various sampling window functions would have on the leakage of energy between bins in the FFT power spectrum. Figures 6.3 (a), (b), (c) 70 Chapter 6 - WARNSIS II Implementation and Evaluation and (d) show the effect of the standard square window, the Parzen window, the Welch Window and the Hanning window on the FFT spectrum of a 2040 Hz signal. Although the Parzen, Welch and Hanning window functions all improve the leakage between bins, as shown by the narrowing of the base of the peak, they provide little advantage for the WARNSIS II spectral analysis algorithm. The reduction in leakage is so small that it is lost in the background noise. This can be seen in Figures 6.4(a) and (b). Figure 6.4 (a) shows the power spectrum of the background noise signal using the standard square window. Figure 6.4 (b) shows the power spectrum for the same signal using the Hanning window function. There is virtually no difference in the spectrum aside from a slight "smoothing" effect that the Hanning window has on the peaks and valleys as was shown in Section 4.1.1.2. Since only the relative magnitudes of the peaks above the preset limit and above 25% of the maximum peak are important, the use of any one of the additional windowing functions simply adds to the processing time of the algorithm with no appreciable benefit. 6.1.2.4 Speed Considerations Although the PC implementation of the WARNSIS II algorithms operates on stored data files, an attempt was made to have the algorithms perform at a "real-time" rate. Due to the overhead of the Windows environment and the extra effort required by the PC's processor to display the graphical information generated by the program, there was not enough processing power to have the algorithms process all of the incoming data in real time. To speed up the processing time, rather than performing the FFT analysis on all of the data, the program was modified so that the FFT was only calculated for one of two, one of three, one of four, etc. sample periods. The time for the intervals for which the FFT was not calculated was included in the burst duration calculations, but no spectral analysis was performed on these missed 71 Chapter 6 - WARNSIS II Implementation and Evaluation o 1.00 -TJ 0.75 -3 0.50 - c 0.25 0.00 5 -0.25 _ -0.50 • -0.75 -1.00 time Relative Magnitude vs Time 1.00 ® 0.80 H =| 0.60 H C D | 0.40 - © 0.20 - 0.00 M i i i M ' i i ' i i i i M i ' ' M i ' ' M ' ' L ' P ' M I I I I T ' l l ' r ' ' ' i i ' ' i r ' i i r i ' ' i i ' i ' r i i ' i ' ' ' ' r i i i r ' ' ' r i ' i i ' i ' i i 1 1 1 1 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 -i a> 0.80 fz 0.60 2 0.40 ® 0.20 0.00 i i i i | i i i i | i i i i | i i i i | i i i t | i i i i | i i i i | i i n 2040 Hz f i i i i i i i i | M i i | i i i i | i i i i | i i i i | i i i i | i i i i | i i i i | i i i i | i n i | i i i i | i i i i | i i i Average Peak Intensity • i " " i " " i " ' • i " " i • • " i ' " • i " " i " " i — j . . . - 1 1 1 " 1111 n | i 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) (a) Standard Square Sampling Window for 2000 Hz Signal Figure 6.3 - Effect of Sampling Window Function on Power Leakage 72 Chapter 6 - WARNSIS II Implementation and Evaluation 1.00 - i © 0.80 ••§ 0.60 cn to 0.40 ® 0.20 0.00 MII|IIII|II I I| I I I I| I I I I| I IM|IIII||II| MII|IIII|IIII|IIII|IIII|IMI|III||I|||||||||IIII|IIII|IIII||I||||||I ' i " " i " " i " " r i " i " " i " " i " " i " T l i " " i " " i " " i " " i " " i " " i " " { " " i " " i " " i " " i " " r 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) (b) Parzen Window for 2000 Hz Signal 1.00 1 III 11 • • 11 j 111111111 j f • i J j 111111 (1111111  f1 > > I >' i r 111111 r 11 r 111 J i j 1111 j j 111111 r 11111111111 j 11111 • 1111»111 j»111 © 0.80 "§ 0.60 cn 2 0.40 ® 0.20 0.00 1.00 o 0.80 f= 0.60 cn J£ 0.40 ® 0.20 11" 1 11" " i 1 " 1 r • • 11 1" 11 1 1 1 11" 1 11 1 rt 11 • 1 " i " " i 1 1 1 1 1 1 1 1 1 1 1 •" i " " i 1 1 1 11" 1 11" " i 1 1 1 1 1" " i1"111 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) (c) Welch Window for 2000 Hz Signal frequency (Hz) 0.00 |IIII|MII|IIII|IIII|UII|IIII|IIII|IIII|IIII|IIII|IIII|IIII|IIII|IIII 1000 2000 3000 4000 Relative FFT Peak Intensity (0 - 5000 Hz) (d) Hanning Window for 2000 Hz Signal 5000 frequency (Hz) Figure 6.3 - Effect of Sampling Window Function on Power Leakage 73 Chapter 6 - WARNSIS II Implementation and Evaluation a> 1.00—] •o 0.75-1 3 0.50 E 0-25 §> 0.00 2 -0-25 H _ -0.50 5 -0.75 H 0 1 -1.00 Relative Magnitude vs Time time 1.00 - I I ® 0.80 - •j= 0.60 - \ 5 0.40 H ] l l , M l , l M l l l T l l M l l l T l l T l l T l l H l l l l l l l l l l , l l l l ' l l l l l l l l l l l l l l l , , ' l l l , l l ' , l l l l l l l l n i l l l l l l l n i l l Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 l l l l | M I I | l l l l | M I I | l l l l | l l l l | l l l l | | | | | | | | | | | M | | | | | | Average Peak Intensity ® 0.20 H Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) (a) - Background Spectrum for Standard Square Sampling Window Figure 6.4 - Effects of Sampling Window, Background Noise Power Spectrum 7 4 Chapter 6 - WARNSIS II Implementation and Evaluation 0 1.00 •o 0.75 - B 0.50 - £. 0.25 g> 0.00 3 -0.25 - _ -0.50 - ® -0.75 - 0 1 -1.00 time Relative Magnitude vs Time 1.00 © 0.80 H =| 0.60 cn | 0.40 - \ ® 0.20 H 0.00 i i i j | i | i t t f | i i ' * i | i i i r | i f i i | ( i i t j i f i i | i r t i | t i t j | r t i i | i i i r j t i t t | i i f « j i i i i j i i i i | i i t i j t t t f j t t t i | i i i i | t i i i | f i i i | f f ( i | 1000 2000 3000 4000 Relative FFT Peak Intensity (0 - 5000 Hz) 5000 frequency (Hz) 1.00 1000 2000 3000 4000 Relative FFT Peak Intensity (above 900 Hz) 5000 frequency (Hz) (b) - Background Spectrum for Hanning Sampling Window Figure 6.4 - Effects of Sampling Window, Background Noise Power Spectrum 7 5 Chapter 6 - WARNSIS II Implementation and Evaluation intervals to determine if a signal was still a candidate or had been lost. The same two consecutive spectral matches or loss for signal acquisition or loss were still required, but these consecutive matches were now spaced further apart in time by the number of "missed" intervals. In comparison to those test signals that were successfully detected by the standard algorithm when no intervals were missed, the modified algorithms were able to miss up to 6 consecutive intervals and still successfully identify the warning signals. This brought the processing speed on a 50MHz 486 PC to the point where the signals could be processed in an amount of time less than or equal to the actual duration of the input signal. An additional increase in processing speed was obtained by comparing the square of the peak magnitudes instead of the peak magnitudes. Since we are only interested in relative magnitudes and not absolute magnitudes there is no need to perform the square root function required to obtain the absolute magnitude from the real and imaginary parts of the FFT. This provides a great increase in speed for the spectral analysis algorithm since processing the square roots requires as much processing time as performing the FFT itself. 6.2 TMS320C30 Based System The DSP version of the WARNSIS II algorithms were written in TMS320C3x assembly language code and implemented on a Texas Instruments TMS320C3x Evaluation Module (EVM). The E V M is a half length board that installs in an IBM compatible PC. TheEVMcan run in stand alone mode operating completely independently from the PC or can be interfaced to the PC through the PC's I/O port structure. The E V M itself consists of a 33 MFLOP 32 bit TMS320C30 Digital Signal Processor with 2K words of internal R A M . 16K words of additional zero wait-state R A M are also provided on the circuit board as well as a TLC32044 76 Chapter 6 - WARNSIS II Implementation and Evaluation Analog Interface Circuit (AIC). The AIC provides 14 bit digitization for audio signals which can be input directly from a microphone or via a preamplified line [30]. In the WARNSIS II setup the AIC of the E V M was connected via the Creative Labs Sound Blaster16 to a standard 500 Ohm unidirectional microphone. For the DSP implementation of WARNSIS II, the Sound Blaster16 was used only as a preamplifier for the microphone and no digitization or filtering was performed by this board. The TLC32044 AIC however has an internal bandpass filter with the ripple bandwidth and 3-dB low frequency roll-off points of the highpass section at 150 Hz and 100 Hz respectively, and a high frequency 3-dB roll-off at approximately 3,700 Hz for a sample rate of 8,012 Hz [31]. The sample rate of 8,012 Hz is used for the DSP implementation as the AIC filtering circuits are optimized for this frequency. The lower sample rate for the DSP implementation vs the PC implementation presents no problems in that it still provides a maximum frequency resolution of 15.64 Hz and an interval time of 63.9 msec. The maximum frequency limit from the lowpass section of the AIC filter also presents no problems as all of the warning signals that we have identified so far have their characteristic peak frequencies well below this limit. As for the PC implementation, the actual choice of sampling rate and sample size is a practical one guided by memory requirements and desired frequency resolution, not a theoretical one. The TMS320C3x Digital Signal Processor family was chosen due to the support available from the manufacturer as well as the availability of a number of versions of the processor at various speed and price ranges. Although the E V M cost was on the order of $1200 US, some versions of the processor itself can be purchased in quantity for under $20 US. This means that a relatively low cost implementation of a stand alone device based on the TMS320C3x DSP could be designed. 77 Chapter 6 - WARNSIS II Implementation and Evaluation 6.2.1 Program Size The size of the compiled assembly language program for the DSP implementation was 1,492 words and required 1,801 words of data storage. Of the 1,492 words of program code, 952 words were required for implementing the WARNSIS II algorithms and communications routines with the PC, 420 words were required for the FFT routine, 78 words were required to implement a floating point divide routine and the remaining 42 words were for miscellaneous interrupt vectors and processor control. Of the 1,801 words of data storage, 1,024 were required for maintaining two 512 word tables, one for collecting the current 512 input samples, the second for simultaneously calculating the FFT of the previous 512 samples. The rest of the data storage was comprised of 256 words of storage for the FFT sums for learning mode, 256 words for the FFT "twiddle factors", 120 words for peak identification, 40 words for templates, 10 words for I/O buffers for PC communications and 55 words for miscellaneous variables. The majority of both code and data were accommodated in the 2K of internal R A M provided on the TMS320C30 DSP chip, meaning less than 2K of external R A M was required. 6.2.2 Results of DSP Based Implementation The WARNSIS II spectral and timing analysis algorithms functioned similarly in the DSP based implementation as they had for the PC based implementation. The TMS320C30, however, provided enough processing speed to perform the analysis in real time. In fact, of the 63.9 msec interval time for 512 samples, approximately 0.57 msec was required to process the FFT from the previous 512 samples. As the current samples are input via an interrupt routine the time not used for processing the FFT's is available for the peak detection, spectral and timing analysis and template comparison algorithms. Also, because the data is input via an 78 Chapter 6 - WARNSIS II Implementation and Evaluation interrupt routine and the burst timing and spectral analysis are performed in real time as the input signal is digitized, the delay from the end of a burst, or interval between bursts, to the time a message is issued to the user is less than one 512 sample interval. This means that there is no appreciable time delay between the end of a warning signal's occurrence and the setting of the recognition flag. 6.2.2.1 Performance Measurements Tests of the DSP implementation of the WARNSIS n algorithms were performed under quiet office conditions with an ambient noise level below 50 dB. The background noise added for testing was generated by a standard stereo receiver playing a combination of F M rock music and voices. Figure 6.5 (a) shows the physical location of signal and noise sources in relation to the microphone input. N shows the location of the noise generating source, W A the location of the warning signal source A, W B the location of the warning signal source B, M the microphone location and S the location of the sound level meter. Warning signal source A was a typical telephone ring generated by a Panasonic PD-2300 telephone whose FFT spectrum and characteristic peak frequency are shown in Figure 6.6. Warning signal source B was a continuous 2200 Hz tone generated by a function generator whose FFT spectrum and characteristic peak frequency are shown in Figure 6.7. Sound level measurements were made with a Realistic (TM) Sound Level Meter with both standard A and C weighting. As shown in Figure 6.5 (b) the C weighting curve has a flat frequency response from 32 Hz to approximately 2,500 Hz, the A weighting curve has a 3 dB highpass roll-off at approximately 500 Hz. This means that more low frequency energy is measured with the C weighting than for the A weighting. 79 Chapter 6 - WARNSIS II Implementation and Evaluation * a f — — 3 ft > (a) Noise, Warning Signal and Microphone Test Setup 20 BO 100 200 500 IK 2 5 10 20 FREQUENCY (Hi) (b) A and C Sound Level Meter Weightings Figure 6.5 - Performance Measurement Setup Chapter 6 - WARNSIS II Implementation and Evaluation 6178 msec time Relative Magnitude vs Time 1.00 © 0.80 TO ~ 0.60 - i 2 0.40 ® 0.20 H 0.00 l l l l | l l l l | l l l l | l l l l | I I M | l l l l | l I " •• I —I — I " ' ' I • " ' I —I 1000 2000 3000 4000 Relative FFT Peak Intensity (0 - 5000 Hz) 5000 frequency (Hz) 1.00 © 0.80 ••§ 0.60 5 0.40 H ® 0.20 0.00 i i i i | i n i | i i i i | i i i i | i m i i i i i | i i i n IIII i n n i II 11 II II III n i l i n i i n i n i l 11 n i l i n i l i II n i i i i i t i i i i i i II i n 1593 Hz Average Peak Intensity • i " • ' i • • " i • l *|VV|A , i. , "W^-I I l , . 1 , , , , , , . , . r . „ , l , . . ^ w ? 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) Figure 6.6 - Panasonic PD-2300 Electronic Ringing Signal Spectral Analysis 81 Chapter 6 - WARNSIS II Implementation and Evaluation a> 1.00 - i •u 0.75 B 0.50 c 0.25 g> 0.00 §. -0.25 -f _ -0.50 - S -0.75 - or -1 .oo - 1 Relative Magnitude vs Time 1.00 a> 0.80 H ••§ 0.60 - \ o> 5 0.40 ® 0.20 H 0.00 111 j f 1111 j 111) 11111 [ 111111 • 11111111 r 111111 j f j 1111 ] 1111 j 111111111 ]. 111111 j 111 j 11111111111111»111 j 1111 j 11111111 • j 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 ® 0.80 - \ fz 0.60 - \ C D 2 0.40 ® 0.20 H 0.00 i j i • j 1111111111111 r 1111111111 ] a 11 r 11111 j j-t- r 11 [ 11 > i j 111 > 11111 j 1111111111 < 11 r j 11111 p • 11111111 [ 111 j t f 11 j r (111 2200 Hz Average Peak Intensity 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) Figure 6 7 - 2200 Hz Continuous Tone Spectral analysis 82 Chapter 6 - WARNSIS II Implementation and Evaluation Table 6.1 shows the upper limits on signal and noise for the DSP implementation of WARNSIS II for sound level measurements with both A and C weightings. As can be seen, the DSP implementation of the WARNSIS II algorithms can successfully detect warning signals in very noisy environments. The DSP implementation was able to detect a 57 dB warning signal at a distance of 4 ft from the device generating the warning signal in the presence of76dB average background noise. This is a signal-to-noise ratio of -19 dB. Since most warning signals are designed to be at least 10 dB above ambient noise levels, the DSP implementation far exceeds the requirements. In fact, in testing, the DSP implementation of WARNSIS II outperformed the author's own ability to detect warning signals by ear and to discriminate between warning signals in very noisy environments. The DSP implementation of the WARNSIS II algorithms performed with 100% recognition accuracy during testing. All occurrences of perviously learned warning signals were recognized until the background noise level exceeded the values shown in Table 6.2.2.1 below and no false positives were generated. Table 6.1 - Single Warning Signal vs. Noise Sound Level Measurements Distance Distance Meter Warning Signal Maximum Average Maximum Peak a (ft) b(ft) Weighting StrengthJdBA) Noise Level (dBA) Noise Level (dBA) 11 2 A 56 72 74 11 2 C 58 80 84 11 4 A 56 62 66 11 4 C 57 76 78 83 Chapter 6 - WARNSIS II Implementation and Evaluation To determine if the presence of one warning signal would suppress the detection of another signal in a noisy environment, a second signal was introduced during testing. In order to determine the level at which the second warning signal (B) would suppress the detection of the original warning signal (A) the following procedure was used. First the noise background level was increased to the point where detection of warning signal A was suppressed by the noise alone. Next the noise level was decreased by 2 dBA to allow detection of warning signal A. The level of warning signal B was then increased to the point where detection of warning signal A was again suppressed. Table 6.2 shows the upper limits for the sound level for the two signals and the background noise. Table 6.2 - Dual Warning Signal Vs Noise Sound Level Measurements Warning Warning Maximum Maximum Distance Distance Meter Signal A Signal B Average Peak a (ft) b(ft) Weighting Strength Strength Noise Level Noise Level (dBA) (dBA) (dBA) (dBA) 11 2 A 58 58 70 72 11 2 C 62 58 78 82 11 4 A 58 55 60 62 11 4 C 60 55 70 74 11 4 A 58 55 - - 11 4 C 60 55 - - 84 Chapter 6 - WARNSIS II Implementation and Evaluation The first four rows of table 6.2 show the level at which the detection of warning signal A was suppressed by warning signal B in the presence of background noise. The last two rows of table 6.2 show the level at which detection of warning signal A was suppressed by warning signal B alone, without the addition of background noise. It is significant to note that the presence or absence of the background noise has no effect on level at which suppression of signal A by signal B occurs. Figure 6.8 shows the FFT spectrum of the background noise. Note that most of the energy is in the range below 900 Hz. Figure 6.9 shows the combined spectrum of signal A and signal B at the point just before suppression of signal A occurs. This shows that suppression of signal A occurs when the magnitude of the characteristic peak for signal B is approximately four times that of signal A. The noise signal can only contribute to the suppression of signal A by signal B if there is significant energy in the noise spectrum at the characteristic frequency peak of signal B. This is in agreement with the original algorithm design as discussed in section 5.3. It would appear from the sound level readings that the strength of both signal A and signal B are at approximately the same level, 55 dBA to 60 dBA, and the magnitude of their characteristic peaks should also be approximately the same. However, since signal B is a pure tone, all of the energy in signal B is found at its characteristic frequency. Signal A, on the other hand, has its energy distributed across the spectrum, including a portion below 900 Hz, which means less energy is contained at the characteristic frequency . 85 Chapter 6 - WARNSIS II Implementation and Evaluation < D 1.00 •o 0.75 H B 0.50 c 0.25 §» 0.00 5 -0.25 _ -0.50 —I £ -0.75 H 0 1 -1.00 time Relative Magnitude vs Time 1.00 ® 0.80 H 0.60 ~ i C D J 0.40 ® 0.20 H 0.00 If l l | l l l l | l l l l | I M I | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | U I I | l l l l | l l l l | l l l l | I I H | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | • I 1 1 ' ' I " *1' I ' ' 1 11 ' ' ' ' I ' 1 ' ' I ' '' 11 ' ' ' '11 ' 1 ' I'' ' • 11 1 1 ' I ' ' '' I '" ' ' I' 1 1 ' I " *' I ' ' ' 1 I 1 ' ' ' I ' • ' • I •' • • I ' • • I' 1 ' 'I ' ' ' ' I 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | l l l l | I M I | l l l l | l l l l | ' | " " | ' • " | " " | " " | " " | • " ' | " 1 ' I ' 1 1 • I" ' ' I " " I 1 " 1 I 1 " ' I" 1 ' t'''' 11 ' ' ' I'' ' • I • ' " I " " I'"' I 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) Figure 6.8 - Test Background Noise Spectral Analysis 86 Chapter 6 - WARNSIS II Implementation and Evaluation < D 100 - j •o 0.75 - B 0.50 - c 0.25 g* 0.00 f| -0.25 - -0.50 ~i r? - ° - 7 5 K -1.00 time Relative Magnitude vs Time 1.00 n M I I | l l l l | l l l l | I I U | M I I | n i l | M I I | I I M | M l j | M I I | l l l l | I I M | I M I | M I I | l i n | l l l l | M n | l t l l | l l l l | l l l ' l | l l l l | I M I | © 0.80 .-I Z3 • ~ 0.60 o> | 0.40 © 0.20 H 0.00 ft1 " I " " ! " A •"•••in— J • i , , | , . . , | T r 7 T p i i l | i . . l | i T i i | , , , , , i, , , , , , , 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (0 - 5000 Hz) frequency (Hz) 1.00 © 0.80 H •§ 0.60 H O ) 5 0.40 ® 0.20 - \ 0.00 l l l l | l l l l | l l l l | I I M | l l l l | l l l l | l l l l | | | | | | | | INI|IIII|IIII|IIM|IIII|IIII|IIII|IIII|IIII|IMI|IIII|IIII|I|I|| Average Peak Intensity t . . . . . . .|i H . - n r T - r r . — , , , , H | „ , F p " 1 " " I " " I1 " ' I " ' '1* '̂' I 1000 2000 3000 4000 5000 Relative FFT Peak Intensity (above 900 Hz) frequency (Hz) Figure 6.9 - Combined Warning Signal A and B Spectral Analysis 87 Chapter 7 7.0 Conclusions and Recommendations It has been shown that the WARNSIS II algorithms, can, by the application of separate spectral, energy and timing analysis routines, in that order, learn and then later recognize warning sounds with 100% accuracy in very noisy background environments. The signal-to-noise ratio in these environments can be on the order of -20 dB. It has also been shown that warning signals can be successfully recognized on the basis of four characteristics: i) peak frequency ii) energy content at the peak frequency iii) burst duration iv) interval time. Both continuous and burst warning signals can be recognized by this method. In particular, a burst signal can be recognized after a single burst and a repetitive warning signal can be successfully recognized on the basis of a single repetition. A warning signal can also be identified with no appreciable delay due to processing after the signal burst has ended. Additionally, it has been shown that it is possible to successfully recognize multiple overlapping warning signals in the presence of background noise. These results mean that it would be possible to implement a device that could operate successfully in real-life situations. The implementations of the WARNSIS II algorithms on both a PC and a DSP module have also shown that it is possible to implement a system that does not rely on any specialized hardware and can be easily ported to distinctly different platforms. 88 Chapter 7 - Conclusions and Recommendations In addition to aiding the design and development of the WARNSIS II algorithms, the PC implementation has provided, not only a tool for further development of WARNSIS II based systems, but a tool for general spectral analysis as well. The base routines and functionality of the PC program as well as the graphical displays for instantaneous signal amplitude, absolute signal amplitude and FFT power spectrum can easily be used as the starting point for other projects in this field. The DSP implementation further shows that it is possible to implement a low cost, low part-count system, with sufficient power to perform the required analysis. The E V M board used in the DSP implementation contains only 24 IC's and provides extra functionality such as analog output and secondary serial communications not required for the WARNSIS II implementation. Although the E V M provided 16K of additional zero wait state R A M , less than 2K of this R A M was required for the WARNSIS II algorithms. This means that a stand- alone implementation of WARNSIS II could be produced on a system consisting of fewer than the 24 IC's on the E V M . Since the code and data space and processing time requirements for the WARNSIS II algorithms are small, it may be possible to add the WARNSIS II functionality to existing equipment without additional memory or processing power. 7.1 Future Work Although the WARNSIS II system performed extremely well and met all of the objectives of phase II of the project, there are some areas where further improvement is possible. 89 Chapter 7 - Conclusions and Recommendations 7.1.1 Improved Learning Mode Although the WARNSIS II recognition mode is able to operate in extremely high noise background areas, the learning mode algorithms require that the warning signal that is being learned be significantly louder than the background noise. In most cases this would not be a problem as it should be possible to arrange, temporarily at least, for a sufficiently quiet background in which to learn a warning signal. There may be cases, however, where this would not be possible and the warning signal would have to be learned in a high noise background environment. It may be possible to improve the learning mode's ability to learn new signals in high noise environments by using an approach similar to the recognition mode's warning signal "candidacy" algorithm. Rather than relying on a single burst and using the STAAA to identify the beginning and end of a burst, multiple signal bursts and frequency characteristics could be used. For example, the first burst could be used to identify the characteristic frequency for the warning signal by monitoring for the occurrence of a strong peak in the power spectrum. The second burst could then be used for confirmation of the spectral peak and burst timing and a third complete burst could be used for interval timing and confirmation of the characteristic frequency and burst times. If the WARNSIS II device were provided with enough memory to store the digitized input signal for two complete bursts, the learning mode could be designed to learn from a single repetition of a warning signal by performing the spectral analysis twice on the initial burst. The 90 Chapter 7 - Conclusions and Recommendations first pass would identify the characteristic peak, the second pass would be used to identify the burst duration time. At least one partial repetition would still be required, however, to identify the interval time. 7.1.2 Improved Recognition Mode It was stated earlier in section 5.3, and shown in section 6.2.2.1, that the presence of a warning signal that was significantly greater in power than other warning signals could, in effect, suppress the recognition of those other warning signals should they occur at the same time. It may be possible to overcome the suppression by performing a multi-pass frequency analysis. In the first pass, the peak with the largest magnitude in the spectrum would be used for normalizing the spectral magnitudes. Once the spectrum had been analysed using this peak for normalization, the process would be repeated using the next largest peak to normalize the spectrum. This would continue until all peaks that exceed the preset minimum "background" value had been used for normalization. This way a single powerful signal would not be able to suppress a valid peak. This would, however, require an increase in both processing power and memory. The processing would only require extra time to recalculate the normalized magnitudes for each pass, not to recalculate the FFT. The data storage requirements would increase by 8 words (256 bits, one for each frequency bin) for flags to indicate if a peak had been previously used for normalization. 7.1.3 Additional Features We have shown that a WARNSIS II device is capable of correctly identifying warning sounds in noisy environments. There is often other information conveyed with a warning signal 91 Chapter 7 - Conclusions and Recommendations in addition to that simple presence or absence of the sound. Humans rely on binaural hearing for sound localization. An improved WARNSIS 13 device could supply even more information to the user if some type of sound localization could be performed. Additionally, an estimate of the "loudness" of the warning signal could provide added benefit to the user. The implementation of these features should be explored. 7.2 Other Applications As stated earlier the functionality of the WARNSIS II algorithms can be incorporated into other devices. This could provide assistance not only to the hard of hearing or the deaf but also to people in other situations. The problem of recognition of warning sounds is not limited to those with hearing impairments. There are situations which arise on a day to day basis which can have serious affect on people with normal hearing. In many industrial environments auditory warning signals are commonly used. On construction or mining sites it is common practice to use auditory warning signals to signal blasting or movement of heavy machinery. In mills and chemical processing plants the starting of a piece of equipment is often preceded by an auditory warning burst. Often the noise present in these environments and the need for personnel to wear hearing protection makes it difficult to hear these signals. Personnel who are working in an area where the risk of injury is high would benefit from a device that was able to alert them to these signals. Another possible use for the WARNSIS II system is in hospitals. In critical care areas, patients may be connected to a number of different medical devices, each with its own alarm sound. Rather than relying on separate recording instruments or hard-wiring the alarms to the central station, a WARNSIS II device which monitors all alarms and reports to the central 92 Chapter 7 - Conclusions and Recommendations station could save both wiring and training costs. Time and effort would also be saved when new equipment was introduced to a critical care area. Since each medical device would have its own warning signal characteristics which could be "pre-learned" by the WARNSIS II device, no extra connections or training would be required each time the equipment was introduced into a new area. By elimination of the hard-wire requirements for some devices, the space near the patient would be less cluttered, allowing for better patient access. 93 References [I] "The Prevalence of Hearing Impairment and Reported Hearing Disability Among Adults in Great Britain", A.C.Davis, pp. 911-917, International Journal of Epidemiology, 18 (4) [2] "Canadians with Impaired Hearing", J. Shein, ed., Publication Division, Statistics Canada, 1992 [3] "Visual Devices For Deaf and Hard of Hearing People: State-of-the-Art", Judith Harkins, GRI Monograph Series A, No. 3, Gallaudet Research Institute, 1991 [4] "Technological Devices for Deaf-Blind Children: Needs and Potential Impact", A.Y.J. Szeto, K.M.Christensen, IEEE Engineering In Medicine and Biology, Volume 7, pp. 25-28, September 1988 [5] "A Computer Sound Cue Indicator for Hearing Impaired People", C.Jensema, D.Hinton, N.Drew, pp. 49-52, Computing Applications to Assist Persons with Disabilities, 1992 Proceedings [6] "Sound Alerting Aids for the Profoundly Deaf, B.Uvacek, G.S.Moschytz, pp. 2615- 2618, IEEE International Symposium on Circuits and Systems, 1988 [7] "A Warning Signal Identification System (WARNSIS) for the Hard of Hearing and the Deaf, Simon Chau, Masters Thesis, University of British Columbia, 1989 [8] Speech Level and Spectrum, Electronics Engineer's Handbook, Second Edition, Section 19.10, pp. 19-7, McGraw-Hill, 1984 [9] "Standard for the Installation, Maintenance and Use of Local Protective Signalling Systems for Guard's Tour, Fire Alarms and Supervisory Service", National Fire Protection Association, NFPA 72A, 1985 [10] "Guide for the Installation, Maintenance and Use of Notification Appliances for Protective Signalling Systems", National Fire Protection Association, NFPA 72G, 1985 [II] "Long-Duration Signal Detection in a Noisy Environment", S.C.Clontz, R.R. Adhami, pp. 527 - 532, IEEE 1989 South Eastern Symposium on System Theory, 1989 [12] "Speech Recognition Techniques", P.M.Grant, pp. 37 - 48, Electronics & Communications Engineering Journal, February 1991 94 [13] "Algorithms and Architectures for Dynamic Programming on Markov Chains", W.G.Bliss, L.L.Scharf, pp. 900-912, IEEE Transactions on Acoustics, Speech and Signal Processing, Vol. 37, No. 6, June 1989 [14] "A Real Time Connected Word Recognition System", Y.Ishikawa, K.Nakajima, pp. 215-217, 10th International Conference on Pattern Recognition, 1990 [15] "Speech Technology At Work", J. Hollingum & G. Cassford, IFS Publications, 1988 [16] "A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition", L.R.Rabiner, Proceedings of the IEEE, pp. 257-285, Vol 77, No. 2, February 1989 [17] "An Implementation of FFT, DCT, and Other Transforms on the TMS320C30", P. Papamichalis, pp. 53-136, Digital Signal Processing Applications with the TMS320 Family, Theory, Algorithms and Implementations, Texas Instruments, Volume 3, 1990 [ 18] "How the FFT Gained Acceptance", J. W. Cooley, IEEE Signal Processing Magazine, Volume 9, Number 1, 1992 [19] "Numerical Recipes in Pascal", W.H. Press, B.P. Flannery, S.A. Teukolsky, W.T. Vetterling, Cambridge University Press, 1992 [20] "A Spectral Magnitude Analysis Theorem and Applications", J.C.Anderson, pp 277- 280, Time-Frequency and Time-Scale Analysis, IEEE International Symposium on Signal Processing, 1992 [21] "An Algorithm for the Machine Calculation of Complex Fourier Series", J.W. Cooley & J.W. Tukey, Math. Comp. 19, 1965 [22] "A New Look at the Comparison of the Fast Hartley and Fourier Transforms", M.Popovic, D.Sevic , pp. 2178 - 2182, IEEE Transactions on Signal Processing, Vol. 42, No. 8, August 1994 [23] "Transforming Real-Valued Sequences: Fast Fourier versus Fast Hartley Transform Algorithms", P.R.Uniyal, pp. 3249 - 3255, IEEE Transactions on Signal Processing, Vol. 42, No. 11, November 1994 [24] "Restructured Recursive DCT and DST Algorithms", P.Lee, F.Huang, pp. 1600 - 1609, IEEE Transactions on Signal Processing, Vol. 42. No. 7, July 1994 95 [25] "An Adaptive UR Structure for the Separation, Enhancement, and Tracking of Multiple Sinusoids", C.C.Ko, C.P.Li, pp. 2832 - 2834, IEEE Transactions on Signal Processing, Vol. 42, No. 10, October 1994. [26] "Linear and Quadratic Time-Frequency Signal Representations", F. Hlawatsch, G.F. Boudreaux-Bartels, IEEE Signal Processing Magazine, Volume 9, Number 2, 1992 [27] "A Wavelet Magnitude Analysis Theorem", J.C.Anderson, pp. 3541 - 3543, IEEE Transactions on Signal Processing, Vol. 41, No. 12, December 1993 [28] "Wavelets and Signal Processing", O.Rioul, M.Vetterli, pp. 14 -35, IEEE Signal Processing Magazine, October 1991 [29] "TMS320C3x Evaluation Module", Technical Reference, Texas Instruments, 1990 [30] "Performance and Compatibility Requirements for Telephone Sets", Canadian Standards Association, National Standard of Canada, CAN/CSA-T510-M87, March 1987. [31 ] TLC32044C, TLC32044I Voice-Band Analog Interface Circuits, Linear Circuits Data Conversion, DSP Analog Interface, and Video Interface Data Book, Volume 2, Texas Instruments, 1992 [32] "Advanced Digital Signal Processing", J.G. Proakis, C M . Rader, F. Ling, C.L. Nikias, pp. 498 - 520, MacMillan Pubilishing Company, 1992 96 Appendices Appendix - A WARNSIS n TMS320C30 Assembly Language Code ********************************************* * FILENAME : warnsis.asm * WRITTEN BY : Kim Dotto * * DATE : 23rd June 1994 * * VERSION : 1.0 * * * ** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * VER DATE COMMENTS * . * 1.0 23rd June 94 TMS320C30 Implementation o f WARNSIS I I p r o j e c t * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * SYNOPSIS: * * * The WARNSIS Program i s designed t o d e t e c t the pr e s e n c e o f a u d i b l e warning * s i g n a l s . These s i g n a l s can be s i n g l e or r e p e t a t i v e b u r s t type i n n a t u r e , * o r th e y can be c o n t i n u o u s . T y p i c a l d e v i c e s g e n e r a t i n g t h e s e warning * s i g n a l s would be te l e p h o n e s , microwaves, smoke d e t e c t o r s o r o t h e r home * o r o f f i c e d e v i c e s . * * The WARNSIS II algorithms e l i m i n a t e the need f o r s p e c i a l i z e d hardware and * p r o v i d e s v e r y good performance i n n o i s y environments. S p e c t r a l a n a l y s i s * i s performed c o n t i n u o u s l y by software u s i n g the FFT i n s t e a d o f s p e c i a l i z e d * c h i p s e t s . The s t a r t or end of a warning s i g n a l b u r s t or r e p e t i t i o n i s * de t e r m i n e d by the presence o r absence o f key s p e c t r a l i n f o r m a t i o n f o r * a g i v e n warning s i g n a l . The FFT power spectrum f o r the r e a l t i m e i n p u t * i s compared t o i n f o r m a t i o n s t o r e d i n p r e d e f i n e d t e m p l a t e s . I f t h e * s p e c t r a l i n f o r m a t i o n matches the template a s p e c t r a l match i s r e g i s t e r e d . * The s i g n a l i s then c o n t i n u o u s l y m onitored u n t i l the s p e c t r a l s i g n a t u r e * d i s a p p e a r s . The b u r s t d u r a t i o n and i n t e r v a l times a r e then compared t o * those i n the template. I f a match o c c u r s f o r both s p e c t r a l and b u r s t * d u r a t i o n then a b u r s t match i s i n d i c a t e d . I f a match a l s o o c c u r s f o r * the i n t e r v a l time then an i n t e r v a l match i s i n d i c a t e d . * * Because the s p e c t r a l a n a l y s i s i s c a r r i e d out i n softw a r e , the WARNSIS I I * p r o j e c t can be p o r t e d t o any hardware w i t h s u f f i c i e n t power t o p e r f o r m * the FFT a n a l y s i s i n r e a l t i m e . T h i s i n c l u d e s a 50MHz 486 PC r u n n i n g under * MS Windows, where the software was o r i g i n a l l y d e s i g n e d . The Windows * program t h a t performs the a n a l y s i s i s c a l l e d WARNSIS.EXE and was w r i t t e n * f o r B o r l a n d ' s Turbo PASCAL f o r Windows Ver. 1.5. T h i s program and t h e * accompanying source f i l e s s h o u l d be a v a i l a b l e from the same s o u r c e as * t h i s f i l e . 97 T h i s v e r s i o n o f the WARNSIS I I p r o j e c t i s d e s g i n e d t o run on the Texas Instruments TMS320C30 DSP and the C30 E v a l u a t i o n Module and i s i n t e n d e d t o show t h a t the p r o j e c t can be implemented on a low c o s t DSP c h i p , n ot j u s t an I n t e l 80C486 50MHz system. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * FILES: WARNSIS.ASM WARNMATH.ASM WARNFFT.ASM WARNTWID.ASM Main program f i l e Math r o u t i n e s f o r F l o a t i n g P o i n t D i v i d e FFT s u b r o u t i n e code f i l e FFT t w i d d l e f a c t o r s f i l e ( s i n e t a b l e ) WARNFFT.CMD L i n k e r command f i l e * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * PASCAL PSEUDOCODE: program w a r n s i s ; c o n s t s i n e _ t a b l e = a r r a y [0. min_hz = 1000; max_hz = 4000; min_power = 1000; .255] o f r e a l ; {twiddle f a c t o r s } {minimum c u t o f f frequency} {maximum c u t o f f frequency} {minimum s p e c t r a l peak power below} {which peak w i l l not be considered} v a r i , j : i n t e g e r ; {general purpose counters} f i l l _ c n t : i n t e g e r ; { c u r r e n t p o s i t i o n o f t a b l e b e i n g f i l l e d } f ftdatO, f f t d a t l : a r r a y [0. . 511] o f r e a l ; {2 t a b l e s f o r c o l l e c t i n g i n p u t {and c a l c u l a t i n g f f t power {spectrum i n f o f f t t o t a l : a r r a y [0..511] of r e a l ; {storage f o r t o t a l f f t spectrum power {used i n l e a r n i n g mode m a x _ f f t : r e a l ; {maximum f f t magnitude i n power spectrum,used f o r { n o r m a l i z a t i o n o f power spectrum between samples a v e _ f f t : r e a l {average f f t magnitude i n power spectrum, g i v e s I { b a s e l i n e f o r comparison o f peak t o background n o i s e | {Each new type o f s i g n a l must be l e a r n e d b e f o r e i t can be d e t e c t e d } {each " l e a r n e d " s i g n a l has i t s own template w i t h the f o l l o w i n g i n f o } template = r e c o r d i n f o : s t r i n g [ 3 0 ] ; b u r s t _ d u r a t i o n : r e a l ; i n t e r v a l time : r e a l ; w a i t i n g end; boolean; {template name} {burst d u r a t i o n } { i n t e r v a l d u r a t i o n } { c u r r e n t l y matching spectrum f l a g ] p r o c e d u r e f f f t _ r l ( f f t _ s i z e , l o g _ s i z e : i n t e g e r ; source_addr, d e s t _ a d d r , 98 s i n e _ t a b l e : p t r ; b i t _ r e v e r s e : b o o l e a n ); b e g i n i f source_addr=dest_addr then c a l c u l a t e _ f f t _ i n p l a c e e l s e c a l c u l a t e _ f f t ; i f b i t _ r e v e r s e then d o _ b i t _ r e v e r s a l s ; end; { g e t _ r e a l t i m e _ d a t a i d c a l l e d upon end of c o n v e r s i o n i n t e r r u p t } p r o c e d u r e g e t _ r e a l t i m e _ d a t a : i n t e r r u p t b e g i n tmp_real:=get_analog_value; i f s t o r i n g _ t a b l e O then b e g i n f f t d a t O [ f i l l _ c n t ] : = t m p _ r e a l end e l s e b e g i n f f t d a t l [ f i l l _ c n t ] : = t m p _ r e a l end; i n c ( f i l l _ c n t ) ; s t a r t _ n e x t ^ c o n v e r s i o n ; end; b e g i n {main program) i n i t i a l i z e _ d a t a _ s t r u c t u r e s ; s t a r t _ f i r s t _ A / D _ c o n v e r s i o n ; r e p e a t i f learning_mode then b e g i n c a n c e l _ t e m p l a t e _ t e s t s ; i f c h e c k _ f o r _ a v a i l a b l e _ t e m p l a t e = t r u e then b e g i n i n i t i a l i z e _ t o t a l _ f f t _ j ? o w e r _ a r r a y ; w a i t _ f o r _ i n p u t _ s i g n a l _ a b o v e _ p r e d e f i n e d _ a m p l i t u d e ; s t a r t _ d u r a t i o n _ t i m e r ; s t a r t _ i n t e r v a l _ t i m e r ; w h i l e i n p u t _ a b o v e _ l i m i t do b e g i n c a l c u l a t e _ f f t _ e v e r y _ 5 1 2 _ s a m p l e s ; a d d _ c u r r e n t _ f f t _ m a g n i t u d e s _ t o _ t o t a l _ f f t _ m a g n i t u d e s end; e n d _ d u r a t i o n _ t i m e r ; s a v e _ d u r a t i o n _ t i m e ; f i n d _ m a i n _ p e a k _ i n _ f f t _ p o w e r _ s p e c t r u m ; save_peak_frequency_and_peak_width; w a i t _ f o r _ i n p u t _ s i g n a l _ a b o v e _ p r e d e f i n e d _ a m p l i t u d e _ a g a i n ; i f s e c o n d _ a m p l i t u d e _ i n c r e a s e _ f o u n d then b e g i n e n d _ i n t e r v a l _ t i m e r ; s a v e _ i n t e r v a l _ t i m e ; end e l s e c a n c e l _ i n t e r v a l _ t i m e r ; e x i t _ l e a r n i n g _ m o d e ; end e l s e i s s u e _ w a r n i n g ; end e l s e b e g i n i f f i l l _ c n t = 5 1 2 then b e g i n f i l l _ c n t : = 0 ; s e t _ o t h e r _ t a b l e _ t o _ b e _ f i l l e d ; i f f f t d a t O _ f u l l then f f f t _ r l ( 5 1 2 , 9 , f f t d a t O , f f t d a t O , s i n e _ t a b l e , f a l s e ) e l s e f f f t _ r l ( 5 1 2 , 9 , f f t d a t l , f f t d a t l , s i n e _ t a b l e , f a l s e ) { | f f t | and f i n d the maximum and average v a l u e o f t a b l e f o r those} { f f t v a l u e s f o r f r e q u e n c i e s between max_hz and min_hz } a v e _ f f t : = 0 max_fft:=0; j:=0; f o r i:=0 t o 255 do i f f f t _ h z [ i ] > m i n _ h z and f f t _ h z [ i ] < m a x _ h z then b e g i n i n c (j ) ; F f t _ r e a l [ i ] : = s q r t ( f f t _ r e a l [ i ] * f f t _ r e a l [ i ] + f f t _ i m a g [ i ] * f f t _ i m a g [ i ] ) ; i f f f t _ r e a l [ i ] > m a x _ f f t then m a x _ f f t : = f f t _ r e a l [ i ] ; a v e _ f f t : = a v e _ f f t + f f t _ r e a l [ i ] ; end; a v e _ f f t : = a v e _ f f t / j ; i d e n t i f y _ j ? e a k s ; { i d e n t i f y peaks i n spectrum > 0.25*max_fft} f o r a l l _ t e m p l a t e s do b e g i n f o r each_peak_found do i f ( a b s ( p e a k _ f r e q - t e m p l a t e _ f r e q ) < t e m p l a t e _ t o l e r a n c e ) and (peak_magnitute>2.5*ave_fft) and (peak_magnitude>min_jpower) then {found a s p e c t r a l match} b e g i n i f c u r r e n t l y _ t i m i n g _ a _ s p e c t r a l _ m a t c h _ f o r _ t h i s _ t e m p l a t e then b e g i n i f h a v e _ b e e n _ t i m i n g _ f o r _ a t _ l e a s t _ 2 _ s a m p l e _ p e r i o d s t h e n s e t _ f l a g _ t o _ i n d i c a t e _ v a l i d _ s t a r t _ o f _ s i g n a l ; c o n t i n u e _ t i m i n g _ s p e c t r a l _ m a t c h ; end; e l s e b e g i n s t a r t _ t i m i n g _ s p e c t r a l _ m a t c h ; end end e l s e b e g i n i f c u r r e n t l y _ t i m i n g _ a _ s p e c t r a l _ m a t c h _ f o r _ t h i s _ t e m p l a t e then i f h a v e _ l o s t _ t h e _ m a t c h _ f o r _ a t _ l e a s t _ 2 _ s a m p l e ^ p e r i o d s t h e n b e g i n s t o p _ t i m i n g _ s p e c t r a l _ m a t c h ; i f t i m i n g _ d u r a t i o n = t e m p l a t e _ v a l u e + - t o l e r a n c e then issue_duration_match_message; i f c u r r e n t l y _ t i m i n g _ i n t e r v a l then 100 * i f i n t e r v a l _ d u r a t i o n = t e m p l a t e _ v a l u e + - t o l e r a n c e then * i s s u e _ i n t e r v a l _ m a t c h _ m e s s a g e ; * r e s e t _ i n t e r v a l _ t i m e r _ f o r _ t h i s _ t e m p l a t e ; * end; * end; * end; * end * e l s e * w a i t _ f o r _ f u l l _ t a b l e * end; * u n t i l done; * end; * * ********************************************* . g l o b a l s i n e t a b . g l o b a l p r o c e s s _ m o d e , f i l l _ c n t , r l a _ a d d r , r l b _ a d d r . g l o b a l _ f f f t _ r l . g l o b a l SQRT . g l o b a l FINV . g l o b a l FDIV . g l o b a l f i n d _ p e a k s , f f t _ m a g n i t u d e , find_match, f i l l _ a r r a y , g e t _ d a t a . g l o b a l s t a r t _ l e a r n i n g , s t a r t _ a n a l y s i s , i d l e _ l o o p , s e t u p _ f f t . g l o b a l f c n t , w f i l l , p r o c e s s _ m o d e . g l o b a l m a x _ f f t , a v e _ f f t , c y c l e _ c n t . g l o b a l r l a _ a d d r , r l b _ a d d r , f f t _ a d d r . g l o b a l t _ i n f o , t _ c o n f i g , t _ b u r s t _ d u r , t _ i n t e r v a l _ t i m e . g l o b a l t_range_min,t_range_max,t_range_tol,t_range_peak . g l o b a l t _ w a i t i n g . g l o b a l peak_hz,peak_cnt,peaks_hcnt, p e a k s _ t c n t , g_up,peak_max . g l o b a l peak_cs . g l o b a l t2000 . . g l o b a l t _ s i g . g l o b a l shortmix . g l o b a l m i c r o s h t . g l o b a l no_message . g l o b a l t e s t _ b u r s t , t e s t _ i n t e r v a l , t e m p l a t e _ l o o p . g l o b a l c a s e l _ 0 , c a s e l _ l , c a s e l _ 2 , c a s e l _ 3 , c a s e l _ 4 , c a s e l _ e n d . g l o b a l case2_0,case2_l,case2_2,case2_3,case2_4,case2_end . g l o b a l c a s e3_0,case3_l,case3_2, case3_3, case3_4, case3_5, case3_end . g l o b a l c a s e4_0,case4_l,case4_2, case4_3, case4_4, case4_5, case4_end . g l o b a l found_burst,found_int,data_index,max_peak • g l o b a l a v e _ a m p l , l e a r n _ c n t , k e e p _ w a i t i n g , tmp_table . g l o b a l n o _ f f t _ r e q , f i n d _ t e m p l a t e , l ess_than_min,find_main_peak . g l o b a l f i n d _ a m p l i t u d e , s u m _ f f t s , c o p y _ f f t _ s u m , p i c k _ m a i n _ p e a k . g l o b a l s a v e _ t e m p l a t e _ i n f o , c l e a r _ t a b l e , a v e r a g e _ f f t _ s u m . g l o b a l s y s i n i t , a i c r e s e t , c o m _ j ? a r m , h c o n t r o l , r e c e i v e O . g l o b a l h r e a d l 6 , h w r i t e l 6 , h r e a d 3 2 , h w r i t e 3 2 . g l o b a l w a i t _ t r a n s m i t _ 0 , dmadone, w o r d f l a g /•Template I n f o r m a t i o n f o r 5 templates t _ i n f o .usect " . f f t d a t a " , 5 ;template name t _ b u r s t _ d u r .usect " . f f t d a t a " , 5 ; b u r s t d u r a t i o n t i n t e r v a l time .usect " . f f t d a t a " , 5 ; i n t e r v a l d u r a t i o n 101 t_range_peak .usect II . f f t d a t a " , 5 ;peak fre q u e n c y t _ w a i t i n g .usect II . f f t d a t a " , 5 / c u r r e n t l y matching spectrum f l a g t b s t a r t .usect II . f f t d a t a " , 5 ; b u r s t t i m e r s t a r t time t bend .usect II . f f t d a t a " , 5 ; b u r s t t i m e r end time t i n t count .usect II . f f t d a t a " , 5 ; i n t e r v a l t i m e r p r o c e s s mode .usect II . f f t d a t a " , 1 ;analyze=0 l e a r n = l f i l l _ c n t .usect II . f f t d a t a " , 1 ; r e a l t i m e d a t a count f l a g f c n t .usect II . f f t d a t a " , 1 ; r e a l t i m e d a t a count w f i l l .usect II . f f t d a t a " , 1 ; r e a l t i m e d a t a a r r a y f l a g c y c l e c n t .usect II . f f t d a t a " , 1 ; t i m i n g c y c l e c o u n t e r n o n e _ w a i t i n g .usect II . f f t d a t a " , 1 ;no templates w a i t i n g f l a g l e a r n _ c n t .usect II . f f t d a t a " , 1 ; l e a r n i n g mode c y c l e c o u n t e r ave ampl .usect H . f f t d a t a " , 1 /average i n p u t s i g n a l s t r e n g t h t e s t ampl .usect II . f f t d a t a " , 1 /average i n p u t s i g n a l s t r e n g t h peak c n t .usect II . f f t d a t a " , 1 /number o f peaks i n spectrum g_up .usect II . f f t d a t a " , 1 /going up a peak o r down? peak hz .usect II . f f t d a t a " , 60 / f r e q u e n c y bin# o f i d e n t i f i e d peak peak_max .usect II . f f t d a t a " , 60 /power o f i d e n t i f i e d peaks r l a addr .usect ti . f f t d a t a " , 1 / t a b l e 0 address r i b addr .usect tt . f f t d a t a " , 1 / t a b l e 1 address f f t _ a d d r .usect ti . f f t d a t a " , 1 / f f t t a b l e address d a t a index .usect II . f f t d a t a " , 1 /address index o f r e a l d a t a max f f t .usect II . f f t d a t a " , 1 /maximum v a l u e f o r n o r m a l i z a t i o n a v e _ f f t .usect II . f f t d a t a " , 1 /average f f t magnitude tmp t a b l e .usect it .tmpdata", 256 ;temporary t a b l e f o r summing f t t s max_peak .usect II f f t d a t a " , ! /peak w i t h g r e a t e s t magnitude i n FFT peak cs .usect II f f t d a t a " , 1 0 / f r e q u e n c y bin# o f i d e n t i f i e d peaks peaks hcnt .usect II f f t d a t a " , 1 /peak w i t h g r e a t e s t magnitude i n FFT peaks_ t c n t .usect II f f t d a t a " , 1 /peak w i t h g r e a t e s t magnitude i n FFT cont f l a g .usect tt . f f t d a t a " , 1 / c o n t i n o u s s i g n a l f l a g s t a c k _ s i z e . s e t 500 s t a c k .usect " . s t a c k " , s t a c k s i z e . s e c t " . v e c s " PARMS: r e s e t .word wa r n s i s i n t o .word cmd_write i n t l .word n u l l i n t i n t 2 .word n u l l _ i n t / h r e a d l 6 i n t 3 . word n u l l i n t x i n t O .word tra n s m i t O ; r i n t O .word r e c e i v e O 102 r i n t O .word f i l l a r r a y x i n t l . word t r a n s m i t l r i n t l . word r e c i e v e l t i n t O .word n u l l i n t t i n t l .word t i m e r l d i n t O . word n u l l i n t .data min ampl . f l o a t 500.0 /minimum amplitude (500) min_power . f l o a t 3.0e6 ;6 /minimum s p e c t r a l peak power h o s t p o r t . word 000804000h ramO addr . word 809800H rami addr .word 809C00H ramla addr .word 809C00H ramlb addr . word 809E00H tmp addr . word tmp t a b l e /address temp c a l c u l a t i o n t a b l e peak t a b l e . word peak hz /address o f peak t a b l e peak mtable . word peak max /address o f peak maximum v a l u e s s i n e . word s i n e t a b /address o f t w i d d l e f a c t o r s t e m p l a t e s . word t i n f o /address o f templ a t e i n f o t _ r p .word t_range_peak /address o f templ a t e peaks t_bdur .word t b u r s t dur /address of template b u r s t d u r a t i o n s t w a i t .word t _ w a i t i n g /address o f template w a i t i n g f l a g s t _ s t a r t .word t _ b s t a r t /address o f template b u r s t s t a r t t_end .word t bend /address o f template b u r s t end t _ i n t .word t i n t e r v a l time /address o f template i n t e r v a l time t _ i n t c .word t i n t count /address o f template i n t e r v a l count temp_def .word template d e f a u l t s /address o f template d e f a u l t s peak c t a b l e .word peak_cs /address o f peak t a b l e peaks_hcount .word peaks_hcnt /address o f peak t a b l e i n d e x p e a k s _ t c o u n t .word p e a k s _ t c n t /address o f peak t a b l e i n d e x f f t voc d a t a .word m i c r o s h t /address o f r e a l t i m e d a t a template d e f a u l t s .word 0 /template names . word 1 .word 2 .word 3 .word 4 .word 13 / b u r s t d u r a t i o n s . word 34 . word 1000 . word 1000 .word 1000 .word 26 / i n t e r v a l times . word 92 .word 1000 .word 1000 . word 1000 103 .word . word . word . word .word 92 101 255 255 255 ;range peak .word .word . word . word . word ;waiting state flags .word .word . word . word . word ;burst timer s t a r t times .word .word .word . word . word ;burst timer end times .word .word .word .word .word ; i n t e r v a l timer s t a r t times . sect ".aicdata" ;stack_addr .word ;intl_hwrl6 .word ;intl_hwr32 .word ;intl_cwr .word ;int2_hrdl6 .word ;int2_hrd32 .word ;cmd_temp .word parameters ;com_j?arm .word ;wordflag .word stack hwritel6 hwrite32 cmd_write hreadl6 hread32 com_cmd com_stat 0 ;address of stack /Address of 16 b i t host write function /Address of 32 b i t host write function /Address of command write function /Address of 16 b i t host read function /Address of 32 b i t host read function /Temporary address of command /Address of command parameters * Addresses of various peripherals and memory control r e g i s t e r s * *********************************************************** ;dma_ctl mcntlrO mcn t l r l tO_ctladdr t l _ c t l a d d r p0_addr .word 000808000h /dma global control r e g i s t e r .word 000808064h / i / o i n terface control reg. addr. .word 000808060h / p a r a l l e l i n t e r f . c n t l . reg. addr. .word 000808020h /Timer 0 .word 000808030h . /Timer 1 .word 000808040h / S e r i a l port 0 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Control parameters to large to f i t i n immediate value * ***************************************************************** 104 e n b l _ e i n t l e n b l _ e i n t 2 e n b l _ s p O _ r i n t o f f i n t c l r tO c t l i n i t . word .word .word .word .word .word 000020400h 000040400h 000000020h O f f f O f b f l h O f f f f f f f 9 h 0C00002Clh ; i n t l e n t e r r u p t dma (host w r i t e s ) ; i n t 2 i n t e r r u p t dma (host w r i t e s ) ; s e r i a l p o r t 0 r e c e i v e i n t e r r u p t ; t u r n o f f i n t l , i n t 2 , i n t 3 , e i n t O , e i n t l ; e i n t 2 , e i n t 3 , dma ; c l r out i n t 0 - 2 ; s e t t i m e r as e l k out, Hl/2 p e r i o d ; t i m e r w i l l run when cpu s t o p s i n ;emulation mode p 0 _ g l o b a l .word 00e970300h ; s e r i a l p o r t 0 g l o b a l c o n t r o l r e g i s t e r ;dma_wctl .word 0C0000943h ;dma w r i t e c o n t r o l ;com. r e g . -> C30 mem. ; i n t e r r u p t d r i v e n from h o s t w r i t e s ; d m a _ r c t l .word 0C0000A13h ;dma read c o n t r o l ;c30 mem -> com r e g ; i n t e r r u p t d r i v e n from h o s t reads * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Host communications command s t r u c t u r e * ***************************************************************** ; com s t a t .word OOOOOOOOOOh /command s t a t u s ; com cmd .word OOOOOOOOOOh ;command ; com_ c o u n t l . word OOOOOOOOOOh / t r a n s f e r count low ; com counth . word OOOOOOOOOOh / t r a n s f e r count h i g h ; com s a d d r l . word OOOOOOOOOOh ;source addr low ; com saddrh .word OOOOOOOOOOh ;source addr h i g h ; com "daddrl .word OOOOOOOOOOh ; d e s t i n a t i o n a d d r e s s ; com daddrh . word OOOOOOOOOOh /•d e s t i n a t i o n a d d r e s s * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * V a r i o u s c o n s t a n t s * WAITO . s e t OOOOh ;memory c o n t r o l r e g v a l , p a r a l l e l bus WAITl . s e t OOOOh ;memory c o n t r o l r e g v a l , i / o bus CACHE . s e t 1800h ; c l e a r and enable cache ENBL_GIE . s e t 2000h : ; g l o b a l i n t e r r u p t e n able ENBL INTO . s e t OOOlh ; i n t e r r u p t 0 enable ENBL INT1 . s e t 0002h ; i n t e r r u p t 1 enable ENBL INT2 . s e t 0004h ; i n t e r r u p t 2 enable ENBL INT3 . s e t 0008h ; i n t e r r u p t 3 enable ENBL XINTO . s e t OOlOh ; s e r i a l p o r t 0 t r a n s m i t i n t . e n a b l e ENBL RINTO . s e t 0020h ; s e r i a l p o r t 0 r e c e i v e i n t . e n a b l e ENBL_XINT1 . s e t 0040h ; s e r i a l p o r t 1 t r a n s m i t i n t . e n a b l e ENBL RINT1 . s e t 0080h / s e r i a l p o r t 1 r e c e i v e i n t . e n a b l e ENBL_TINTO . s e t OlOOh ;time r 0 i n t e r r u p t e n able ENBL_TINT1 . s e t 0200h ;time r 1 i n t e r r u p t e n able ENBL_DINT . s e t 0400h ;dma i n t e r r u p t enable (cpu) BEGIN CMD SEND . s e t 1 ;Begin sending cmd parameters END CMD SEND . s e t 2 ;End s e n d i n g cmd parameters INIT_DONE . s e t 5 ;Reset i n t i a l i z a t i o n complete CMD_OK . s e t 0 /•Received cmd parameters ok CMD_ERROR . s e t -1 / E r r o r on r e c e i v i n g command parameter 105 CMD FINISH . s e t 0 CMD" "LOAD . s e t 1 CMD_ _ACTIVE . s e t 2 CMD NOP . s e t 10 CMD "HOST MR 16 . s e t 11 CMD" ~H0ST_MW16 . s e t 12 CMD HOST MR32 . s e t 13 CMD HOST MW32 . s e t 14 CMD" "HOST DMAR . s e t 15 CMD" "HOST DMAW . s e t 16 / S t a t u s , command i s f i n i s h e d / S t a t u s , command i s b e i n g l o a d e d / S t a t u s , command i s c u r r e n t l y a c t i v e /Nop command /C30 memory read, 16 b i t mode /C30 memory w r i t e , 16 b i t mode /C30 memory read, 32 b i t mode /C30 memory w r i t e , 32 b i t mode /C30 memory read v i a dma, 16 b i t mode /C30 memory w r i t e v i a dma, 16 b i t mode w a r n s i s : . t e x t xor i e , i e xor i f , i f s t a r t i n i t : end i n i t : d e f a u l t s xor R0,R0 ld p @raml_addr,DP l d i @fft_voc_data,AR0 s t i AR0,@data index l d i @raml_addr,ARO l d i @sine,AR2 l d i 1023,RC r p t b end i n i t l d f *AR0,R1 subf 128,Rl l d i 0,R1 s t i Rl,*AR0++ l d i @ramla_addr, ARO l d i @ramlb_addr, AR1 ld p Sprocess mode, DP s t i ARO,@rla addr s t i AR1,@rlb_addr s t i R0,@process mode s t i R0,@fcnt s t i R0,Speaks hcnt s t i R0,@peaks_tcnt l d i Shostport,AR4 s t i R0,*AR4 not R0,R1 s t i R l , @ w f i l l s t i Rl,@process mode s t i R 0 , @ f i l l _ c n t s t i R0,@cycle_cnt s t i R0,@none w a i t i n g l d i @templates,ARO l d i @temp d e f , A R l l d i 39,RC r p t b end temp l d i *AR1++,R1 ; c l r R0 /s e t d a t a page /get address o f r e a l d a t a /save i t i n d a t a _ i n d e x / l o a d address o f RAMla b l o c k / l o a d address o f s i n e t a b l e / l o a d r e p e a t c o u n t e r f o r 1024 /re p e a t s /get r e a l d a t a / s u b t r a c t 128 o f f s e t /save a d j u s t e d r e a l d a t a / s t a r t f i r s t A/D c o n v e r s i o n / l o a d address o f RAMla b l o c k / l o a d address o f RAMlb b l o c k / s e t d a t a page /save t a b l e a d d r e s s c u r r e n t /data page / s e t f o r normal o p e r a t i o n / / s e t c o u n t e r t o ze r o / s e t peak t a b l e head p o i n t e r = 0 / s e t peak t a b l e t a i l p o i n t e r = 0 /send 0 t o pc /s e t i n i t i a l t a b l e / s e t f o r l e a r n i n g mode; /s e t f i l l _ c n t t o 0 /s e t t i m e r count t o 0 /s e t no templates w a i t i n g t o 0 / l o a d address o f templat e i n f o / l o a d address o f tem p l a t e / r e p e a t s 106 end_temp: s t i Rl,*AR0++ / s e t up d e f a u l t t e m p l a t e s l d p PARMS or ENBL GIE,ST /enable g l o b a l i n t e r r u p t o r ENBL XINT0,IE /enable s e r i a l p o r t 0 t x i n t / o r ENBL INT2,IE /enable s e r i a l p o r t 0 t x i n t or ENBL INTO,IE /enable s e r i a l p o r t 0 t x i n t or ENBL_RINTO, IE /enable s e r i a l p o r t 0 rx i n t c a l l a i c r e s e t / r o u t i n e t o r e s e t a i c l d p @process_mode, DP / s e t d a t a page /The p r o c e s s o r w a i t s here w h i l e i t f i l l s the a r r a y s w i t h d a t a /when an a r r a y i s f u l l then p r o c e s s i n g b e g i n s i d l e l o o p : xor R0,R0 cmpi @process mode, RO /are we i n l e a r n i n g mode? beq d o _ a n a l y s i s / i f we a r e do l e a r n i n g r o u t i n e c a l l u s t a r t l e a r n i n g d o _ a n a l y s i s : c a l l f i l l a r r a y /get d a t a l d i @ f i l l _ c n t , R O / e l s e have we 512 p i e c e s o f data? cmpi 512,RO / i f we do p r o c e s s then c a l l e q s t a r t a n a l y s i s / e l s e w a i t f o r more d a t a b r i d l e l o o p end i d l e : / A n a l y s i s S u b r o u t i n e s s e t u p _ f f t : l d i 1,R0 /set f l a g f o r doing b i t r e v e r s a l s push RO /put i t on the s t a c k l d i @sine,RO /get address o f s i n e t a b l e push RO /put i t on the s t a c k l d i @rla addr,R0 /get address o f d a t a t a b l e 0 l d i @ w f i l l , R l /get which t a b l e f l a g w f i l l not R1,R1 / n o t ( w f i l l ) t o r e c o v e r f l a g cmpi 0,R1 /are we u s i n g t a b l e 0? beq f f t 0 " l d i @rlb_addr,RO /no then get t a b l e 1 ad d r e s s f f t j ) : s t i R0,@fft addr /save l o c a t i o n o f f f t when done push RO /push c o r r e c t t a b l e a d d r e s s on push RO /stack f o r b o t h s o u r c e and d e s t . l d i 9,R0 / l o g ( f f t s i z e ) : = 9 push RO /put i t on the s t a c k l d i 512,RO / f f t s i z e : = 5 1 2 push RO /put i t on the s t a c k xor ENBL GIE,ST / d i s a b l e g l o b a l i n t e r r u p t c a l l f f f t r l / c a l c u l a t e f f t o r ENBL_GIE, ST /enable g l o b a l i n t e r r u p t pop RO /get r i d o f parameters f o r pop RO ; _ f f f t _ r l pop RO 107 pop RO pop RO pop RO r e t s u / S u b r o u t i n e t o pe r f o r m Main A n a l y s i s f o r s i g n a l d e t e c t i o n s t a r t a n a l y s i s : xor R0,R0 s t i R O , @ f i l l _ c n t r l d i @hostport,AR4 t s t i RO,*AR4 / send i t t o pc ld p dprocess mode,DP / s e t d a t a page l d i S c y c l e cnt,RO /get c y c l e c n t ad d i 1,R0 / i n c ( c y c l e cnt) s t i RO,@cycle_cnt /save c y c l e c n t xor ENBL_GIE, ST / d i s a b l e g l o b a l i n t e r r u p t c a l l s e t u p _ f f t • l d p @raml addr,DP / s e t d a t a page 1 l d i @raml_addr,ARO / l o a d address o f RAMla b l o c k c a l l f f t magnitude / c a l c magnitude, maximum and ave 1 l d p @raml addr,DP / s e t d a t a page r l d i @raml_addr,ARO / l o a d address o f RAMla b l o c k c a l l f i n d _ p e a k s / f i n d peaks i n spectrum c a l l find_match / f i n d any template matches e n d _ a n a l y s i s : r e t s u / L e a r n i n g S u b r o u t i n e s t a r t l e a r n i n g push DP push ARO template i n t e r v a l time push AR1 /template b u r s t d u r a t i o n push AR2 / b u r s t t i m e r end times push AR3 / b u r s t t i m e r s t a r t t imes push AR4 w a i t i n g f l a g s push AR5 /template peak v a l u e s push AR6 •peak t a b l e magnitudes push AR7 •peak t a b l e peak v a l u e s push RO push RI push R2 push R3 push R4 found f l a g push R5 •w a i t i n g f l a g push R7 push IRO peak t a b l e s index push IR1 •template t a b l e s i n d e x l d p @peak_hz, DP •set d a t a page l d i Speak table,AR7 •get address o f peak t a b l e l d i Speak mtable,AR6 /get address o f peak max t a b l e l d i @t rp,AR5 /get address o f template peaks l d i @t_wait,AR4 •get address o f template f l a g s 108 /get address o f b u r s t t i m e r s t a r t ;get address o f b u r s t t i m e r end ;get address o f i n t e r v a l t i m e r ;template_index:=0 ; s e t t e s t amplitude f l a g ;send f l a g f o r l e a r n i n g mode / i n s e r t code here t o / c a n c e l a l l w a i t i n g templates from p r o c e s s mode /when e n t e r i n g l e a r n i n g mode, can be done w h i l e l o o k i n g / f o r b l a n k template because a l l unused templates a r e a f t e r /the templates t h a t are b e i n g used l d i @t s t a r t , A R 3 l d i @t end,AR2 l d i @t_intc,AR0 l d i 0,IR1 l d f -1.0,R0 s t f RO,@test_ampl l d i 0E000h,R7 c a l l w r i t e queue found_template: k e e p _ w a i t i n g : f f t 00: l d i *+AR5(IR1) , RO cmpi 255,RO / i f template_peak = 255 then beq found template / found b l a n k template a d d i 1, IR1 / e l s e b r f i n d template / i n c ( i n d e x ) and t r y a g a i n l d i 0E020h,R7 a d d i IR1,R7 c a l l w r i t e queue /send f l a g f o r l e a r n i n g mode / save c y c l e count here t o s e t a b s o l u t e time l i m i t on / l e a r n i n g c y c l e t o r e c o v e r from unknown s i g n a l l d i d c y c l e cnt,R0 s t i RO,61earn_cnt xor R0,R0 s t i R0,@cont f l a g / c ontinuous s i g n a l f l a g s t i RO,*+AR2(IR1) • zero b u r s t end s t i RO,*+AR3(IR1) b u r s t s t a r t s t i RO,*+AR0(IR1) and i n t e r v a l times c a l l c l e a r t a b l e c l e a r f f t sum t a b l e c a l l f i l l a r r a y /get d a t a l d i S f i l l cnt,R0 •do we have 512 p i e c e s o f data ? cmpi 512,RO bne keep_waiting •no then keep c o l l e c t i n g d a t a xor R0,R0 s t i R 0 , @ f i l l c n t • r e s e t f i l l c n t f l a g t o w a i t l d i d r l a addr,R0 /get address o f d a t a t a b l e 0 l d i @ w f i l l , R l /get which t a b l e f l a g w f i l l not R1,R1 / n o t ( w f i l l ) t o r e c o v e r f l a g cmpi 0,R1 /are we u s i n g t a b l e 0? beq f f t 00 l d i @rlb_addr,R0 •no then get t a b l e 1 a d d r e s s s t i R0,@fft_addr •save l o c a t i o n o f f f t when done l d p @process_mode,DP / s e t d a t a page 109 not c o n t i n u o u s l d i @cycle cnt,R0 ;get c y c l e c n t a d d i 1,R0 ; i n c ( c y c l e cnt) s t i RO,@cycle c n t ;save c y c l e c n t l d i @cycle cnt,R0 ;get c u r r e n t c y c l e c n t l d i @learn c n t , R l ;get count a t s t a r t o f l e a r n c y c l e s u b i RI, RO cmpi 300,RO ;have we spent more than 500 c y c l e s b i t keep g o i n g ; ~20 seconds cmpi 2,R5 ; i f not t i m i n g b u r s t then end mode b i t end l e a r n i n g cmpi 4,R5 ; i f f i n i s h e d b u r s t then not c o n t i n . bge not c o n t i n u o u s l d i 2,R0 s t i R0,@cont f l a g b r find_main_peak l d i 1,R0 s t i RO,@cont_flag b r f i n d main_peak keep_going: bg_ok: c a l l f i n d amplitude ;get average amplitude l d f @test ampl,R0 cmpf -1,R0 ,-have we sampled background l e v e l bne bg ok l d f @ave ampl,R0 mpyf 1.5,R0 / m u l t i p l y by 1.5 s t f RO,@test ampl ;save 1 . 5 * f i r s t sample as background l d i *+AR4(IR1) ,R5 ;get w a i t i n g f l a g ; cmpi 4,R5 ;have we f i n i s h e d w i t h b u r s t bge no f f t r e q ;then j u s t w a i t t o i d e n t i n t e r v a l cmpi 1,R5 b i t no f f t r e q n o _ f f t _ r e q : xor ENBL_GIE, ST ; d i s a b l e g l o b a l i n t e r r u p t c a l l setup f f t / c a l c u l a t e c u r r e n t f f t x o r ENBL_GIE, ST / d i s a b l e g l o b a l i n t e r r u p t c a l l f f t magnitude / c a l c u l a t e c u r r e n t f f t magnitudes c a l l sum f f t s ;add t o t o t a l magnitudes or ENBL_GIE,ST /enable g l o b a l i n t e r r u p t xor R0,R0 s t i R O , @ f i l l _ c n t ; r e s e t f i l l c n t l d f @ave ampl,R0 ;get average s i g n a l a m p l i t u d e f i x R0,R7 c a l l w r i t e queue l d f @min ampl,R2 ;get minimum a l l o w a b l e a m p l i t u d e l d f . @test ampl,r2 ;use t e s t background i n s t e a d f i x R2, R7 c a l l w r i t e queue cmpf R2,R0 ; i f average amplitude < m i n l e v e l t h e n b i t l e s s than min 110 case3 _0: cmpi 0, R5 bne case3 1 l d i S c y c l e cnt,R0 s t i RO,*+AR3(IR1) l d i 1,R0 s t i RO, *+AR4(IR1) b r case3 end case3 _1: cmpi 1,R5 bne case3 2 l d i 2,R0 s t i RO, *+AR4(IR1) b r case3 end case3 2: cmpi 2, R5 bne case3_3 b r case3_end case3 _3: cmpi 3, R5 bne case3 4 l d i 2, RO s t i RO,*+AR4(IR1) b r case3 end case3 _4 cmpi 4,R5 bne case3 5 l d i @cycle cnt,R0 s t i RO,*+AR0(IR1) l d i 5,R0 s t i RO,*+AR4(IR1) b r case3 end case3 _5 cmpi 5,R5 bne case3 end l d i 6,R0 s t i RO,*+AR4(IR1) b r case3 end case3 end: b r case4_end l e s s _ than_min: case4 _0: cmpi 0,R5 bne case4 1 b r case4 end case4 _1: cmpi 1,R5 bne case4 2 l d i 0,R0 s t i RO, *+AR3(IR1) s t i RO,*+AR4(IR1) c a l l c l e a r t a b l e b r case4_end case4 _2: cmpi 2,R5 bne case4 3 l d i S c y c l e cnt,R0 s t i RO,*+AR2(IR1) l d i 3,R0 s t i RO,*+AR4(IR1) b r case4 end case4 3: cmpi 3,R5 bne case4 4 l d i 4,R0 s t i RO,*+AR4(IR1) b r case4 end 0:begin save b u r s t s t a r t time waiting:=1 end 1:begin waiting:=2 end 2:begin do n o t h i n g end; 3:begin waiting:=2 end 4:begin save i n t e r v a l time waiting:=5 end 5:begin waiting:=6 end end case w a i t i n g o f 0:begin do n o t h i n g end 1:begin r e s e t b u r s t s t a r t time waiting:=0 c l e a r FFT magnitude sums end 2:begin save b u r s t end time waiting:=3 end 3:begin waiting:=4 end 111 case4_4: cmpi bne b r case4_5: cmpi bne l d i s t i b r case4_end: l d i cmpi bne find_main_peak: xor c a l l c a l l c a l l c a l l o r s a v e _ t e m p l a t e _ i n f o : l d i s t i l d i a d d i c a l l l d i l d i s u b i l d i l d i s u b i l d i l d i l d i cmpi b i t l d i n o _ s e t _ i n t : cmpi b i t l d i n o _ s e t _ b u r s t : s t i s t i l d i a d d i c a l l l d i a d d i 4, R5 case4_4 case4_end 5, R5 case4_end 4,R0 RO, *+AR4(IR1) case4 end 4:begin do n o t h i n g end 5:begin waiting:=4 end end *+AR4(IR1),R5 ;get w a i t i n g f l a g 6,R5 ;are we f i n i s h e d ? k e e p _ w a i t i n g ;no then keep w a i t i n g ; e l s e ENBL_GIE,ST / d i s a b l e g l o b a l i n t e r r u p t c o p y _ f f t _ s u m ;copy sum from temporary t a b l e a v e r a g e _ f f t _ s u m / c a l c u l a t e max and average o f sum find_peaks / f i n d the peaks i n sum t a b l e pick_main_peak / p i c k the l a r g e s t peak ENBL_GIE,ST /enable g l o b a l i n t e r r u p t @max_peak,RO RO,*+AR5(IR1) OElOOh,R7 R0,R7 write_queue *+AR3(IR1),R0 *+AR2(IR1),R1 R0,R1 *+AR3(IR1) ,R0 *+AR0(IR1) ,R2 R0,R2 @t_bdur,AR2 @t_int,AR3 @cont_flag,RO 1,R0 n o _ s e t _ i n t 0,R2 /get f r e q u e n c y o f maximum peak /save i t i n t a b l e /send f l a g f o r l e a r n i n g mode /get b u r s t s t a r t time /get b u r s t end time /get d i f f e r e n c e /get b u r s t s t a r t time /get i n t e r v a l time /get d i f f e r e n c e /get addr of template b u r s t d u r r a t i o n /get addr o f template i n t e r v a l time /get c o n t i n o u s f l a g 2,R0 n o _ s e t _ b u r s t 0,R1 Rl,*+AR2(IR1) R2,*+AR3(IR1) 0E200h,R7 R1,R7 write_queue 0E300h,R7 R2,R7 /save b u r s t d u r r a t i o n i n templ a t e /save i n t e r v a l time i n t e m p l a t e /send f l a g f o r l e a r n i n g mode 112 c a l l write_queue ;send f l a g f o r l e a r n i n g mode e n d _ l e a r n i n g : ;send f l a g f o r l e a r n i n g mode l d i 0E010h,R7 c a l l write_queue xor R0,R0 s t i RO,@process_mode ; s e t f o r normal o p e r a t i o n s t i RO, *+AR4 (IR1) ;waiting:=0 so i t w i l l d e t e c t l a t e r o r ENBL GIE,ST /enable g l o b a l i n t e r r u p t pop pop pop pop pop pop pop pop pop pop pop pop pop pop pop pop pop pop IR1 IRO R7 R5 R4 R3 R2 RI RO AR7 AR6 AR5 AR4 AR3 AR2 AR1 ARO DP r e t s u ; F i n d _ a m p l i t u d e f i n d s the average a b s o l u t e amplitude o f the i n p u t s i g n a l ; t o t e s t f o r b e g i n i n g and end of s i g n a l b u r s t . f i n d a mplitude: sum_average: push DP push AR7 push R4 push R3 push R2 push RI push RO push RC push RE l d f 0,R0 l d i @ f f t addr,AR7 l d i 511,RC r p t b sum average l d f *AR7++,R1 ab s f R1,R1 addf R1,R0 f l o a t 512,RI c a l l FDIV s t f RO,@ave_ampl ;get a ddress o f c u r r e n t f f t t a b l e ; s e t t o sum 255 words ;get c u r r e n t i n p u t d a t a ;get a b s o l u t e v a l u e ;add t o t a l ; d i v i d e sum by 512 t o get average ; i n p u t a b s o l u t e a m plitude and ;save i t i n ave_ampl 113 pop RE pop RC pop RO pop Rl pop R2 pop R3 pop R4 pop AR7 pop DP retsu ;Sum f f t s sums the current FFT magnitudes with those saved i n the t o t a l sum f f t s : sum table: table tmp table push DP push AR7 push AR6 push Rl push RO push RC push RE l d f 0, RO l d i dtmp addr,AR7 ;get address of temporay table l d i @fft addr,AR6 ;get address of current f f t table l d i 254,RC ;set to sum 255 words rptb sum table ldp @raml addr,DP ;get data page of current f f t table l d f *AR6++,R0 ;get current f f t magnitudes ldp @tmp table,DP ;get data page of temporary table l d f *AR7,R1 ;get f f t sum from temporary table addf R1,R0 ;add current f f t to table s t f RO,*AR7++ ;and save sum i n tmp_table pop RE pop RC pop RO pop Rl pop AR6 pop AR7 pop DP retsu ; Copy_fft_sum copys Sum of FFT magnitudes back to the FFT arrays so that ;Find_jpeaks subroutine can operate copy_fft_sum: push DP push AR7 push AR6 push RO push RC push RE l d i @tmp addr,AR7 l d i @fft_addr,AR6 ;get address of temporay table ;get address of current f f t table 114 copy_sum: l d i r p t b ld p l d f l d p s t f pop pop pop pop pop pop r e t s u 254,RC copy_sum @tmp_table, DP *AR7++,R0 @raml_addr, DP RO,*AR6++ RE RC RO AR6 AR7 DP ' s e t t o copy 255 words ;get d a t a page o f temporary t a b l e ;get f f t sum from temporary t a b l e ;get data page of c u r r e n t f f t t a b l e ; f f t _ t a b l e [ A R 6 ] : = t m p _ t a b l e [ A R 7 ] ; F i n d the average amplitude o f f f t peaks from the sum o f a l l t h e f f t s a v e r a g e _ f f t _ s u m : push push push push push push push push push push push l d p xor s t f s t f l d i l d i l d i r p t b cmpi b i t l d f l d f cmpf b i t s t f no new amax: end_ave_loop: l d f addf s t f a d d i l d f l d f c a l l s t f DP RE RC AR5 AR6 RO RI R2 R3 R4 IRO @rla_addr,DP RO, RO RO,@max_fft RO,@ave_fft @fft_addr,AR5 1, IRO 254,RC end_ave_lpop .58,IRO end_ave_loop *+AR5(IRO) ,R0 @max_fft,Rl R1,R0 no_new_amax RO,@max_fft @ a v e _ f f t , R l RO, RI RI,@ave_fft 1, IRO @ave_fft, RO 197,RI FDIV RO,Save f f t ; s e t d a t a page ;max_fft:=0 ; a v e _ f f t : = 0 ;get address o f f f t t a b l e ; s e t i n dex t o 1 ;255 v a l u e s ; i f l e s s than 900HZ th e n ;@ sample r a t e 8000Hz ;don't c a l c u l a t e max o r ave ;get f f t _ r e a l [ I R O ] ;get c u r r e n t m a x _ f f t ; i f max_fft>new magnitude ;then don't pdate m a x _ f f t ; e l s e s t o r e new max ; a v e _ f f t : = a v e _ f f t + m a x _ f f t ;inc(IRO) ;get average t o t a l ;get number o f a d d i t i o n s ;note 197 f o r sample r a t e ;of 8000 Hz ;save i t 115 ave sum end: pop IRO pop R4 pop R3 pop R2 pop R l pop RO pop AR6 pop AR5 pop RC pop RE pop DP r e t s u ; Pick_main_peak scans the peak t a b l e g e n e r a t e d by f i n d _ p e a k s and l o o k s ; f o r the peak w i t h the g r e a t e s t magnitude pi c k _ m a i n _jpeak: push DP push AR5 push AR6 push AR7 push RO push R l push RC push RE l d f 0,R0 ; t e s t mag:=0 l d i 0,AR5 ;max_peak:=0 l d p Speak hz,DP ; s e t d a t a page l d i @peak_table,AR7 ;get address o f peak t a b l e l d i Speak mtable,AR6 ;get address o f peak max t a b l e l d i Speak cnt,RC ;get peak c n t su b i 1,RC ; s e t t o t e s t a l l peaks found r p t b next_peak l d f *AR6++, R l ;get peak magnitude cmpf R l , RO ; i s i t b i g g e r than c u r r e n t bgt next_peak ; i f g r e a t e r than l d f R l , RO ;then save magnitude and l d i AR7,AR5 ;index t o peak frequency t a b l e a d d i 1,AR7 ; i n c ( i n d e x ) l d i *AR5,R0 s t i RO, Smax_jpeak pop RE pop RC POP R l pop RO pop AR7 pop AR6 pop AR5 pop DP r e t s u :get frequency o f l a r g e s t peak ;save i t i n max_peak ; C l e a r _ t a b l e c l e a r s the FFT magnitude sum t a b l e 1 1 6 c l e a r _ t a b l e : push DP push AR7 push RO push RC push RE l d f 0,RO ldp @tmp_addr,DP l d i @tmp_addr,AR7 l d p @tmp_table, DP l d i 254,RC r p t b c l r _ t a b l e c l r _ t a b l e : s t f R0,*AR7++ ;tmp_table[AR7]:=0.0 pop RE pop RC pop RO pop AR7 pop DP r e t s u /Matching S u b r o u t i n e matches peaks found i n fi n d _ p e a k s t o i n f o / s t o r e d i n templates f i n d match: push DP push ARO /template i n t e r v a l time push AR1 /template b u r s t d u r a t i o n push AR2 / b u r s t t i m e r end times push AR3 / b u r s t t i m e r s t a r t times push AR4 / w a i t i n g f l a g s push AR5 /template peak v a l u e s push AR6 /peak t a b l e magnitudes push AR7 /peak t a b l e peak v a l u e s push RO push R l push R2 /min_power push R3 / 2 . 5 * a v e _ f f t push R4 ;foung f l a g push R5 / w a i t i n g f l a g push R7 t push IRO /peak t a b l e s index push IR1 /template t a b l e s i n d e x l d p dpeak hz,DP / s e t d a t a page l d i @peak_table,AR7 /get address o f peak t a b l e l d i Speak mtable,AR6 /get address o f peak max t a b l e l d i @t rp,AR5 /get address o f template peaks l d i @t wait,AR4 /get address o f template f l a g s l d i @t s t a r t , A R 3 /get address o f b u r s t t i m e r s t a l d i @t end,AR2 /get address o f b u r s t t i m e r end l d i @t_intc,AR0 /get address o f i n t e r v a l t i m e r l d f @min_power, R2 l d f @ave f f t , R 3 mpyf 2.5,R3 / R l : = 2 . 5 * a v e _ f f t /get data page of temporary t a b l e p t r /get address o f temporay t a b l e /get d a t a page o f temporary t a b l e / s e t t o c l e a r 255 words 117 mpyf 6.25,R3 ;Rl : = 6 . 2 5 * a v e _ f f t no s q r t s t e m p l a t e _ l o o p : test_temps: e a s e l 0: e a s e l 1: e a s e l 2: l d i 0,IR1 l d i 0,R4 l d i 0,IR0 l d i @peak_cnt,RC s u b i 1,RC r p t b test_temps l d f *+AR6(IR0),R0 cmpf R3,R0 b i t test_temps cmpf R2,R0 b i t test_temps f l o a t *+AR5(IR1) ,R1 f l o a t *+AR7(IRO) , RO subf R0,R1 a b s f R1,R1 cmpf 3,R1 bgt test_temps a d d i 1,R4 a d d i 1,IR0 l d i *+AR4(IR1) ,R5 cmpi 0,R4 beq not_found cmpi 0,R5 bne c a s e l _ l l d i @cycle_cnt,RO s t i RO,*+AR3(IR1) l d i 1,R0 s t i RO,*+AR4(IR1) b r c a s e l _ e n d cmpi 1,R5 bne c a s e l _ 2 l d i 2,R0 s t i RO,*+AR4(IR1) b r c a s e l _ e n d cmpi 2,R5 bne e a s e l 3 ;template_index:=0 ; f o u n d : = f a l s e ;peak index:=0 ;get number of peaks found ;get next peak i n peak t a b l e ; i f peak_mag<2.5*ave_fft ;then not a v a l i d peak ; i f peak_mag<min_power l i m i t ;then not a v a l i d peak ;get template v a l u e ;R0:=peak f r e q u e n c y ;R1:=R1-R0 ; i f a b s ( p e a k - t e m p l a t e ) > t o l e r a n c e ;then no peak match ; e l s e found:=true ; i n c ( p e a k _ i n d e x ) ;get w a i t i n g f l a g ; i f not(found) then ;no template match case w a i t i n g o f 0:begin get c u r r e n t c y c l e count t e m p f l R l ] . b u r s t _ s t a r t : = c y c l e _ c n t w a i t i n g : = l end 1:begin waiting:=2 end 2:begin do n o t h i n g j u s t w a i t dur t e s t c o n t : sec) l d i @t_bdur,ARl l d i *+ARl(IR1),R0 cmpi 0,R0 bne n o _ t e s t _ c o n t l d i @cycle_cnt,RO l d i *+AR3(IR1),R1 s u b i R1,R0 l d i 31,Rl s u b i R1,R0 f l o a t R0,R0 get address o f temp l a t e b u r s t get template b u r s t d u r r a t i o n e l s e dont i s s u e message get b u r s t end time get b u r s t s t a r t time b u r s t d u r r a t i o n : = e n d - s t a r t get c o n t i n u o u s b u r s t dur. (2 c o n v e r t t o f l o a t i n g p o i n t 118 nov4: n o _ t e s t _ c o n t : c a s e l _ 3 : c a s e l _ 4 : c a s e l _ e n d : n o t _ f o u n d : case2_0: c a s e 2 _ l : case2 2: ab s f R0,R0 f l o a t 31,RI mpyf 0.30,R1 cmpf RO, RI b i t n o _ t e s t _ c o n t l d i 0, RO s t i RO, *+AR4(IR1) l d i 0C000H,R7 a d d i IR1,R7 push AR4 push IRO l d i @peak ctable,AR4 l d i Speaks tent,IRO s t i R7,*+AR4(IRO) a d d i 1, IRO cmpi 10,IRO bne nov4 xor IRO,IRO s t i IRO,Speaks t e n t pop IRO pop AR4 br e a s e l end cmpi 3, R5 bne e a s e l 4' l d i 2, RO s t i RO,*+AR4(IR1) br e a s e l end cmpi 4,R5 bne e a s e l end l d i 2, RO s t i RO,*+AR4(IR1) get |R0-R1| RI s e t f o r +-15% t o l e r a n c e on b u r s t d u r a t i o n i f d i f f e r e n c e between b u r s t d u r a t i o n and s t o r e d v a l u e i n template < 15% o f s t o r e d v a l u e then b u r s t matches waiting:=0 d i p l a y message BOO p l u s i n d e x s t o r e message i n p e a k _ t a b l e b r temp_loop_end end; 3 r b e g i n waiting:=2 end 4:begin waiting:=2 end end ;case w a i t i n g o f cmpi 0,R5 ; 0:begin bne c a s e 2 _ l ; do n o t h i n g b r case2_end ; end cmpi 1,R5 ; 1:begin bne case2_2 ; l d i 4,R0 s t i RO,*+AR4(IR1) ; waiting:=4 b r case2_end ; end cmpi 2,R5 ; 2:begin bne case2_3 ; l d i Scycle_cnt,RO ; get c u r r e n t c y c l e count s t i RO,*+AR2(IR1) ; t e m p t l R l ] . b u r s t _ e n d : = c y c l e _ c n t 119 case2 3: t e s t b u r s t : dur found b u r s t : n o v l : l d i 3,R0 s t i RO, *+AR4(IR1) b r case2 end cmpi 3,R5 bne case2_4 l d i 0, RO s t i RO, *+AR4(IR1) l d i *+AR2(IR1),R0 l d i *+AR3(IR1),R1 s u b i R1,R0 l d i @t_bdur,ARl l d i *+ARl(IR1),R1 s u b i R1,R0 f l o a t R0,R0 ab s f RO, RO f l o a t *+ARl(IR1),R1 mpyf 0.30,R1 cmpf RO, RI b i t no message l d i 0B000H,R7 a d d i IR1,R7 push AR4 push IRO l d i Speak ctable,AR4 l d i Speaks tent,IRO s t i R7,*+AR4(IRO) a d d i 1, IRO cmpi 10,IRO bne n o v l xor IRO,IRO s t i IRO,Speaks t e n t pop IRO pop AR4 waiting:=3 end ,3: b e g i n waiting:=0 get b u r s t end time get b u r s t s t a r t time b u r s t d u r r a t i o n : = e n d - s t a r t get address o f templa t e b u r s t get template b u r s t d u r r a t i o n c o n v e r t t o f l o a t i n g p o i n t get IR0-R1I RI s e t f o r +-15% t o l e r a n c e on b u r s t d u r a t i o n i f d i f f e r e n c e between b u r s t d u r a t i o n and s t o r e d v a l u e i n template < 15% o f s t o r e d v a l u e then b u r s t matches e l s e dont i s s u e message d i p l a y message BOO p l u s i n d e x s t o r e message i n p e a k _ t a b l e t e s t i n t e r v a l : time l d i S t _ i n t , A R l f l o a t *+AR3(IR1),RO f l o a t *+AR0(IR1),R1 cmpf 0,R1 beq n o t _ z e r o subf RI,RO,RI f l o a t *+ARl(IR1) ,R0 subf R0,R1 ab s f R1,R1 f l o a t *+ARl (IRl) ,R0 mpyf 0.10,RO cmpf R0,R1 bgt no message get address of template i n t e r v a l get b u r s t s t a r t time get c u r r e n t i n t e r v a l t i m e r c n t i f i n t e r v a l _ t i m e r = 0 the n not c u r r e n t l y t i m i n g i n t e r v a l R I : = i n t e r v a l _ t i m e r - b u r s t _ s t a r t get template i n t e r v a l time get magnitude o f d i f f e r e n c e get template i n t e r v a l time s e t 10% t o l e r a n c e i f magn o f d i f f < 10% o f s t o r e d i n t e r v a l time then i n t e r v a l 120 match match found i n t : nov2: not zero: no_message: case2 4: case2 end: bgt n o t _ z e r o ; i n t e r v a l time then i n t e r v a l l d i 0,R0 s t i RO,*+AR0(IR1) i n t e r v a l _ t i m e r : = 0 ; l d i 0B100H,R7 d i p l a y message BIO p l u s i n d e x a d d i IR1,R7 push AR4 push IRO l d i Speak ctable,AR4 s t o r e message i n peak t a b l e l d i Speaks tent,IRO s t i R7,*+AR4(IRO) a d d i 1, IRO cmpi 10,IRO bne nov2 xor IRO,IRO s t i IRO,Speaks t e n t pop IRO pop AR4 l d i *+AR3(IR1),RO s t i RO,*+AR0(IR1) ; i n t e r v a l t i m e r : = b u r s t s t a r t b r case2_end l d i 0,R7 not R7,R7 br case2 end end cmpi 4,R5 4:begin bne case2_end l d i 0,R0 s t i RO, *+AR4(IR1) waiting:=0 end b r temp l o o p end end a d d i 1,IR1 ; i n c ( t e m p l a t e index) cmpi 5,IR1 ;more templates? b i t t e m p l a t e _ l o o p •compare next template • e l s e we a r e done pop IR1 pop IRO pop R7 pop R5 pop R4 pop R3 pop R2 pop RI pop RO pop AR7 pop AR6 pop AR5 pop AR4 pop AR3 pop AR2 pop AR1 121 pop ARO pop DP end match: r e t s u f i n d _ p e a k s : i n i t _ p e a k : g o i n g _ u p l : going_downl: f i n d peaks i n spectrum from FFT push DP push AR4 push AR5 push AR6 push AR7 push RO push R l push R2 push R3 push IRO push IR1 l d p @peak hz,DP ; s e t d a t a page l d i @peak_table,AR7 ;get address o f peak t a b l e l d i @peak mtable,AR6 ;get address o f peak max t a b l e xor R0,R0 s t i RO,@peak_cnt ;peak cnt:=0 s t i RO,@g_up ;g_up:=0 l d i RO,IRO ;peak_hz t a b l e index:=0 l d i RO,IR1 ; f f t peak t a b l e index:=0 l d f 0,R1 l d i 49,RC ; r p t b i n i t _ j ? e a k s t f R1,*AR6++ ; s e t a l l peak maximums t o 0 s t i R0,*AR7++ ; s e t a l l peaks t o 0 l d i @peak_table,AR7 ;get address o f peak t a b l e l d i Speak mtable,AR6 ;get address o f peak max t a b l e l d i @ f f t addr,AR5 ;get c u r r e n t f f t peak t a b l e l d i @g_up,R2 ;get g_up f l a g l d i 254,RC r p t b t e s t j p e a k s cmpi 57,IR1 ; i f l e s s than 900HZ ;@ sample r a t e 8000Hz b i t t e s t _ p e a k s ;dont l o o k f o r peaks l d f *+AR6(IR0),R0 ;get c u r r e n t peakjnax[IRO] l d f *+AR5(IR1),R1 ;get c u r r e n t f f t _ v a l u e [ I R 1 ] cmpf R0,R1 ; i f R1>R0 ( i e ff t > p e a k max) b l e g o i n g downl ;then we are g o i n g down a peak cmpi 1,R2 ; i f g_up<l then bge go i n g u p l ; a d d i 1,R2 ;inc(g_up) s t f Rl,*+AR6(IR0) ;peak max[IR0]:=fft v a l u e [ I R l ] ; s t i IR1,*+AR7(IRO) ;peak_hz[IRO]:=[IR1] b r t e s t _ p e a k s cmpi 0,R2 ; i f g_up>0 then b l e t e s t _ p e a k s ;begin s u b i 1,R2 ; dec(g_up) cmpi 0,R2 ; i f g up=0 bne go i n g down3 ; b e g i n 122 going_down4: going_down3: t e s t _ p e a k s : l d f @max_fft,R3 mpyf 0.25,R3 mpyf 0.0625,R3 l d f *+AR6(IR0),R0 cmpf R3,R0 b l e going_down4 a d d i 1,IR0 s t i IRO, @peak_cnt b r t e s t _ p e a k s l d f 0,R0 s t f RO,*+AR7(IRO) xor R0,R0 s t i RO,*+AR6(IRO) a d d i 1,IR1 no s q r t get peak_max[IRO] i f peak_max[IRO]>0.25*max_fft i n c ( p e a k _ c n t ) save peak_cnt e l s e peak_max[IRO]:=0; peak_hz[IRO]:=0; end end; i n c ( I R 1 ) t a b l e l d i @peak_cnt,R0 l d i @peak_ctable, AR4 l d i @cycle_cnt, IRO s t i RO,*+AR4(IRO) ;get c u r r e n t peak count ;get address o f peak count ;get c u r r e n t c y c l e pop IR1 pop IRO pop R3 pop R2 pop R l pop RO pop AR7 pop AR6 pop AR5 pop AR4 pop DP end_find_peaks: r e t s u ; R e a l t i m e Data a r r a y f i l l i n g r o u t i n e c a l l e d by i n t e r r u p t f i l l _ a r r a y : f i l l O : nop nop push ST push DP push AR7 push RO push IRO push R7 l d p @rla addr,DP ; s e t d a t a page l d i @rla addr,AR7 ;get address o f t a b l e 0 l d i @ w f i l l , RO ;get t a b l e f i l l i n g f l a g cmpi 0,R0 ;are we f i l l i n g t a b l e 0 ? beq f i l l O ;yes then j u s t c o n t i n u e l d i @rlb_addr,AR7 ; e l s e get address o f t a b l e 1 c a l l r e c e i v e O c a l l get data ;get the c u r r e n t r e a l t i m e d a t a l d i @fcnt,IRO ;get t a b l e i ndex s t f R7,*+AR7(IRO) ; s t o r e d a t a i n t a b l e 123 a d d i 1,IR0 cmpi 512,IRO bne n o _ r e s e t _ c n t s t i I R O , @ f i l l _ c n t l d i @wfill,R0 not R0,R0 s t i R 0 , @ w f i l l l d i 0,IR0 ; i n c i ndex ; i s t a b l e f u l l ? ;no then keep f i l l i n g ; e l s e s e t f i l l _ c n t f l a g ;get t a b l e f i l l i n g f l a g ; i n v e r t which t a b l e f l a g ;save which t a b l e f l a g ; r e s e t i n d e x n o _ r e s e t _ c n t : s t i IR0,@fcnt ;save index pop R7 pop IRO pop RO pop AR7 pop DP pop ST nop nop e n d _ f i l l : r e t i r e t s ; P l a c e h o l d e r s u b r o u t i n e f o r g e t t i n g r e a l t i m e d a t a ; r e t u r n s d a t a i n R7 g e t _ d a t a : format push DP push AR7 l d p @data_index,DP l d i @data_index,AR7 l d f *AR7++,R7 subf 128,R7 s t i AR7,@data_index pop AR7 pop DP r e t s u ;save d a t a page ;save AR7 ;get c u r r e n t r e a l d a t a page ;get c u r r e n t r e a l d a t a a d d r e s s ;get d ata, i n c ( d a t a _ i n d e x ) ; s u b t r a c t 12 8 f o r 8 b i t voc ;save new index ; r e s t o r e r e g i s t e r s / P l a c e h o l d e r f o r do n o t h i n g i n t e r r u p t r o u t i n e n u l l i n t : r e t i u ; S u b r o t u i n e f o r c a l c u l a t i n g FFT magnitudes, maximum and average f f t _ m a g n i t u d e : push DP push RE push Re push AR5 push AR6 push RO push RI push R2 push R3 push R4 push IRO l d p @rla xor R0,R0 ; s e t d a t a page 124 no new max: end_magn_loop: fft_mag_end: s t f R0,@max f f t s t f R0,@ave f f t l d i @ f f t addr,AR5 l d i @ f f t addr,AR6 addi 512,AR6 l d i 1, IRO l d i 254,RC r p t b end magn l o o p cmpi 58,IRO b i t end magn l o o p l d f *+AR5(IRO),R0 l d f *-AR6(IRO),Rl mpyf R0,R0 mpyf R1,R1 addf R1,R0 ; c a l l SQRT s t f •RO,*+AR5(IRO) l d f @max f f t , R l cmpf R1,R0 b i t no new max s t f RO,@max_fft l d f Save f f t , R l addf R0,R1 s t f Rl,@ave f f t a d d i 1, IRO l d f @ave f f t , R 0 l d f 197,Rl c a l l FDIV s t f RO,@ave_fft pop IRO pop R4 pop R3 pop R2 pop R l pop RO pop AR6 pop AR5 pop RC pop RE pop DP r e t s u * * * * * * * * * * * * * * * * * * * * * * t ;max_fft:=0 ; a v e _ f f t : = 0 ;get a ddress o f f f t t a b l e ;get address of end of f f t t a b l e ; s e t i n d e x t o 1 ;255 v a l u e s ; i f l e s s than 900HZ then ;@ sample r a t e 8000Hz ;don't c a l c u l a t e max o r ave ;get f f t _ r e a l [ I R O ] ;get f f t _ i m a g [ I R O ] /square r e a l p a r t /square imag p a r t ;sum the squares ;take the s q r t ;save i t i n t a b l e a t r e a l v a l u e ;get c u r r e n t m a x _ f f t ; i f max_fft>new magnitude ;then don't pdate m a x _ f f t ; e l s e s t o r e new max ; a v e _ f f t : = a v e _ f f t + m a x _ f f t ;inc(IRO) ;get average t o t a l ;get number o f a d d i t i o n s ;note 197 f o r sample r a t e ;of 8000 Hz ;save i t Reset and i n t i a l i z e the AIC O p e r a t i o n s : Set up t i m e r 0 t o s u p p l y AIC master c l o c k Reset the AIC * I n t i a l the s e r i a l p o r t s * Take AIC out of r e s e t * I n t i a l i z e the AIC * 125 * Enable r e c e i v e i n t e r r u p t s * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * a i c r e s e t : r e g i s t e r l d i 2, i o f ;xfO t o output, s e t xfO t o 0 l d i @t0 c t l a d d r , a r O ;get address o f t i m e r c o n t r o l l d i l , r l ; t c l k O w i l l e q u a l h l / 2 s t i rl,*+arO(8) ; s e t the p e r i o d r e g i s t e r t o 1 l d i @ t O _ c t l i n i t , r l ;get t i m e r 0 setup v a l u e s t i r l , * a r O ; s e t t i m e r 0 t o run i n p u l s e mode l d i @p0 addr,arO ;get address o f s e r i a l p o r t 0 l d i l l l h , r l s t i rl,*+arO(2) ; i n t i a l i z e t r a n s m i t p o r t c o n t r o l s t i rl,*+arO(3) ; i n t i a l i z e r e c e i v e p o r t c o n t r o l l d i @p0 g l o b a l , r l ; i n t i a l i z e p o r t 0 g l o b a l c o n t r o l s t i r l , * a r O xor r l , r l s t i rl,*+arO(8) ; s e t t r a n s m i t d a t a t o 0 l d i 0,R7 r p t s 99 nop ;wait f o r 50 t i m e r out c l o c k s l d i 6, i o f ; s e t xfO t o 1, ! r e s e t AIC ; s e t up the a i c c a l l w a i t t r a n s m i t 0 ; p o l l f o r t r a n s m i t i n t e r r u p t l d i 3, r l s t i r l,*+arO(8) ;secondary t r a n s m i t t i o n c a l l w a i t t r a n s m i t 0 l d i l a 3 4 h , r l ; s e t the sampling r a t e s t i r l,*+arO(8) l d i * + a r O ( 1 2 ) , r l c a l l w a i t t r a n s m i t 0 ; p o l l f o r t r a n s m i t i n t e r r u p t l d i 3, r l s t i r l , * + a r 0 ( 8 ) ;secondary t r a n s m i t t i o n c a l l w a i t t r a n s m i t 0 l d i 3 8 72h,rl ; s e t the sampling r a t e f o r 10.3kHz l d i 3C7Ah,rl ; s e t the sampling r a t e f o r 9.6kHz l d i 346Ah,rl ; s e t the sampling r a t e f o r 11kHz s t i r l,*+arO(8) l d i * + a r O ( 1 2 ) , r l c a l l w a i t t r a n s m i t 0 ;setup a i c t r a n s m i t and r e c i e v e l d i 3, r l /sampling r a t e s s t i rl,*+arO(8) c a l l w a i t t r a n s m i t 0 l d i 2 a 7 h , r l s t i rl,*+arO(8) l d i * + a r O ( 1 2 ) , r l xor i f , i f / c l e a r out a l l i n t e r r u p t f l a g s x o r ENBL_XINTO, IE / d i s a b l e s e r i a l p o r t 0 t x i n t or @enbl_spO_r, i e ; enable s e r i a l p o r t 0 r e t s / w a i t _ t r a n s m i t _ 0 : 126 wloop: xor bz r e t s i f , i f t s t b 1 0 h , i f wloop ;wait f o r the t r a n s m i t i n t e r r u p t ; f l a g t o be s e t . w a i t _ t r a n s m i t _ 0 : wloop: t s t b bz wloop l d i 0,R7 r e t s lh,R7 ; f l a g t o be s e t . t r a n s m i t O : l d i 1,R7 r e t i t r a n s m i t l : r e t i r e c i e v e l : r e t i t i m e r l : r e t i r e c e i v e O : ; push push push push l d p l d i l d i l d i l s h ash f l o a t s t i pop pop pop ; pop r e t s r e t i s t ;save r e g i s t e r s rO arO dp PARMS @pO_addr, arO *+arO(12),rO RO, R7 16,R7 -18,R7 R7,R7 rO,*+arO(8) dp arO rO s t ;get p o r t address ;read i n p u t ;send output • r e s t o r e r e g i s t e r s * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * hread() * * * * Read d a t a from c30 memory and w r i t e t o communications r e g . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * h r e a d l 6 : push s t ;save r e g i s t e r s push rO push ar6 push IRO push dp l d p process_mode,DP l d i @peak_ctable, AR6 l d i @peaks_hcnt, IRO cmpi @peaks_tcnt, IRO beq send_zero l d i *+AR6(IR0) ,R0 ;get address o f output b u f f e r ;get p o i n t e r t o head o f b u f f e r ;get p o i n t e r t o t a i l o f b u f f e r ; i f e q u a l do n o t h i n g ; e l s e get n e s t message 127 l d i Q h o s t p o r t , a r 6 ; l o a d h o s t p o r t address s t i r 0 , * a r 6 ; s t o r e d a t a a d d i 1,IR0 / i n c head p o i n t e r cmpi 10,IRO ;have we r o l l e d over bne m i s s _ r e s e t _ j p o i n t e r s ;no then save new head p o i n t e r xor IRO,IRO ; e l s e r e s e t head and t a i l so b u f f e r s t i IRO,@peaks_hcnt ;doesn;t o v e r f l o w (10 words max) s t i IRO,@peaks_tcnt b r n o _ r e s e t _ p o i n t e r s m i s s _ r e s e t _ j p o i n t e r s : s t i IRO,@peaks_hcnt ;save head p o i n t e r n o _ r e s e t _ p o i n t e r s : pop dp / r e s t o r e r e g i s t e r s pop IRO pop ar6 pop rO pop s t , r e t s send_zero: xor R0,R0 l d i S h o s t p o r t , a r 6 ; l o a d h o s t p o r t a d d r e s s s t i r 0 , * a r 6 / s t o r e d a t a pop dp / r e s t o r e r e g i s t e r s pop IRO pop ar6 pop rO pop s t r e t s /command w r i t e cmd_write: push s t /save r e g i s t e r s push rO push ar6 push dp push R7 l d p process_mode, DP xor R0,R0 l d i S h o s t p o r t , a r 6 / l o a d h o s t p o r t address l d i *ar6,R7 /get i n p u t command n o t _ l : no echo: cmpi 0, R7 beq no_echo c a l l w r i t e queue /echo t o output queue cmpi 1,R7 bne not 1 not R0,R7 s t i R7,@process mode /s e t f l a g f o r l e a r n i n g mode c a l l h r e a d l 6 / w r i t e next queue e n t r y t o pop R7 pop dp / r e s t o r e r e g i s t e r s pop ar6 pop rO 128 pop r e t i s t w r ite_queue: nov3: push AR4 push IRO l d i . Speak ctable,AR4 l d i @peaks tent,IRO s t i R7,*+AR4(IRO) a d d i 1, IRO cmpi 10,IRO bne nov3 xor IRO,IRO s t i IRO,Speaks t e n t pop IRO pop AR4 r e t s s t o r e message i n output queue end. 129 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * F i l e : warnmath.asm * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * SUBROUTINE: FPINV * * * * WRITTEN BY: GARY A. SITT0N * * GAS LIGHT SOFTWARE * * HOUSTON, TEXAS * * MARCH 1989. * * * * FLOATING POINT INVERSE: RO <= 1/RO * * * * APPROXIMATE ACCURACY: 8 DECIMAL DIGITS. * * INPUT RESTRICTIONS: RO != 0.0. * * REGISTERS FOR INPUT: RO. * * REGISTERS USED AND RESTORED: DP AND SP. * * REGISTERS ALTERED: RO-2 AND R4. * * REGISTERS FOR OUTPUT: RO. , * * ROUTINES NEEDED: NONE. • ' * * EXECUTION CYCLES (MIN, MAX): 33 , 33. * ********************************************************* EXTERNAL PROGRAM NAMES .GLOBL FPINV INTERNAL CONSTANTS .DATA ONE .SET 1.0 TWO .SET 2.0 MSK .WORD 0FF7FFFFFH .TEXT . s e c t ".mtext" START OF FPINV PROGRAM FPINV: LDF R0,R0 . ; TEST F RETSZ ; RETURN NOW IF F = 0 GET APPROXIMATION TO 1/F. FOR F = (1+M) * 2**E AND 0 <= M < 1, USE: X[0] = (l-M/2) * 2**-E PUSH DP ; SAVE DATA PAGE POINTER 130 LDP PUSHF POP XOR PUSH POPF POP @MSK RO R l @MSK, R l R l R l DP LOAD DATA PAGE POINTER SAVE AS FLT. PT. F = (1+M) * 2**E FETCH BACK AS INTEGER COMPLEMENT E & M BUT NOT SIGN BIT SAVE AS INTEGER, AND BY MAGIC... R l <= XfO] = (l-M/2) * 2**-E. UNSAVE DP NEWTON ITERATION FOR: Y(X) = X - 1/F = 0 ... MPYF R1,R0,R4 ; R4 <= F * XfO] SUBRF TWO,R4 ; R4 <= 2 - F * XfO] MPYF R4,R1 ; R l <= X f l ] = XfO] * (2 - F * XfO]) MPYF R1,R0,R4 ; R4 <= F * X f l ] SUBRF TWO,R4 ; R4 <= 2 - F * X f l ] MPYF R4,R1 ; R l <= X[2] = X f l ] * (2 - F * X f l ] ) MPYF R1,R0,R4 ; R4 <= F * X[2] SUBRF TWO,R4 ; R4 <= 2 - F * X[2] MPYF R4,R1 ; R l <= X[3] = X[2] * (2 - F * X[2]) FOR THE LAST ITERATION : X[4] = (X[3] * (1 - (F * X [ 3 ] ) ) ) + X[3] RND RND MPYF R0,R4 R1,R0 R0,R4 ; ROUND F BEFORE LAST MULTIPLY ; ROUND X[3] BEFORE MULTIPLIES ; R4 <= F * X[3] = 1 + EPS FINISH ITERATION AND RETURN POP R2 BUD R2 SUBRF ONE,R4 MPYF R0,R4 ADDF R4,R1,R0 R2 <= RETURN ADDRESS RETURN (DELAYED) R4 <= 1 - F * X[3] = EPS R4 <= X[3] * EPS ; RO <= X[4] = ( X [ 3 ] * ( l - ( F * X [ 3 ] ) ) ) + X[3] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * SUBROTUINE: FDIV WRITTEN BY: GARY A. SITTON GAS LIGHT SOFTWARE HOUSTON, TEXAS APRIL 1989. FLOATING POINT DIVIDE FUNCTION: RO <= R0/R1. * * APPROXIMATE ACCURACY: 8 DECIMAL DIGITS. * INPUT RESTRICTIONS: R l != 0.0. * REGISTERS FOR INPUT: RO (DIVIDEND) AND R l (DIVISOR).* REGISTERS USED AND RESTORED: DP AND SP. * REGISTERS ALTERED: RO-4. * REGISTERS FOR OUTPUT: RO (QUOTIENT). * * ROUTINES NEEDED: FPINV. * * EXECUTION CYCLES (MIN, MAX): 43 , 43. * ********************************************************* EXTERNAL PROGRAM NAMES 131 GLOBL FDIV GLOBL FPINV .TEXT . s e c t ".mtext" START OF FDIV PROGRAM FDIV: RND LDF CALL RND MPYF RO, R3 R l , RO FPINV RO R3, RO R3 <= RND X R l <= Y RO <= 1/Y ROUND BEFORE RO <= X RETS RETURN .END * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 132 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * FILENAME : warnfft.asm * * ADAPTED FROM : Texas Instrument * * DATE : 23rd June 1994 * * VERSION : 3.0 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * VER DATE COMMENTS * 3.0 18th J u l y 23rd J u l y 91 91 O r i g i n a l R e l e a s e . Most Stages M o d i f i e d . Minimum FFT S i z e i n c r e a s e d from 32 t o 64. F a s t e r i n p l a c e b i t r e v e r s i n g a l g o r i t h m . Program s i z e i n c r e a s e d by about 100 words. One e x t r a d a t a word r e q u i r e d . 23rd June 94 Used as 2 512 word FFT banks Both Bank2 t o r e s i d e i n RAMI i n t e r n a l bank Code to r e s i d e i n RAMO i n t e n a l bank NOT c a l l e d as a C s u b r o u t i n e C a l l e d as an assembly language r o u t i n e o n l y ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * SYNOPSIS: i n t f f f t _ r l ( FFT_SIZE, LOG_SIZE, SOURCE_ADDR, DEST_ADDR, SINE TABLE, BIT REVERSE ); i n t FFT_SIZE i n t LOG_SIZE f l o a t *SOURCE_ADDR f l o a t *DEST_ADDR ; f l o a t *SINE_TABLE ; i n t BIT REVERSE ; 64, 128, 256, 512, 1024, ... 6, 7, 8, 9, 10, ... ; P o i n t s t o l o c a t i o n o f s o u r c e d a t a . P o i n t s t o where d a t a w i l l be o p e r a t e d on and s t o r e d . P o i n t s t o the SIN/COS t a b l e . = 0, B i t R e v e r s i n g i s d i s a b l e d . <> 0, B i t R e v e r s i n g i s e n a b l e d . NOTE: 1) I f SOURCE_ADDR = DEST_ADDR, then i n p l a c e b i t r e v e r s i n g i s performed, i f e n a b l e d (more p r o c e s s o r i n t e n s i v e ) . 2) FFT SIZE must be >= 64 ( t h i s i s not c h e c k e d ) . * DESCRIPTION: G e n e r i c f u n c t i o n t o do a r a d i x - 2 FFT computation on t h e C30. * The d a t a a r r a y i s one o f 2 FFT_SIZE-long t a b l e s w i t h o n l y * r e a l d a t a . The output i s s t o r e d i n the same l o c a t i o n s w i t h * r e a l and i m a g i n a r y p o i n t s R and I as f o l l o w s : DEST ADDR[0] -> R(0) R ( D R(2) R(3) 133 R(FFT_SIZE/2) I(FF T SIZE/2 - 1) I (2) DEST_ADDR[FFT_SIZE - 1] -> 1(1) T h i s s u b r o u t i n e i s based on the FORTRAN program i n the paper by Sorensen e t a l . , June 1987 i s s u e o f Trans , on ASSP. B i t r e v e r s a l i s o p t i o n a l l y implemented a t the b e g i n n i n g o f the f u n c t i o n . The s i n e / c o s i n e t a b l e f o r the t w i d d l e f a c t o r s i s e x p e c t e d t o be s u p p l i e d i n the f o l l o w i n g format: SINE TABLE[0] -> s i n ( 0 * 2 * p i / F F T _ S I Z E ) s i n ( l * 2 * p i / F F T _ S I Z E ) s i n ( ( F F T _ S I Z E / 2 - 2 ) * 2 * p i / F F T _ S I Z E ) SINE_TABLE [FFT_SIZE/2 - 1] -> s i n ( (FFT_SIZE/2-l) *2*pi/FFT_SIZE) * * NOTE: The t a b l e i s the f i r s t * * Stack s t r u c t u r e upon c a l l : * + + * -FP(7) BIT REVERSE | * -FP(6) SINE TABLE | * -FP(5) DEST ADDR | * -FP(4) SOURCE ADDR | * -FP(3) LOG SIZE | * -FP(2) FFT_SIZE | * -FP(1) r e t u r n addr | * -FP(0) o l d FP | * +— + * **************************************** * WARNING: DP i n i t i a l i s e d o n l y once i n the program. Be wary * w i t h i n t e r r u p t s e r v i c e r o u t i n e s . Make sure i n t e r r u p t * s e r v i c e r o u t i n e s save the DP p o i n t e r . * * WARNING: The DEST_ADDR must be a l i g n e d such t h a t the f i r s t * LOG_SIZE b i t s a r e zero ( t h i s i s not checked by the * program). * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * REGISTERS USED: RO, R l , R2, R3, R4, R5, R6, R7 * ARO, AR1, AR2, AR3, AR4, AR5, AR6, AR7 * IRO, IR1 134 * RC, RS, RE * DP * * MEMORY REQUIREMENTS: Program = 405 Words (approximately) * Data = 7 Words * Stack = 12 Words * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * BENCHMARKS: Assumptions - Program i n RAMO * - Reserved da t a i n RAMO * - Stack on Primary/Expansion Bus RAM * - S i n e / C o s i n e t a b l e s i n RAMO * - P r o c e s s i n g and data d e s t i n a t i o n i n RAMI. * - Primary/Expansion Bus RAM, 0 wai t s t a t e . * * FFT S i z e B i t R e v e r s i n g Data Source C y c l e s ( C 3 0 ) * * 1024 OFF RAMI 19816 approx. * Note: T h i s number does not i n c l u d e the C c a l l a b l e overheads. * Add 57 c y c l e s f o r these overheads. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ENBL_GIE . s e t 2000h ; g l o b a l i n t e r r u p t enable FP . s e t AR3 . g l o b a l _ f f f t _ r l ; E n t r y e x e c u t i o n p o i n t . FFT_SIZE: .usect " . f f t d a t a " , l ; Reserve memory f o r arguments. LOG_SIZE: .usect " . f f t d a t a " , l SOURCE_ADDR: .usect " . f f t d a t a " , l DEST_ADDR: .usect " . f f t d a t a " , l SINE_TABLE: .usect " . f f t d a t a " , l BIT_REVERSE: .usect " . f f t d a t a " , l SEPARATION: .usect " . f f t d a t a " , 1 I n i t i a l i s e C F u n c t i o n . . s e c t " . f f t t e x t " f f f t r l : PUSH FP ; Pre s e r v e environment. LDI SP, FP PUSH RO PUSH R l PUSH R2 PUSH R3 PUSH R4 PUSH R5 PUSH PUSH R7 PUSH ARO PUSH AR1 R6 135 PUSH AR2 PUSH AR3 PUSH AR4 PUSH AR5 PUSH AR6 PUSH AR7 PUSH IRO PUSH IR1 PUSH DP LDP FFT_SIZE ; I n i t i a l i s e DP p o i n t e r . LDI *-FP(2),R0 ; Move arguments from s t a c k . STI RO,@FFT_SIZE LDI *-FP(3),R0 STI RO, @LOG_SIZE LDI *-FP(4),R0 STI RO,@SOURCE_ADDR LDI *-FP(5),R0 STI RO,@DEST_ADDR LDI *-FP(6),R0 STI RO,@SINE_TABLE LDI *-FP(7),R0 STI RO,@BIT REVERSE Check B i t R e v e r s i n g Mode (on o r o f f ) . BIT_REVERSING = 0, then OFF (no b i t r e v e r s i n g ) . BIT_REVERSING <> 0, Then ON. LDI @BIT_REVERSE,RO CMPI 0,R0 BZ MOVE DATA Check B i t R e v e r s i n g Type. I f SourceAddr = DestAddr, Then In P l a c e B i t R e v e r s i n g . I f SourceAddr <> DestAddr, Then Standard B i t R e v e r s i n g . LDI @SOURCE_ADDR,R0 CMPI @DEST_ADDR,RO BEQ IN PLACE ; B i t r e v e r s i n g Type 1 (From Source t o D e s t i n a t i o n ) . ; NOTE: abs (SOURCE_ADDR - DEST_ADDR) must be > FFT_SIZE, t h i s i s not checked. LDI @FFT_SIZE,R0 SUBI 2,R0 LDI @FFT_SIZE,IRO LSH -1,IR0 ; IRO = H a l f FFT s i z e . LDI @SOURCE ADDR,ARO 136 LDI @DEST_ADDR,AR1 LDF *AR0++,R1 RPTS RO LDF *ARO++,Rl || STF Rl,*AR1++(IR0)B STF R1,*AR1++(IR0)B BR START In P l a c e B i t R e v e r s i n g . ; B i t R e v e r s i n g On Even L o c a t i o n s , 1st H a l f Only. IN_PLACE: LDI @FFT_SIZE, IRO LSH -2,IRO ; IRO = Q u a r t e r FFT s i z e . LDI 2,IR1 LDI @FFT_SIZE,RC LSH -2,RC SUBI 3,RC LDI @DEST_ADDR,ARO LDI ARO,AR1 LDI ARO,AR2 NOP *AR1++(IR0)B NOP *AR2++(IR0)B LDF *++AR0(IR1),RO LDF *AR1,R1 CMPI AR1,ARO ; Xchange L o c a t i o n s o n l y i f AR0<AR1. LDFGT R0,R1 LDFGT *AR1++(IR0)B,R1 RPTB BITRV1 LDF *++AR0(IR1),R0 || STF RO,*AR0 LDF *AR1,R1 || STF Rl,*AR2++(IRO)B CMPI AR1,ARO LDFGT R0,R1 BITRV1: LDFGT *AR1++(IRO)B,RO STF R0,*AR0 STF R1,*AR2 ; Perform B i t R e v e r s i n g On Odd L o c a t i o n s , 2nd H a l f Only. LDI @FFT_SIZE,RC LSH -1,RC LDI @DEST_ADDR,ARO ADDI RC,AR0 ADDI 1,AR0 137 LDI ARO,AR1 LDI ARO,AR2 LSH -1,RC SUBI 3,RC NOP *AR1++(IR0)B NOP *AR2++(IR0)B LDF *++AR0(IR1) ,R0 LDF *AR1,R1 CMPI AR1,ARO ; Xchange L o c a t i o n s o n l y i f AR0<AR1. LDFGT R0,R1 LDFGT *AR1++(IR0)B,R1 RPTB BITRV2 LDF *++AR0(IR1),RO | | STF RO,*AR0 LDF *AR1,R1 M STF Rl,*AR2++(IR0)B CMPI AR1,ARO LDFGT R0,R1 STF R0,*AR0 STF R1,*AR2 ; Perform B i t R e v e r s i n g On Odd L o c a t i o n s , 1 s t H a l f Only. LDI @FFT_SIZE,RC LSH -1,RC LDI RC,IR0 LDI @DEST_ADDR,ARO LDI ARO, AR1 ADDI 1,AR0 ADDI IR0,AR1 LSH -1,RC LDI RC,IRO SUBI 2,RC y LDF *AR0,RO LDF *AR1,R1 RPTB BITRV3 LDF *++AR0(IR1),RO || STF RO,*AR1++(IRO)B BITRV2: LDFGT *AR1++(IR0)B,R0 BITRV3: LDF *AR1,R1 | | STF Rl,*-AR0(IR1) STF RO, *AR1 STF Rl,*AR0 BR START Check Data Source L o c a t i o n s . I f SourceAddr = DestAddr, Then do n o t h i n g . I f SourceAddr <> DestAddr, Then move d a t a . 138 MOVEJDATA: LDI @SOURCE_ADDR,RO CMPI 0DEST ADDR,R0 BEQ START LDI @FFT_SIZE,RO SUBI 2,R0 LDI @SOURCE_ADDR,ARO LDI @DEST_ADDR,ARl LDF *ARO++,Rl RPTS LDF RO *ARO++,Rl 11 STF R l , *AR1++ STF Rl,*AR1 Perform f i r s t and second FFT l o o p s . | _ ARl -> | AR2 -> | AR3 -> |_ AR4 -> AR l -> 11 I 0 12 | 1 13 | 2 14 | 3 1 4 <- [X(I1) <- [X(I1) <- [X(I1) <- ~[X(I3) + X ( I 2 ) ] - X ( I 2 ) ] + X ( I 2 ) ] - X(I4)] + [X(I3) - [X(I3) + X ( I 4 ) ] + X(I4) ] START: LDI 0DESTJ LDI ARl,AR2 LDI ARl,AR3 LDI ARl,AR4 ADDI 1, AR2 ADDI 2,AR3 ADDI 3, AR4 LDI 4, IRO LDI @FFT_SIZE,RC LSH -2, RC SUBI 2,RC LDF *AR2,R0 | | LDF *AR3,R1 ADDF3 Rl,*AR4,R4 SUBF3 Rl,*AR4++(IRO) SUBF3 R0,*AR1,R6 ADDF3 RO,*AR1++(IRO) , R7 ADDF3 R7,R4,R2 RO = R4 = ,R5 ; R6 = X(I2) R l = X(I3) R5 = X(I1) R7 = X(I3) + X(I4) -[X(I3) - X ( I 4 ) ] - X(I2) — + | X(I1) + X(I2) R2 = R7 + R4 - --+ SUBF3 R4,R7,R3 R3 R7 R4 — + | I I RPTB LOOPl_2 LDF *+AR2(IRO) , RO | | LDF *+AR3(IRO) , R l ADDF3 R1,*AR4,R4 I I I I I I I 139 || STF R3,*AR3++(IR0) ; X(I3) < + I I I SUBF3 Rl,*AR4++(IR0),R5 ; I I I || STF R5, *-AR4 (IRO) ; X ( I 4 ) < 1 — I ~ + SUBF3 R0,*AR1,R6 ; I I || STF R6,*AR2++(IRO) ; X(I2) < 1 — + ADDF3 RO,*AR1++(IRO),R7 ; I || STF R2, *-ARl (IRO) ; X(I1) < + ADDF3 R7,R4,R2 LOOPl_2: SUBF3 R4,R7,R3 STF R3,*AR3 || STF R5,*-AR4(IRO) STF R6,*AR2 I| STF R2,*-ARl(IRO) Perform T h i r d FFT Loop P a r t A: ~~ A R l -> AR2 -> AR3 -> ARl -> I I | 0 <- X(I1) + X(I3) I I 1 12 | 2 I I 3 13 | 4 <- I I 5 14 | 6 <- -X(I4) I I 7 X(I1) - X(I3) I 8 I 9 I LDI @DEST ADDR,ARl LDI ARl , AR2 LDI ARl , AR3 ADDI 4,AR2 ADDI 6,AR3 LDI 8, IRO LDI @FFT SIZE,RC LSH -3, RC SUBI 2,RC SUBF3 *AR2,*AR1,R1 ADDF3 *AR2, *AR1,R2 NEGF *AR3,R3 RPTB LOOP3_A LDF *+AR2(IRO),RO ; RO = X(I3) I | STF R2,*AR1++(IRO) SUBF3 R0,*AR1,R1 R l = X(I1) - X(I3) | | STF Rl,*AR2++(IRO) t ADDF3 R0,*AR1,R2 ; R2 = X(I1) + X(I3) — + | | STF R3,*AR3++(IRO) NEGF *AR3,R3 ; R3 = -X(I4) — + 140 STF I | STF STF R2,*AR1 Rl,*AR2 R3,*AR3 I I X(I1) < I + | X(I3) < I + X(I4) < + P a r t B: 1 o ARO -> 1 11 1 1 2 1 <- X(I1) + [X(I3)*COS + X(14)*COS] ARl -> 1 12 | 1 4 3 <- X(I1) - [X(I3)*COS + X(14)*COS] AR2 -> 1 13 | 1 6 5 <- -X(I2) - [X(I3)*COS - X(14)*COS] AR3 -> 1 14 | 1 8 7 <- X(I2) - [X(I3)*COS - X(I4)*COS] ARO | 9 NOTE: COS(2*pi/8) = SIN(2*pi/8) "l LDI @FFT_SIZE,RC LSH -3,RC LDI RC,IR1 SUBI 3,RC LDI 8,IRO LDI @DEST_ADDR,ARO LDI ARO,ARl LDI ARO,AR2 LDI ARO,AR3 ADDI l,ARO ADDI 3,ARl ADDI 5,AR2 ADDI 7,AR3 LDI LDF 0SINE TABLE,AR7 I n i t i a l i s e t a b l e p o i n t e r s . *++AR7(IR1),R7 ; R7 = COS(2*pi/8) ; *AR7 = COS (2*pi /8) MPYF3 *AR7,*AR2,R0 ; RO = X(I3)*COS MPYF3 *AR3,R7,R1 ; R5 = X(I4)*COS ADDF3 R0,R1,R2 ; R2 = [X(I3)*COS + X(I4)*COS] MPYF3 *AR7,*+AR2(IRO),RO || SUBF3 R0,R1,R3 ; R3 = -[X(I3)*COS - X(I4)*COS] SUBF3 *AR1,R3,R4 ; R4 = -X(I2) + R3 — + ADDF3 *AR1,R3,R4 || STF R4,*AR2++(IRO) SUBF3 R2,*AR0,R4 || STF R4,*AR3++(IRO) ADDF3 *AR0,R2,R4 || STF R4,*AR1++(IR0) R4 = X(I2) + R3 — | — + X(I3) < + | R4 = X(I1) - R2 — + | X(I4) < : |—+ R4 = X (II) + R2 — | — + X(I2) < + | RPTB LOOP3 B 141 L00P3 B: MPYF3 *AR3,R7,R1 || STF R4,*ARO++(IRO) ADDF3 R0,R1,R2 MPYF3 *AR7,*+AR2(IRO),RO I| SUBF3 R0,R1,R3 SUBF3 *AR1,R3,R4 ADDF3 *AR1,R3,R4 || STF R4,*AR2++(IRO) SUBF3 R2,*AR0,R4 || STF R4,*AR3++(IRO) ADDF3 *AR0,R2,R4 || STF R4,*AR1++(IRO) ; x( i l ) <- MPYF3 *AR3,R7,Rl || STF R4,*ARO++(IRO) ADDF3 RO,Rl,R2 SUBF3 R0,R1,R3 SUBF3 *AR1,R3,R4 ADDF3 *AR1,R3,R4 || STF R4,*AR2 SUBF3 R2,*ARO,R4 || STF R4,*AR3 ADDF3 *AR0,R2,R4 || STF R4,*AR1 STF R4,*AR0 Perform F o u r t h FFT Loop. P a r t A: _ A R l -> AR2 -> AR3 -> AR l -> I I I | 0 <- X(I1) + X(I3) I I 1 I 2 I I 3 12 | 4 I I 5 I 6 I 7 13 I 10 <- X(I1) - X(I3) J 9 i I 11 14 f 12 <- -X(I4) I 13 I 14 I I 15 15 | 16 I 17 \ l / LDI @DEST_ADDR,ARl LDI A R l , AR2 LDI ARl,AR3 142 ADDI 8,AR2 ADDI 12,AR3 LDI 16,IRO LDI @FFT_SIZE,RC LSH -4,RC SUBI 2,RC SUBF3 *AR2,*AR1,R1 ADDF3 *AR2,*AR1,R2 NEGF *AR3,R3 RPTB LOOP4_A LDF *+AR2(IRO),RO ; RO = X(I3) || STF R2,*ARl++(IRO) SUBF3 R0,*AR1,R1 ; R l = X(I1) - X(I3) + || STF Rl,*AR2++(IR0) ; I ADDF3 R0,*AR1,R2 ; R2 = X(I1) + X(I3) — + | II STF R3,*AR3++(IRO) ; I I LOOP4_A: NEGF *AR3,R3 ; R3 = -X(I4) — + I | I I STF R2,*AR1 ; X(I1) < — I + | || STF R1,*AR2 ; X(I3) < 1 .-+ STF R3,*AR3 ; X(I4) < + P a r t B: I I 0 ARO -> | I l _ ( 3 r d ) _ | 1 <- X(I1) + [X(I3)*COS + X(I4)*SIN] I I l _ ( 2 n d ) _ | 2 I I l _ ( l s t ) _ | 3 I I 4 I I 2 _ ( l s t ) _ | 5 ; I I2_(2nd)_| 6 ARl -> | I 2 _ ( 3 r d ) _ | 7 <- X ( I l ) - [X(I3)*COS + X(I4)*SIN] I _ l 8 AR2 -> | I 3 _ ( 3 r d ) _ | 9 < X(I2) - [ X ( I 3 ) * S I N - X(I4)*COS] | I 3 _ ( 2 n d ) _ | 10 AR4 -> | I 3 _ ( l s t ) _ | 11 I I 12 I I 4 _ ( l s t ) _ | 13 | I4 _ ( 2 n d ) _ | 14 AR3 -> | I 4 _ ( 3 r d ) _ | 15 <- X(I2) - [X(I3)*SIN - X(I4)*C0S] I I 16 ARO -> | | 17 LDI @FFT_SIZE,RC LSH -4,RC LDI RC,IR1 LDI 2,IRO SUBI 3,RC 143 LDI @DEST_ADDR,ARO LDI ARO,ARl LDI ARO,AR2 LDI AR0,AR3 LDI ARO,AR4 ADDI l,ARO ADDI 7,ARl ADDI 9,AR2 ADDI 15,AR3 ADDI 11,AR4 LDI @SINE_TABLE,AR7 LDF *++AR7(IR1),R7 ; R7 = SIN(1*[2*pi/16]) ; *AR7 = COS(3*[2*pi/16]) LDI AR7,AR6 LDF *++AR6(IRl) ,R6 ; R6 = SIN(2*[2*pi/16]) ; *AR6 = COS(2*[2*pi/16]) LDI AR6,AR5 LDF *++AR5(IR1),R5 ; R5 = SIN(3*[2*pi/16]) ; *AR5 = COS(1*[2*pi/16]) LDI 16,IR1 MPYF3 *AR7,*AR4,R0 RO = X(I3)*COS(3) X(14)*COS] MPYF3 *++AR2(IRO),R5,R4 ; MPYF3 *—AR3(IRO),R5,R1 ; MPYF3 *AR7,*AR3,R0 | ADDF3 R0,R1,R2 MPYF3 *AR6,*-AR4,R0 | SUBF3 R4,R0,R3 SUBF3 *—ARl(IRO),R3,R4 ; ADDF3 *AR1,R3,R4 ; I STF R4,*AR2— ; SUBF3 R2,*++ARO(IRO),R4 | STF R4,*AR3 ADDF3 *AR0,R2,R4 | STF R4,*AR1 MPYF3 *++AR3,R6,Rl | STF R4,*AR0 ADDF3 R0,R1,R2 MPYF3 *AR5,*-AR4(IRO) , RO | SUBF3 R0,R1,R3 SUBF3 *++ARl,R3,R4 ADDF3 *AR1,R3,R4 | STF R4,*AR2 SUBF3 R2,*—AR0,R4 I STF R4,*AR3 ADDF3 *AR0,R2,R4 | STF R4,*AR1 MPYF3 *—AR2,R7,R4 | STF R4,*AR0 MPYF3 *++AR3,R7,Rl MPYF3 *AR5,*AR3,R0 | ADDF3 R0,R1,R2 R4 R l X(I3)*SIN(3) X(I4)*SIN(3) RO = X(I4)*COS(3) R2 = [X(I3)*C0S + X(I4)*SIN] R4 = • R4 = X(I3) -X(I2) X(I2) < R4 = X(I4) < R4 = X(I1) X(I2) < X(I1) <- R3 = - [ X ( I 3 ) * S I N - + R3 — + + R3 — | — + + I X(I1) - R2 — + | + R2 I—+ | — + + I I + 144 MPYF3 *AR7,*++AR4(IR1) , RO I SUBF3 R4,R0,R3 SUBF3 *++ARl,R3,R4 ADDF3 *AR1,R3,R4 | STF R4,*AR2++(IR1) SUBF3 R2,*—ARO,R4 | STF R4,*AR3++(IRl) ADDF3 *AR0,R2,R4 | STF R4,*AR1++(IRl) RPTB LOOP4_B MPYF3 *++AR2(IRO) , R5, R4 I STF R4,*ARO++(IRl) MPYF3 *—AR3(IRO),R5,Rl MPYF3 *AR7,*AR3,R0 | ADDF3 R0,R1,R2 MPYF3 *AR6,*-AR4,R0 | SUBF3 R4,R0,R3 SUBF3 *—ARl(IRO),R3,R4 ADDF3 *AR1,R3,R4 | STF R4,*AR2— SUBF3 R2,*++ARO(IRO) ,R4 | STF R4,*AR3 ADDF3 *AR0,R2,R4 | STF R4,*AR1 MPYF3 *++AR3,R6,Rl | STF R4,*AR0 ADDF3 R0,R1,R2 MPYF3 *AR5,*-AR4(IRO) , RO | SUBF3 R0,R1,R3 SUBF3 *++ARl,R3,R4 ADDF3 *AR1,R3,R4 | STF R4,*AR2 SUBF3 R2,*—ARO,R4 | STF R4,*AR3 ADDF3 *AR0,R2,R4 | STF R4,*AR1 MPYF3 *—AR2,R7,R4 I STF R4,*ARO MPYF3 *++AR3,R7,Rl MPYF3 *AR5,*AR3,RO | ADDF3 R0,R1,R2 MPYF3 *AR7,*++AR4(IRl),RO | SUBF3 R4,R0,R3 SUBF3 *++ARl,R3,R4 ADDF3 *AR1,R3,R4 | STF R4,*AR2++(IRl) SUBF3 R2,*—ARO,R4 I STF R4,*AR3++(IRl) ADDF3 *AR0,R2,R4 | STF R4,*AR1++(IR1) MPYF3 *++AR2(IRO),R5,R4 | | STF R4,*ARO++(IRl) MPYF3 *—AR3(IRO),R5,R1 MPYF3 *AR7,*AR3,R0 | | ADDF3 R0,R1,R2 MPYF3 *AR6,*-AR4,RO | | SUBF3 R4,R0,R3 SUBF3 * — A R l ( I R O ) ,R3,R4 ADDF3 *AR1,R3,R4 | | STF R4,*AR2 — SUBF3 R2,*++ARO(IRO),R4 | | STF R4,*AR3 ADDF3 *AR0,R2,R4 I | STF R4,*AR1 MPYF3 *++AR3,R6,Rl | | STF R4,*ARO ADDF3 R0,R1,R2 MPYF3 *AR5,*-AR4(IRO),RO | | SUBF3 RO,Rl,R3 SUBF3 *++ARl,R3,R4 ADDF3 *AR1,R3,R4 | | STF R4,*AR2 SUBF3 R2,*—AR0,R4 I | STF R4,*AR3 ADDF3 *AR0,R2,R4 | | STF R4,*AR1 MPYF3 *—AR2,R7,R4 | | STF R4,*ARO MPYF3 *++AR3,R7,Rl MPYF3 *AR5,*AR3,R0 | | ADDF3 R0,R1,R2 SUBF3 R4,R0,R3 SUBF3 *++ARl,R3,R4 ADDF3 *AR1,R3,R4 | | STF R4,*AR2 SUBF3 R2,*—AR0,R4 | | STF R4,*AR3 ADDF3 *AR0,R2,R4 | | STF R4,*AR1 STF R4,*AR0 Perform Remaining FFT l o o p s (loop 4 onwards). L O O P 1st 2nd \ / \ / | | X 1 (II) | 0 0 <- X' (II) + X' (13) | A R l -> | X ( I l ) _ ( l s t ) _ | 1 1 <- X(I1) + [X(I3)*COS X(I4)*SIN] | | X ( I l ) _ ( 2 n d ) _ | 2 2 I I x ( I l ) (3rd) | 3 3 A -> | I | X'(I2) | 8 16 B -> | . I 146 • I AR2 -> | AR3 X(14)*COS] I X ( I 2 ) _ ( 3 r d ) _ | 13 29 _ X ( I 2 ) _ ( 2 n d ) _ | 14 30 _ X ( I 2 ) _ ( l s t ) _ | 15 31 <- X' (13) | 16 32 < -> | X ( I 3 ) _ ( l s t ) _ | 17 _ X ( I 3 ) _ ( 2 n d ) _ | 18 34 X(I3) (3rd) | 19 35 X(I1) - [X(I3)*COS + X(I4)*SIN] X' (II) - X 1 (13) 33 <- -X(I2) - [X ( I 3 ) * S I N - D -> | I X' (14) | 24 48 <- -X'(14) X(14)*COS] AR4 I | X ( I 4 ) _ ( 3 r d ) _ | 29 I X ( I 4 ) _ ( 2 n d ) _ | 30 -> | X(I4) (1st) | 61 62 A R l -> | f I 32 "| 33 "l 64 65 \ l / 31 63 <- X(I2) - [X ( I 3 ) * S I N LOOP: INLOP: — + LDI @FFT_SIZE, IRO LSH -2,IRO STI IRO,0SEPARATION LSH -2,IRO LDI 5,R5 LDI 3,R7 LDI 16, R6 LDI @DEST_ADDR,AR5 LDI @DEST_ADDR,ARl LSH -1,IR0 LSH 1,R7 ADDI 1,R7 LSH 1,R6 LDI ARl,AR4 ADDI R7,AR1 LDI ARl,AR2 ADDI 2,AR2 ADDI R6,AR4 SUBI R7,AR4 LDI AR4,AR3 SUBI 2,AR3 LDI @SINE_TABLE,ARO LDI R7,IR1 LDI R7,RC ARl p o i n t s a t A. AR2 p o i n t s a t B. AR4 p o i n t s a t D. AR3 p o i n t s a t C. ARO p o i n t s a t SIN/COS t a b l e . ADDF3 SUBF3 *- NEGF *- -ARl(1R1),*++AR2(IR1),RO RO = X 1 ( I I ) + X 1 ( 1 3 ) -AR3(IR1),*AR1++,R1 -AR4, R2 ; R l = X ' ( I I ) - X'(13) -+| R2 = -X' (14) — + I | 147 I I STF R0,*-AR1 STF R1,*AR2— | | STF R2,*AR4++(IRl) LDI OSEPARATION, I R l SUBI 3,RC ; X' (II) < I | + ; X' (13) < I + ; X' (14) < + ; IR1=SEPARATI0N BETWEEN SIN/COS TBLS MPYF3 *++AR0(IRO) , *AR4, R4 MPYF3 *AR0,*++AR3,Rl MPYF3 *++AR0(IRl),*AR4,RO MPYF3 *AR0,*AR3,R0 I SUBF3 R1,R0,R3 MPYF3 *++ARO(IRO),*-AR4,RO I ADDF3 R0,R4,R2 SUBF3 *AR2,R3,R4 ADDF3 *AR2,R3,R4 | STF R4,*AR3++ SUBF3 R2,*AR1,R4 | STF R4,*AR4— ADDF3 *AR1,R2,R4 I STF R4,*AR2— RPTB IN_BLK LDF *-ARO(IRl),R3 MPYF3 *AR4,R3,R4 | STF R4,*AR1++ MPYF3 *AR3,R3,R1 MPYF3 *AR0,*AR3,R0 I SUBF3 R1,R0,R3 MPYF3 *++AR0(IRO),*-AR4,R0 | ADDF3 R0,R4,R2 SUBF3 *AR2,R3,R4 ADDF3 *AR2,R3,R4 | STF R4,*AR3++ SUBF3 R2,*AR1,R4 | STF R4,*AR4— ADDF3 *AR1,R2,R4 | STF R4,*AR2— LDF *-AR0(IRl) ,R3 MPYF3 *AR4,R3,R4 | STF R4,*AR1++ MPYF3 *AR3,R3,R1 MPYF3 *AR0,*AR3,RO | SUBF3 R1,R0,R3 LDI R6,IR1 ADDF3 R0,R4,R2 SUBF3 *AR2,R3,R4 ADDF3 *AR2,R3,R4 | STF R4,*AR3++(IR1) SUBF3 R2,*AR1,R4 | STF R4,*AR4++(IR1) ADDF3 *AR1,R2,R4 | STF R4,*AR2++(IRl) R4 = X( I 4 ) * S I N R l = X(13)*SIN RO = X(14)*COS RO = X(I3)*COS R3 = -[X(13)*SIN ; R2 = X(I3)*COS + R4 = R3 - X(I2) — * R4 = R3 + X(I2) — | — * X(I3) < * | R4 = X(I1) - R2 — * | X(I4) < I — * R4 = X(I1) + R2 — I — * X(I2) < * | - X(14)*COS] X(14)*SIN X(I1) <- STF R4,*AR1++(IR1) SUBI3 AR5,AR1,R0 148 CMPI @FFT_SIZE,RO BLTD INLOP LDI @SINE_TABLE,ARO LDI R7,IR1 LDI R7,RC LOOP BACK TO THE INNER LOOP ; ARO POINTS TO SIN/COS TABLE ADDI 1,R5 CMPI @LOG_SIZE,R5. BLED LOOP LDI @DEST_ADDR,ARl LSH -1,IR0 LSH 1,R7 Return t o C environment. POP DP POP POP POP AR7 POP AR6 POP AR5 POP AR4 POP AR3 POP AR2 POP ARl POP ARO POP R7 POP R6 POP R5 POP R4 POP R3 POP R2 POP R l POP RO POP FP RETS ; R e s t o r e IR1 IRO environment v a r i a b l e s . . end * No more. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 149 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * warntwid.asm FFT SIZE: 512 . g l o b a l . d a t a s i n e t a b s i n e t a b . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t . f l o a t 0.00000000000 0. 01227153829 0. 02454122852 0.03680722294 0. 04906767433 0.06132073630 0.07356456360 0. 08579731234 0. 09801714033 0.11022220729 0.12241067520 0.13458070851 0.14673047446 0.15885814333 0.17096188876 0.18303988796 0.19509032202 0.20711137619 0.21910124016 0.23105810828 0.24298017990 0.25486565960 0.26671275748 0.27851968939 0.29028467725 0.30200594932 0.31368174040 0.32531029216 0.33688985339 0.34841868025 0.35989503654 0.37131719395 0.38268343236 0.39399204006 0.40524131400 0.41642956010 0.42755509343 0.43861623854 0.44961132965 0.46053871096 150 f l o a t 0. 47139673683 f l o a t 0. 48218377208 f l o a t 0. 49289819223 f l o a t 0. 50353838372 f l o a t 0. 51410274419 f l o a t 0. 52458968268 f l o a t 0. 53499761989 f l o a t 0. 54532498842 f l o a t . 0. 55557023302 f l o a t 0. 56573181078 f l o a t 0. 57580819142 f l o a t 0. 58579785746 f l o a t 0. 59569930449 f l o a t 0. 60551104140 f l o a t 0. 61523159058 f l o a t 0. 62485948814 f l o a t 0. 63439328416 f l o a t 0. 64383154289 f l o a t 0. 65317284295 f l o a t 0. 66241577759 f l o a t 0. 67155895485 f l o a t 0. 68060099779 f l o a t 0. 68954054474 f l o a t 0. 69837624941 f l o a t 0. 70710678119 f l o a t 0. 71573082528 f l o a t 0. 72424708295 f l o a t 0. 73265427167 f l o a t 0. 74095112535 f l o a t 0. 74913639452 f l o a t 0. 75720884651 f l o a t 0. 76516726562 f l o a t 0. 77301045336 f l o a t 0. 78073722857 f l o a t 0. 78834642763 f l o a t 0. 79583690461 f l o a t 0. 80320753148 f l o a t 0. 81045719825 f l o a t 0. 81758481315 f l o a t 0. 82458930279 f l o a t 0. 83146961230 f l o a t 0. 83822470555 f l o a t 0. 84485356525 f l o a t 0. 85135519310 f l o a t 0. 85772861000 f l o a t 0. 86397285612 f l o a t 0. 87008699111 f l o a t 0. 87607009419 f l o a t 0. 88192126435 f l o a t 0. 88763962040 f l o a t 0. 89322430120 f l o a t 0. 89867446569 f l o a t 0. 90398929312 f l o a t 0. 90916798309 f l o a t 0. 91420975570 f l o a t 0. 91911385169 f l o a t 0. 92387953251 f l o a t 0. 92850608047 f l o a t 0. 93299279884 f l o a t 0. 93733901191 f l o a t 0. 94154406518 f l o a t 0. 94560732538 f l o a t 0. 94952818059 f l o a t 0. 95330604035 f l o a t 0. 95694033573 f l o a t 0. 96043051942 f l o a t 0. 96377606579 f l o a t 0. 96697647104 f l o a t 0. 97003125319 f l o a t 0. 97293995221 f l o a t 0. 97570213004 f l o a t 0. 97831737072 f l o a t 0. 98078528040 f l o a t 0. 98310548743 f l o a t 0. 98527764239 f l o a t 0. 98730141816 f l o a t 0. 98917650996 f l o a t 0. 99090263543 f l o a t 0. 99247953460 f l o a t 0. 99390697000 f l o a t 0. 99518472667 f l o a t 0. 99631261218 f l o a t 0. 99729045668 f l o a t 0. 99811811290 f l o a t 0. 99879545620 f l o a t 0. 99932238459 f l o a t 0. 99969881869 f l o a t 0. 99992470183 f l o a t 0. 99999999999 f l o a t 0. 99992470183 f l o a t 0. 99969881869 f l o a t 0. 99932238459 f l o a t 0. 99879545620 f l o a t 0. 99811811290 f l o a t 0. 99729045668 f l o a t 0. 99631261218 f l o a t 0. 99518472667 f l o a t 0. 99390697000 f l o a t 0. 99247953460 f l o a t 0. 99090263543 f l o a t 0. 98917650996 f l o a t 0. 98730141816 f l o a t 0. 98527764239 f l o a t 0. 98310548743 f l o a t 0. 98078528040 f l o a t 0. 97831737072 f l o a t 0. 97570213004 f l o a t 0. 97293995221 f l o a t 0. 97003125319 f l o a t 0. 96697647104 f l o a t 0. 96377606579 f l o a t 0. 96043051942 f l o a t 0. 95694033573 f l o a t 0. 95330604035 f l o a t 0. 94952818059 f l o a t 0. 94560732538 f l o a t 0. 94154406518 f l o a t 0. 93733901191 f l o a t 0. 93299279884 f l o a t 0. 92850608047 f l o a t 0. 92387953251 f l o a t 0. 91911385169 f l o a t 0. 91420975570 f l o a t 0. 90916798309 f l o a t 0. 90398929312 f l o a t 0. 89867446569 f l o a t 0. 89322430120 f l o a t 0. 88763962040 f l o a t 0. 88192126435 f l o a t 0. 87607009419 f l o a t 0. 87008699111 f l o a t 0. 86397285612 f l o a t 0. 85772861000 f l o a t 0. 85135519311 f l o a t 0. 84485356525 f l o a t 0. 83822470555 f l o a t 0. 83146961230 f l o a t 0. 82458930278 f l o a t 0. 81758481315 f l o a t 0. 81045719825 f l o a t 0. 80320753148 f l o a t 0. 79583690461 f l o a t 0. 78834642763 f l o a t 0. 78073722857 f l o a t 0. 77301045336 f l o a t 0. 76516726562 f l o a t 0. 75720884651 f l o a t 0. 74913639452 f l o a t 0. 74095112536 f l o a t 0. 73265427167 f l o a t 0. 72424708295 f l o a t 0. 71573082528 f l o a t 0. 70710678119 f l o a t 0. 69837624941 f l o a t 0. 68954054474 f l o a t 0. 68060099780 f l o a t 0. 67155895485 f l o a t 0. 66241577759 f l o a t 0. 65317284295 f l o a t 0. 64383154289 f l o a t 0. 63439328416 f l o a t 0. 62485948814 f l o a t 0. 61523159058 f l o a t 0. 60551104140 f l o a t 0. 59569930449 f l o a t 0. 58579785746 f l o a t 0. 57580819142 f l o a t 0. 56573181078 f l o a t 0. 55557023302 f l o a t 0. 54532498842 f l o a t 0. 53499761989 f l o a t 0. 52458968268 f l o a t 0. 51410274419 f l o a t 0. 50353838373 f l o a t 0. 49289819223 f l o a t 0. 48218377208 f l o a t 0. 47139673683 f l o a t 0. 46053871096 f l o a t 0. 44961132965 f l o a t 0. 43861623854 f l o a t 0. 42755509343 f l o a t 0. 41642956010 f l o a t 0. 40524131400 f l o a t 0. 39399204006 f l o a t 0. 38268343236 f l o a t 0. 37131719395 f l o a t 0. 35989503654 f l o a t 0. 34841868025 f l o a t 0. 33688985339 f l o a t 0. 32531029216 f l o a t 0. 31368174040 f l o a t 0. 30200594932 f l o a t 0. 29028467725 f l o a t 0. 27851968939 f l o a t 0. 26671275748 f l o a t 0. 25486565961 f l o a t 0. 24298017990 f l o a t 0. 23105810828 f l o a t 0. 21910124016 f l o a t 0. 20711137619 f l o a t 0. 19509032202' f l o a t 0. 18303988796 f l o a t 0. 17096188876 f l o a t 0. 15885814334 f l o a t 0. 14673047446 f l o a t 0. 13458070851 f l o a t 0. 12241067520 f l o a t 0. 11022220729 f l o a t 0. 09801714033 f l o a t 0. 08579731234 f l o a t 0. 07356456360 f l o a t 0. 06132073630 f l o a t 0. 04906767433 f l o a t 0. 03680722294 f l o a t 0. 02454122852 f l o a t 0. 01227153829 /***************************************** /* F i l e : WARNSIS.CMD */ / * • * / /* TMS320C30 EVALUATION MODULE REAL FFT */ /* PROGRAM LINK COMMAND FILE */ /* */ /* Kim Dotto June 22 1994 */ /* */ /*************************************** w a r n s i s . o b j w a r n f f t . o b j warntwid.obj warnmath.obj -o w a r n s i s . o u t -m w a r n s i s . 1 s t - f 0x00000000 MEMORY { } VECS: org = 0 l e n = 0x40 /* RESERVED VECTOR LOCATIONS */ SRAM: org = 0x40 l e n = 0x3FC0 /* PRIMARY BUS SRAM (16K) */ RAMO: org = 0x809800 l e n = 0x400 /* INTERNAL RAMO(IK) */ RAMla: org = 0x809C00 l e n - 0x200 /* INTERNAL RAMI(IK) */ RAMlb: org = 0x809E00 l e n = 0x200 /* INTERNAL RAMI(IK) */ SECTIONS { .vecs: { ) > VECS /* RESET/INTERRUPT VECTORS . t e x t : U > SRAM / * CODE .tmpdata: {} > SRAM / * temporary c a l c u l a t i o n t a b l e . f f t _ 3 s g : { } > RAMla /* 2000 Hz t e s t d a t a . f f t s r c O : { ) > RAMla /* 1st 512 words o f FFT SOURCE . f f t s r c l : { } > RAMlb /* 2nd 512 words o f FFT SOURCE . f f t t e x t : { } > RAMO /* FFT SUBROUTINE . f f t d a t a : { } > RAMO /* FFT SUBROUTINE DATA .mtext: { } > RAMO /* MATH SUBROUTINE .mdata: { } > RAMO /* MATH SUBROUTINE DATA . b s s : { } > RAMO /* VARIABLES .data: { 1 > RAMO /* ASSEMBLY CODE CONSTANTS .s t a c k : { } > SRAM . f f t _ v o c : { } > SRAM /* Temporary voc f i l e s t o r a g e . a i c d a t a : { } > SRAM /* AIC I n f o */ */ */ */ */ */ */ */ */ */ */ */ */ 155

Cite

Citation Scheme:

    

Usage Statistics

Country Views Downloads
United States 7 1
China 4 0
France 3 0
India 1 0
City Views Downloads
Unknown 9 4
Shenzhen 2 0
Beijing 2 0
Karaikudi 1 0
Ashburn 1 0

{[{ mDataHeader[type] }]} {[{ month[type] }]} {[{ tData[type] }]}

Share

Share to:

Comment

Related Items