# Pareto-Optimized AVQI Assessment of Dysphonia: A Clinical Trial Using Various Smartphones
## 3 Materials and Methods
### Calculating Required Voice Characteristics
```
1:functionPitchAnalysis(\(sound\), \(timeStep\), \(pitchFloor\), \(useGaussianWindow\), \(pitchCeiling\), \(silenceThreshold\), \(voicingThreshold\), \(octaveCost\), \(octaveJumpCost\), \(voicedUnvoicedCost\))
2:\(resampledSound\leftarrow\) Resample(\(sound\), \(2\times pitchCeiling\))
3:\(preEmphasizedSound\leftarrow\) PreEmphasize(\(resampledSound\), \(pitchFloor\))
4:\(windowLength\gets 1/pitchFloor\)
5:if\(timeStep=0\)then
6:\(timeStep\gets 0.25/pitchFloor\)
7:endif
8:if\(useGaussianWindow=True\)then
9:\(windowLength\gets 2\times windowLength\)
10:endif
11:\(pitch\leftarrow\) CreateEmptyPitch()
12:\(pitch\leftarrow\) SetTimeStep(\(pitch\), \(timeStep\))
13:\(pitch\leftarrow\) SetPitchFloor(\(pitch\), \(pitchFloor\))
14:\(pitch\leftarrow\) SetSilenceThreshold(\(pitch\), \(silenceThreshold\))
15:\(pitch\leftarrow\) SetVoicingThreshold(\(pitch\), \(voicingThreshold\))
16:\(pitch\leftarrow\) SetCeiling(\(pitch\), \(pitchCeiling\))
17:\(pitch\leftarrow\) SetOctaveCost(\(pitch\), \(octaveCost\))
18:\(pitch\leftarrow\) SetOctaveJumpCost(\(pitch\), \(octaveJumpCost\times 0.01/timeStep\))
19:\(pitch\leftarrow\) SetVoicedUnvoicedCost(\(pitch\), \(voicedUnvoicedCost\times 0.01/timeStep\))
20:for\(frame\) in \(preEmphasizedSound\) with interval of \(timeStep\)do
21:\(frameLength\leftarrow\) the length of the analysis window
22:\(window\leftarrow\) CreateWindow(\(frameLength\), \(useGaussianWindow\))
23:\(autocorrelation\leftarrow\) Autocorrelate(\(frame\times window\))
24:\(candidates\leftarrow\) ExtractCandidates(\(autocorrelation\), \(pitchFloor\), \(pitchCeiling\))
25:\(bestCandidate\leftarrow\) FindBestCandidate(\(candidates\), \(voicingThreshold\))
26:\(pitch\leftarrow\) AddPitchMeasurement(\(pitch\), \(frame\), \(bestCandidate\))
27:endfor
28:\(pitch\leftarrow\) PostProcessPitch(\(pitch\))
29:return\(pitch\)
30:endfunction
```  
**Algorithm 2** Pitch analysis based on the cross-correlation method. ```
1:functiongetFormatMean(\(formantNum\), \(fromTime\), \(toTime\), \(units\))
2:\(formantObj\leftarrow\) selected Formant object
3:\(mean\gets 0\)
4:\(count\gets 0\)
5:for\(i\gets 1\) to \(n\)do
6:\(time\leftarrow\) time at index \(i\) of formantObj
7:if\(time<fromTime\) or \(time>\) toTimethen
8:continue
9:endif
10:endfor
11:\(formantVal\leftarrow\) formant value at index \(i\), formant number \(formantNum\) of formantObj
12:endfunction
```  
**Algorithm 3** Formant calculation. Figure 7: Pitch analysis and harmonicity calculation. ```
1:functionCalculateHarmonicity(\(sound,from\_time,to\_time,timestep\),

\(silence\_threshold,periods\_per\_window\))
2:\(harmonicity\leftarrow\)ToHarmonicity(\(sound\), timestep, silence\_threshold,

\(periods\_per\_window\))
3: Select(harmonicity, \(from\_time,to\_time\))
4:returnGet_mean (harmonicity)
5:endfunction
```  
**Algorithm 4** Harmonicity calculation. The third step is to calculate the shimmer (see Figure 8 and Algorithm 5). This algorithm calculates two measures of shimmer, which is a measure of cycle-to-cycle variations in vocal amplitude. The input is a sound waveform, a point process representing glottal closures, and the start and end times in seconds. The output is the shimmer local value and the shimmer dB value.