\chapter{Methodology}

This chapter outlines the research methodology used to generate smooth \glspl{mp} between various musical scales, particularly in the context of Western and Persian music, which includes microtonal intervals. The aim is to develop an effective computational model that enables smooth transitions between scales while retaining the emotional and tonal integrity of the music. The methodology combines music theory, computational techniques, and machine learning algorithms, particularly the \gls{som}, to achieve this goal. By using \gls{som}, the research seeks to uncover hidden patterns in the relationships between different scales and to model the subtle nuances that define key modulation. The approach is designed to provide a comprehensive understanding of the underlying structure of musical scales, offering insights into how different tonalities relate to one another and how they can transition smoothly within a musical context.

The chapter discusses the steps taken for data collection, design, and implementation of the \gls{som} algorithm, as well as the generation and evaluation of \glspl{mp}. The data collection process involves gathering a variety of musical scales from both Western and Persian traditions, paying particular attention to the microtonal intervals that distinguish Persian music. These scales are carefully analyzed to identify the key intervals and tonal relationships that will inform the creation of \glspl{mp}. The \gls{som} algorithm is then applied to map these scales onto a two-dimensional grid, where the proximity of scales on the map reflects their relative tonal similarity. The goal is to produce a map that accurately represents the relationships between scales, enabling the identification of smooth \glspl{mp} that transition from one key to another without disrupting the musical flow. Once the \glspl{mp} are generated, they are evaluated through both computational and qualitative methods to assess their emotional impact and their effectiveness in maintaining musical coherence. The chapter also discusses the criteria used for evaluating the \glspl{mp}, including the smoothness of the transitions, the emotional tone of the music, and the perceptual ease with which listeners can follow the modulation.

Through this methodology, the research aims to contribute to a deeper understanding of how musical scales, both traditional and microtonal, can be integrated into a computational model for key modulation. By employing \gls{som}, this study explores the potential of machine learning algorithms to enhance music theory and composition, offering new tools for composers, musicians, and researchers to explore key transitions and \glspl{mp} in a wide range of musical traditions. The methodology presented in this chapter provides the foundation for the subsequent chapters, which will detail the implementation and analysis of the model, as well as the results of the \gls{mp} evaluations.

\section{Data Collection}

Data collection is the basis of the methodology, as it serves as input for the computational model. In this study, the data represent interval patterns from both Iranian and Western classical music scales. The initial focus is on capturing the relationships between musical notes in these scales, including fine-grained differences in pitch for microtonal scales that are meaningful in Persian music. This nuanced approach is crucial to understand the subtle tonal shifts that occur in Persian music and to incorporate these into the \glspl{mp} between scales.

The dataset used for training the \gls{som} includes a variety of scales, each with its own specific interval pattern. These scales are carefully selected to represent a broad spectrum of musical traditions, particularly from both Persian and Western classical music \cite{29}. The scales selected for the study include:

\begin{itemize}
    \item \textbf{Major Scale (Mahur)}: This scale follows the common Western pattern of major scales, which serve as the cornerstone of Western tonal music theory.
    \item \textbf{Melodic Minor Scale}: This scale has distinct ascending and descending forms and is used in both Western and Iranian music, highlighting its flexibility and adaptability across cultures.
    \item \textbf{Harmonic Minor Scale}: Known for its strange sound, especially in Persian music, this scale has an amplified seventh interval that gives it a dramatic, otherworldly quality.
    \item \textbf{Natural Minor Scale}: This scale follows the diatonic pattern common in Western music and provides a basic basis for comparison with other scales.
    \item \textbf{Homayoun Mode}: One of the important modes in Iranian classical music, known for its distinct emotional quality, often evoking feelings of peace and nostalgia.
    \item \textbf{Shur Mode}: This Persian mode is characterized by a mixture of minor and major intervals and is often used to express melancholy, creating a complex emotional tone.
    \item \textbf{Chahargah Mode}: This mode from Persian classical music evokes a heroic and dramatic tone, frequently used to convey strength, courage, and passion.
    \item \textbf{Segah Mode}: A mode used in Persian classical music that has a unique combination of intervals, creating a mystical and solemn atmosphere, often associated with spiritual or introspective themes.
