# Wearable Voice Dosimetry System
## 3 Materials and Methods
### System Validation  
#### 3.4.1 Microcontroller and Algorithm Validation  
The implementation of the algorithm in the microcontroller has been verified using Matlab (Matlab R2018b, Mathworks Inc., Natic, MA, USA) implementation as a reference. For this purpose, several test signals with known characteristics, whose magnitude spectra  
Figure 6: Microcontroller activity. The ME line is yellow if the processor is in low power mode and red if it is running. The LEA line is grey when the LEA is inactive and green or red when it is active. (**a**) No phonation was detected, and LEA activates twice: for FFT and magnitude computation. (**b**) Phonation detected, LEA activates four times for FFT, magnitude, filtering, and autocorrelation.  
are shown in Figure 2 and in Figure 5 cases (a)-(d). These specific signals exemplify the various scenarios that may arise with real signals. Case (a) illustrates the reason why exclusively using the autocorrelation method is not sufficient and how the algorithm uses the information of the magnitude of the FFT to correctly calculate the \(F_{0}\) when the first harmonic is not the one that contributes the most energy (the spectral peak corresponding to \(F_{0}\) is not the highest one), and, when in the autocorrelation function, the highest peak is not the first peak. Therefore, the algorithm searches for the highest peak in the magnitude spectrum. That peak is further examined as to whether it is the first harmonic or not. In this case, it is not, and another harmonic is found before it. The position of this earlier harmonic is used to set the \(p_{\rm FFT}\) variable and, consequently, to calculate \(F_{0}\). In case (b), the maximum of the magnitude spectrum is at the first harmonic, and, in the autocorrelation, the maximum coincides with the first peak. Since the maximum of the autocorrelation coincides with the first peak of the magnitude of the FFT, the position of this peak, \(p_{\rm acorr}\), is used to compute \(F_{0}\). In case (c), the maximum of the magnitude spectrum is in the third harmonic. This is discovered by finding another peak at 1/3 of the position of the third harmonic. Since, in the autocorrelation, the maximum coincides with the first peak, the algorithm uses \(p_{\rm acorr}\) to calculate \(F_{0}\). Case (d) is similar to case (c), except that the maximum of the magnitude spectrum occurs at the second harmonic. Again, this is detected by finding another peak at 1/2 of the position of the second harmonic. Similarly, since, in the autocorrelation, the maximum coincides with the first peak, the algorithm uses the \(p_{\rm acorr}\) to calculate \(F_{0}\). Cases (b)-(d) differ in the way the FFT magnitude peak corresponding to \(F_{0}\) is being detected but in all of them, the autocorrelation method was sufficient to calculate \(F_{0}\). In case (e), the algorithm does not use the autocorrelation results since the frequency corresponding to the maximum of the magnitude spectrum is greater than 480 Hz and only one harmonic is present. As no prior peak to the highest one is found in the magnitude, its position \(p_{\rm FFT}\) corresponds to \(F_{0}\). In all cases, the results obtained in Matlab and in the device were the same. In case (a), however, both the Matlab code and the device produced an \(F_{0}\) estimate of 88 Hz. This is because the true \(F_{0}\) of 90 Hz was purposely not a multiple integer of 4 Hz, the spectral resolution of the system. There is no such problem in cases (b)-(e) and the results obtained in Matlab and in the device were equal to the true value of \(F_{0}\) in the test signals.