## 3 Conventional Music Theory for Comfortable Sound Design
### Music Theory of Melody [53]  
A melody is a combination of the pitch and the rhythm, while more figuratively, the term can include successions of other musical elements, such as tonal color. It is the foreground to the background accompaniment. A line or part need not be a foreground melody. Melodies often consist of one or more musical phrases or motifs and are usually repeated throughout a composition in various forms. Melodies may also be described by their melodic motion or the pitches or the intervals between pitches (predominantly conjunct or disjunct or with further restrictions), pitch range, tension and release, continuity and coherence, cadence, and shape. Proposed Comfortable Design Based on Auditory Masking Using Chord Progression and Melody Generation for Dental Treatment Noises  
We propose comfortable sound design using auditory masking based on chord progression and melody generation that corresponds to the peak frequencies of dental treatment noises. Figure 4 shows a flowchart of the proposed method. As shown in Figure 4, dental treatment noise is captured with a microphone using frame processing. The noise is then transformed using a fast Fourier transform (FFT) as follows:  
\[X(f;k)=\text{FFT}[x(t;k)], \tag{3}\]  
where \(t\) represents the time index, \(f\) represents the frequency index, \(k\) is the frame index, \(X(f;k)\) denotes the spectrum of the dental treatment noise at the \(k\)-th frame, \(x(t;k)\) denotes the dental treatment noise at the \(k\)-th frame, and \(\text{FFT}[\cdot]\) denotes the FFT function. The logarithmic power spectrum is calculated as follows:  
\[P(f;k)=10\cdot\log_{10}|X(f;k)|^{2}, \tag{4}\] \begin{table}
\begin{tabular}{c c c c c c c c} \hline
**Key** & **I** & **II** & **III** & **IV** & **V** & **VI** & **VII** \\ \hline C & C & Dm & Em & F & G & Am & Bm \\ \hline D\(\flat\) & D\(\flat\) & E\(\flat\)m & Fm & G\(\flat\) & A\(\flat\) & B\(\flat\) & Cm \\ \hline D & D & Em & F\(\sharp\)m & G & A & Bm & C\(\sharp\)m \\ \hline E\(\flat\) & E\(\flat\) & Fm & Gm & A\(\flat\) & B\(\flat\) & Cm & Dm \\ \hline E & E & F\(\sharp\)m & G\(\sharp\)m & A & B & C\(\sharp\)m & D\(\sharp\)m \\ \hline F & F & Gm & Am & B\(\flat\) & C & Dm & Em \\ \hline G\(\flat\) & G\(\flat\) & A\(\flat\)m & B\(\flat\)m & B & D\(\flat\) & E\(\flat\)m & Fm \\ \hline G & G & Am & Bm & C & D & Em & F\(\sharp\)m \\ \hline A\(\flat\) & A\(\flat\) & B\(\flat\)m & Cm & D\(\flat\) & E\(\flat\) & Fm & Gm \\ \hline A & A & Bm & C\(\sharp\)m & D & E & F\(\sharp\)m & G\(\sharp\)m \\ \hline B\(\flat\) & B\(\flat\) & Cm & Dm & E\(\flat\) & F & Gm & Am \\ \hline B & B & C\(\sharp\)m & D\(\sharp\)m & E & F\(\sharp\) & G\(\sharp\)m & A\(\sharp\)m \\ \hline \end{tabular}
\end{table} 
Table 1: Diatonic chords in major keys. where \(P(f;k)\) represents the logarithmic power spectrum at the \(k\)-th frame. The spectral peak is detected using the local deviation calculated from the logarithmic power spectrum \(P(f;k)\) as follows:  
\[D(f;k) = \frac{P(f;k)-\mu(f;k)}{\sigma(f;k)}, \tag{5}\] \[\mu(f;k) = \frac{1}{F}\int_{f-\frac{F}{2}}^{f+\frac{F}{2}}P(f;k)df,\] (6) \[\sigma(f;k) = \frac{1}{F}\int_{f-\frac{F}{2}}^{f+\frac{F}{2}}|P(f;k)-\mu(f;k)|df, \tag{7}\]  
where \(D(f;k)\) represents the local deviation at the \(k\)-th frame, \(F\) is the frequency bandwidth of analysis, and \(\mu(f;k)\) and \(\sigma(f;k)\) are the mean and variance of the power in \(F\) centered on \(f\) at the \(k\)-th frame. If \(D(f;k)\) is greater than the threshold value (i.e., 0.0), \(D(f;k)\) is considered a peak. The peak frequency with the highest \(D(f;k)\) is identified as the strongest peak frequency \(f_{\text{M}}(k)\). \(key(k)\), representing the key number (an integer value from 0 to 11) at the \(k\)-th frame, is determined as follows:  
* When a scale ascends by an octave, the frequency doubles;
* The chromatic scale consists of twelve pitches, each separated by a semitone interval;
* The frequency ratio between consecutive semitones is constant.