\end{itemize}

This information has been derived from the study of \cite{29}. Figure \ref{fig:figure6} illustrates that the collected data consists of a list of nodes, where each node is itself a list. The first index of each node represents the root note, while the remaining items correspond to the step degrees. In this figure, the major scale pattern is depicted, referring to seven root notes. The collected data list can follow this same structure for all musical scales. Figure \ref{fig:figure6} illustrates that the collected data consists of a list of nodes, where each node is itself a list. The first index of each node represents the root note, while the remaining items correspond to the step degrees. In this figure, the major scale pattern is depicted, referring to seven root notes. The collected data list can follow this same structure for all musical scales.

\begin{figure}[H]
    \centering
    \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (6).png}
    \caption{A set of seven Major/Mahour scales with different axis notes.}
    \label{fig:figure6}
\end{figure}

Each scale consists of seven notes and the corresponding intervals that define the relationship between the notes. These intervals can be derived through analysis of both Western and Persian musical structures. In Persian music, these intervals can include microtones (e.g., quarter tones or other subtle pitch variations) which are essential for creating the distinctive sound of Persian music. These microtonal variations often form the basis of the emotional expressiveness in Persian compositions. The inclusion of microtones in this study is critical for representing the fine distinctions in pitch that shape the musical experience in both cultures \cite{70}.

In this study, each note is represented numerically, where its pitch is denoted relative to a starting tonic note, known as the axis note (shahed), which serves as the tonal center for the scale. This numerical representation allows for precise analysis and manipulation of the data. For example, a scale like Mahour may have a tonic note at C, and the subsequent notes would be derived based on their intervals from the tonic. The microtonal variations are included by representing these intervals with higher precision (e.g., quarter tones, half steps, and other finer gradations of pitch), thus providing a more accurate mapping of musical intervals for computational analysis \cite{71}.

This data was collected from various musical theory sources, including both Western and Persian classical music literature, as well as contemporary analyses of microtonal music systems. The data collection process is designed to be exhaustive and comprehensive, capturing the full range of scales and modes used across both musical traditions. The collected data is then encoded into a numerical format suitable for processing by the \gls{som} algorithm. This encoding process ensures that the microtonal intervals are preserved and can be effectively used in the generation of \glspl{mp} \cite{72}.

The contents of each item in the node list are shown in Figure \ref{fig:figure7}. The first item represents the scale degree, where the axis note defines the melody.

\begin{figure}[H]
    \centering
    \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (7).png}
    \caption{Structure of the node list, illustrating how the axis note determines the melody based on scale degrees.}
    \label{fig:figure7}
\end{figure}

Since each musical note, considering microtones, can exist in five different forms (sharp, flat, natural, koron, and sori), Figure \ref{fig:figure8} illustrates that each item in the node representing scale degrees can have five possible variations.

\begin{figure}[H]
    \centering
    \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (8).png}
    \caption{The range of values for each item in the collected data, considering the microtones used in Persian music.}
    \label{fig:figure8}
\end{figure}

Image \ref{fig:figure9} illustrates how the different states of each note can be represented using numbers. These numbers correspond to the position of each note within the list that defines the range of comma counts in a scale.

\begin{figure}[H]
    \centering
    \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (11).png}
    \caption{Representation of first degree's possible positions in a scale using index numbers based on the total count of commas in the scale.}
    \label{fig:figure9}
\end{figure}

This expanded data set is essential for the model, as it allows for the generation of modulation paths that respect both the microtonal subtleties of Persian music and the broader structural relationships in Western music. With this rich set of data, the \gls{som} will be able to generate nuanced and accurate paths for modulation between scales, accounting for both the emotional and technical aspects of musical transitions.

\section{Designing the \gls{som}}

The design process for the \gls{som} involved several key components, which were critical to ensuring the model effectively captured the complexities of musical scales, including their \gls{mt} features. The steps are as follows: \cite{74}

\begin{itemize}
    \item \textbf{Grid Dimensions:} The \gls{som} was initialized with a two-dimensional grid of nodes. Each node in the grid represents a cluster of similar scales, and its position reflects the relationship of scales with one another based on their interval patterns. The grid's size was carefully chosen after testing several configurations, balancing computational efficiency with the model’s ability to capture complex relationships between scales. A larger grid allowed for more detailed clustering, but required more computational power, while a smaller grid could lead to oversimplification. Therefore, finding the optimal size for the grid was a key design decision.
    
    Figure \ref{fig:figure10} demonstrates the initial estimation of the map dimensions by counting the possible nodes based on the permutations of different states of each node’s items.
    
    \begin{figure}[H]
        \centering
        \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (9).png}
        \caption{An initial estimate of the map dimensions required for the \gls{som} algorithm.}
        \label{fig:figure10}
    \end{figure}
    \item \textbf{Data Representation:} Each musical scale was represented as a vector
    The numerical values of these values correspond to the pitch relationships between
    notes, with particular attention to the inclusion of microtonal intervals.
    The minor tones of Iranian music, which are smaller than Western semitones
    are particularly important to include, as they form a central aspect of the Persian
    musical system. The notes within each scale were encoded as a set of features, where each feature indicates the relationship of a note to the tonic (axis note) and other notes in the scale. This numerical representation enabled the \gls{som} to analyze and process the data efficiently, while still preserving the intricate details of each scale's structure.
    
    Since the product of possible states for each node is 109,375 and the nodes are supposed to be adjacent to each other in a two-dimensional grid, the potential dimensions of our map at its largest will be the square root of this number. As shown in Figure \ref{fig:figure11}, each node is 7-dimensional, and the entire map system is two-dimensional, with the adjacency of the nodes determining the layout.
    
    \begin{figure}[H]
        \centering
        \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (10).png}
        \caption{Representation of the 7-dimensional nodes within a 2-dimensional map, where the layout is determined by the adjacency of the nodes.}
        \label{fig:figure11}
    \end{figure}
    \item \textbf{Initial Weights:} The initial weights for each node in the \gls{som} grid were set randomly, but within a carefully defined range that reflected the potential values of musical intervals. These intervals were chosen to encompass the full range of possible pitch relationships found in both Western and Persian musical systems. Western music typically operates within a twelve-tone temperament framework, in which basic intervals consisting of whole steps and semitones form the basis of most musical structures. In contrast, Persian music, with its deep history of microtonality, utilizes intervals that fall between Western semitones, resulting in a unique system of microtonal steps. The inclusion of these microtonal intervals in the initial range of weights was essential for ensuring that the \gls{som} could accommodate the complexities of Persian music, which features a rich variety of intervals that are not present in traditional Western music.

    To ensure that the \gls{som} was capable of effectively learning and clustering scales from both traditions, the range of initial weights was chosen to reflect this duality. The weight of each node in the network therefore corresponded to the potential pitch distances present in the scales analyzed, ensuring that nodes could represent different relationships between internal substructures of both Western and Persian scales. By initializing the weights in this way, we provided the \gls{som} with a starting point that was both flexible and capable of adapting to the diverse pitch intervals that would be encountered during the training process. This flexibility was crucial in allowing the \gls{som} to learn meaningful representations of the different scales, facilitating the clustering of related scales and the generation of smooth transitions between them.

    As the \gls{som} was trained on the musical data, the random initialization of weights played an important role in allowing the algorithm to explore the full range of possible pitch intervals. The initial weights provided a foundation for the learning process, ensuring that the system did not favor any specific set of intervals over another. Instead, the weights were adjusted gradually through the training process, with the system refining its understanding of musical structures and the relationships between scales. This adaptive process allowed the \gls{som} to generate clusters of scales that reflected the musical logic and structure of both Western and Persian traditions, while also respecting the \glspl{mt} nuances that characterize Persian music.

    Since each scale degree has only 5 different frequency states and we have converted these states into numbers, we can generate random nodes. For example, as shown in Figure \ref{fig:figure12}, the possible numerical values for the fifth degree of each scale are 26, 28, 31, 34, and 36. We repeat this process to create all possible nodes. To assist with the learning process, nodes that share the same scale but have different root notes are created consecutively so that, in the initial map, these nodes are deliberately placed as neighbors. This helps accelerate learning and facilitates greater interaction during the process.

    The randomness of the initial weights also helped prevent the \gls{som} from converging prematurely to a suboptimal solution. By starting with random values within the defined range, the \gls{som} had the opportunity to explore different configurations of pitch intervals and scale structures. This exploration was essential for ensuring that the system could generate meaningful and musically coherent results, rather than becoming trapped in a local optimum that might not reflect the true diversity of musical scales. Over time, as the training process progressed, the weights were adjusted in such a way that they corresponded more closely to the actual pitch intervals and scale structures in the training data, leading to the formation of meaningful clusters that represented different musical scales.

    \begin{figure}[H]
        \centering
        \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (14).png}
        \caption{An example of numerical values for the fifth scale degree, showing how random nodes are generated from frequency states.}
        \label{fig:figure12}
    \end{figure}

    \item \textbf{Normalization:} Normalizing the data is crucial in this study because the \gls{som} algorithm uses a distance calculation between two vectors, and unnormalized data can bias the results toward larger values and the seventh degree notes of the scale. Since each degree in the vector of each node has specific values and only 5 possible states, we normalize these values using a formula that changes the minimum value to 0 and the maximum value to 1:
    \begin{equation}
        x' = \frac{x - x_{\min}}{x_{\max} - x_{\min}}
    \end{equation}
    where \( x \) is the original value, \( x_{\min} \) is the minimum value in the vector, and \( x_{\max} \) is the maximum value in the vector. 
    
    Thus, in the end, all items of each node have values between 0 and 1, and each value represents a specific state of the degree's position of the note within the list of commas in the musical scale.
    

    \item \textbf{Identifying the \gls{bmu}:} The process of identifying the \gls{bmu} and updating the weights of the \gls{bmu} and its neighboring nodes continued until the \gls{som} had sufficiently learned to represent the relationships between the musical scales. This involved multiple cycles of training, with the \gls{som} being exposed to various input scales in each cycle. As the training progressed, the weights of the nodes converged, and the \gls{som} produced a map that meaningfully clustered the musical scales based on their interval patterns \cite{78}. The resulting map provided an effective representation of the musical scales, which could then be used to generate modulation paths between them. These modulation paths, based on the clustering and relationships learned by the \gls{som}, allowed for the generation of smooth transitions between scales, respecting both the \gls{mt} intervals of Persian music and the traditional intervals of Western music.

    Figure \ref{fig:figure14} shows that the system finds the \gls{bmu} by calculating the Euclidean distance between two 7-dimensional nodes.
    
    \begin{figure}[H]
        \centering
        \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (19).png}
        \caption{Identifying the Best Match Unit according to the input.}
        \label{fig:figure14}
    \end{figure}
    
    Also, Figure \ref{fig:figure15} shows that to update the \gls{bmu}, all 7 dimensions of the nodes correspondingly update based on the 7 items of the input node.
    
    \begin{figure}[H]
        \centering
        \includegraphics[width=1.0\linewidth]{images/chapter4/Figure (20).png}
        \caption{The \gls{bmu} is selected based on the smallest distance, and its weights, along with its neighbors, are adjusted.}
        \label{fig:figure15}
    \end{figure}

    \item \textbf{Identifying Neighborhood:} The neighborhood defines how the weights of nodes are updated during each iteration. Initially, the neighborhood function is wide, meaning that many neighboring nodes are adjusted in response to each training step. As training progresses, the neighborhood function gradually narrows, so only the \gls{bmu} and a small number of its nearest neighbors are updated. This ensures that the \gls{som} begins with a broad consideration of scale relationships and then refines its clustering as the training continues \cite{79}. The gradual narrowing of the neighborhood radius allows the map to fine-tune its representation of the data over time, improving the clustering accuracy and the quality of modulation paths \cite{80}. By adjusting the neighborhood function in this way, the \gls{som} algorithm can adapt to the inherent structure of musical scales, facilitating a more accurate representation of the relationships between scales and their potential transitions.
    \glspl{som} typically consider node neighborhoods either as rectangular grids or hexagonal (octagonal) grids. Our choice is to use eight neighbors for each node, providing more connections between nodes. This is because each node has 7 dimensions, and musical scales may have several neighboring steps.

    Figure \ref{fig:figure16} illustrates how, in our proposed model, the neighbors of each node are related based on their indices in the neuron list.
    \begin{figure}[H]
        \centering
        \includegraphics[width=0.4\linewidth]{images/chapter4/Figure (21).png}
        \caption{In this method, 8 neighboring nodes are considered for each node.}
        \label{fig:figure16}
    \end{figure}

    \item \textbf{Convergence Criteria:}
Training continues until the algorithm converges, meaning that the weights of the nodes no longer change significantly. Several factors influence convergence in the \gls{som} algorithm:
  \begin{itemize}
    \item \textbf{Decay of the Learning Rate:} During training, the \gls{lr}, denoted as \( \eta(t) \), gradually decreases over time. This ensures that as the algorithm progresses, the updates to the node weights become smaller, allowing the map to stabilize. A common approach is to update the \gls{lr} as:
      \begin{equation}
      \eta(t) = \eta_0 \cdot \exp\left( -\frac{t}{\tau} \right)
      \end{equation}
      where \( \eta_0 \) is the initial \gls{lr}, \( t \) is the number of iterations, and \( \tau \) is a constant that controls the rate of decay. As \( \eta(t) \) approaches zero, the updates to the weights become negligible, signaling convergence.
      
    \item \textbf{Decay of the Neighborhood Radius:} Similar to the \gls{lr}, the neighborhood radius \( \sigma(t) \) also decays over time. This means that in the beginning, the weight updates affect a large group of neighboring nodes, but as training progresses, only nodes that are very close to the \gls{bmu} are updated. A typical update rule is:
      \begin{equation}
      \sigma(t) = \sigma_0 \cdot \exp\left( -\frac{t}{\tau_{\sigma}} \right)
      \end{equation}
      where \( \sigma_0 \) is the initial neighborhood radius and \( \tau_{\sigma} \) is the time constant that controls the decay rate.
      
    \item \textbf{No Significant Change in Weights:} Convergence is also identified when the changes in the weights of the nodes fall below a certain threshold. In other words, after a certain number of iterations, the weights of the nodes are considered stable, and further updates are minimal. The convergence criterion can be expressed as:
      \begin{equation}
      \sum_{i=1}^{N} \left| \Delta \mathbf{w}_i(t) \right| < \epsilon
      \end{equation}
      where \( \Delta \mathbf{w}_i(t) \) is the weight change of the \( i \)-th node at time \( t \), and \( \epsilon \) is a small threshold value.

    \item \textbf{Example:} Let’s assume we are training a \gls{som} for musical scales. Initially, the \gls{lr} is set to a value of 0.1, and the neighborhood radius is set to 5. As training progresses, the \gls{lr} decays to 0.01, and the neighborhood radius reduces to 1. At this point, if the weight changes for any node are less than 0.001 over the course of 100 iterations, we consider the map to have converged. The trained map will then reveal patterns, such as clusters of similar musical scales or modulation paths between scales.
  \end{itemize}


\end{itemize}

After training, the map is visually inspected to ensure that the clusters align with known musical theory concepts. Similar scales are grouped together, and dissimilar scales are placed further apart on the grid. This clustering allows for the identification of \gls{mp} between different scales. The visual inspection of the map helps to validate the effectiveness of the \gls{som} in capturing the relationships between scales, ensuring that the clustering reflects both the theoretical and practical aspects of musical modulation. The trained map can then be used as a basis for further exploration, such as generating \gls{mp}, examining transitions between different scales, or analyzing the potential for smooth modulation across Western and Persian music systems.

\section{Modulation Path Generation}

Once the \gls{som} is trained, the next step is to generate \gls{mp} between different scales. Modulation refers to the process of transitioning from one key or mode to another in a musical piece. In this research, the aim is to generate smooth \gls{mp} that maintain the tonal coherence and emotional integrity of the music.

The generation of \gls{mp} involves identifying pathways through the \gls{som} grid that allow for gradual transitions between different musical scales. These paths are visualized as lines between nodes in the \gls{som}, with each node representing a musical scale. The paths are drawn in such a way that they reflect smooth transitions in terms of both tonal relationships and emotional qualities.

To ensure the smoothness of the modulation, the following approach is used:
\begin{enumerate}
    \item \textbf{Find the closest scale to the input scale:} Similar to the process of finding the \gls{bmu}, we identify the scale in the map that is closest to the input scale and store its index.
    \item \textbf{Find the closest scale to the target scale:} We repeat the same process for the target scale, identifying its closest scale in the map and storing its index.
    \item \textbf{Apply the Bresenham algorithm:} Using the Bresenham algorithm, we determine the scales that lie along the straight line path between the source node and the destination node.
    \item \textbf{Generate the modulation path:} The scales along the line path between the source and destination nodes are suggested as the modulation path.
    \item \textbf{Smooth auditory transition:} Since the scales are already arranged in the map based on similarity in both scale and root-note, the straight line path provides a smooth auditory transition for changing musical scales.
\end{enumerate}

Additionally, to present the modulation path to the user, a decoder is required that converts the nodes back into musical scales in a format recognizable by music experts. This decoder will transform the numerical representation of the scales into standard musical notation, ensuring that the resulting scales can be easily understood and interpreted in musical terms.

For decoding the nodes in the modulation path between the source and destination nodes, the following steps must be performed:
\begin{enumerate}
    \item \textbf{Denormalizing the data:} First, we have a list of nodes, each represented by a 7-dimensional vector. Each value in the vector is between 0 and 1, and these need to be denormalized. Using the reverse of the normalization formula, we convert them back to their original values:
    \begin{equation}
        x = x' \times (x_{\max} - x_{\min}) + x_{\min}
    \end{equation}
    where \( x' \) is the normalized value, \( x_{\min} \) and \( x_{\max} \) are the minimum and maximum values of the vector, and \( x \) is the denormalized value.
    \item \textbf{Mapping to musical symbols:} Each denormalized value corresponds to a specific position in the list of all commas of a musical scale. These values must be mapped to their corresponding musical symbols using a predefined dictionary.
    \item \textbf{Constructing the scale pattern:} Based on the tonic note of the input scale, we construct the scale pattern, ensuring that the notes are represented by their names rather than degrees. This allows for proper identification of the musical scale.
    \item \textbf{Displaying the modulation path:} Finally, there is no need to display the order or name of the scale itself. It is sufficient to display the notes in order, from note C to note B, along with the symbols indicating their alterations (such as sharp, flat, or natural).
\end{enumerate}

In Figure \ref{fig:figure17}, the process of identifying the nodes that lie along the modulation path between the source and destination scales is illustrated. These nodes represent the steps in the gradual modulation from one musical scale to another, ensuring a smooth and coherent transition.

\begin{figure}[H]
    \centering
    \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (45).png}
    \caption{Finding the shortest path between two nodes on the Self-Organizing Map using Bresenham's Algorithm.}
    \label{fig:figure17}
\end{figure}

\begin{figure}[H]
    \centering
    \includegraphics[width=0.9\linewidth]{images/chapter4/Figure (31).png}
    \caption{Finding the shortest path between two nodes on the Self-Organizing Map using Bresenham's Algorithm.}
    \label{fig:figure_decoder}
\end{figure}

In \ref{fig:figure_decoder}, the dictionary used for converting denormalized numbers into musical symbols is shown. Examples of names for musical notes include:

\begin{itemize}
    \item "bb" : Double Flat
    \item "bk" : Flat and Koron
    \item ">" : Sori
    \item "\#" : Sharp
    \item "\#>" : Sharp and Sori
    \item "\#\#" : Double Sharp
\end{itemize}

Since updates during the training phase may generate values outside the 5 expected states, we round the numbers to the closest expected values before denormalizing them to make them usable. We also support states that include double sharp, double flat, sharp sori, or flat koron. 

Finally, when displaying the modulation path nodes, many of them may be repeated consecutively in the suggested list. We use the frequency of these repetitions, relative to the total length of the path, to calculate and suggest the proportion of each scale used in the modulation process to the composer. The formula used is:
\begin{equation}
    I_{\text{scale}} = \frac{\text{Number of repetitions of a node in the path}}{\text{Total number of nodes in the path}}
\end{equation}
This means that if a part of the modulation path from the source scale to the destination scale is criticized, it can spend 60\% of the transition time on the scale that has a 60\% proportion, as this scale indicates a greater importance in the neighborhood and transition of this modulation.

Figure \ref{fig:figure30} shows an example of entering two musical measures and introducing the performer for each in the application. The system takes inputs from the source and destination scales, where the first value of each input is note-based. The input is always written in ascending order from C to B, with only the note status being important, indicated by the musical symbols mentioned earlier.
\begin{figure}[H]
    \centering
    \includegraphics[width=1.0\linewidth]{images/chapter4/Figure (44).png}
    \caption{Example of entering two musical measures and performers, demonstrating modulation path visualization and smooth key transitions.}
    \label{fig:figure30}
\end{figure}

In Figure \ref{fig:figure31}, a real depiction of the self-organizing map is shown, where a direct modulation path is drawn between the source and destination steps. This path is determined by Bresenham's Algorithm, demonstrating an efficient route for modulation between the two input steps on the trained neurons.
\begin{figure}[H]
    \centering
    \includegraphics[width=1.0\linewidth]{images/chapter4/Figure (43).png}
    \caption{A real depiction of the self-organizing map with a direct modulation path between the source and destination steps, determined by Bresenham’s Algorithm.}
    \label{fig:figure31}
\end{figure}

Figure \ref{fig:figure32} The output image of the application, where the user has configured the presence of quarter tones and entered two input scales. In the output, each suggested step is accompanied by its importance percentage in the modulation path, which is determined based on the frequency of each step’s occurrence consecutively along the path. The display of each step is such that the first note is note-based, and the remaining notes are in ascending order from C to B, with only their status being important. This helps the composer refine the modulation process and ensure smoother transitions between the scales.

\begin{figure}[H]
    \centering
    \includegraphics[width=1.0\linewidth]{images/chapter4/Figure (46).png}
    \caption{Application output showing the step path and usage recommendations based on input scales and quarter tones.}
    \label{fig:figure32}
\end{figure}

The output of the application is a sequence of nodes, each representing a step
in the modulation process. These nodes correspond to trained neurons within
the SOM that guide the modulation path. The sequence of nodes is structured
such that redundant or unnecessary nodes are merged, simplifying the transition
while maintaining accuracy. This simplification process ensures that the generated
modulation path remains efficient and easy to follow, without compromising the
musical integrity of the transition.
Additionally, the importance of each node is weighted based on its frequency
within the modulation path. This weighting system allows musicians to emphasize
or de-emphasize certain steps in the path, depending on their musical preferences or
the specific requirements of the composition. For example, nodes that are critical
to the harmonic flow of the modulation can be highlighted, while less significant
nodes can be minimized, offering more flexibility in the final modulation result.
The system also provides visual representations of the modulation process,
making it easier for composers and performers to understand the structure of the
modulation and visualize the transition between keys. These graphical representations display the modulation path within the SOM, highlighting key steps in
the sequence. The visual output aids in the understanding of how the modulation
progresses, helping composers to make informed decisions when adjusting the path
or making modifications based on their artistic vision.