# Technical, Musical, and Legal Aspects of an AI-Aided Algorithmic Music Production System
## 2 Materials and Methods
### The Generator
The second stage is an analogue to the process of composition, where a series of operations eventually produces a formal musical score. A musical work may be seen as a hierarchic, multi-layer structure. Its design requires the interaction of multiple algorithms with different internal data representations. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Data** & **Type** & **Comment** \\ \hline Genre & Enumeration & Single choice from a list \\ Duration & Integer & [s] \\ Tempo & Integer & [BPM] \\ Mood & Floating point & Range from _sad_ to _happy_ \\ Oddity & Floating point & Range from _normal_ to _odd_ \\ Tuning & Floating point & Fundamental frequency of A4 [Hz] \\ \hline \hline \end{tabular}
\end{table} 
Table 1: User-controlled parameters defining a single musical work. Figure 2: The model of the music generation process. At the top level, an overall structure of a composition is determined by a musical form. Automatic production may be based upon a set of common forms typical of particular genres and a parameter-guided series of choices. Choices are made based on genre-dependent probabilities and include the relation between harmony and form, i.e., the number of chords in a sequence, the size of chord areas compared to a phrase length, and the repeatability. Other decisions concern lengths of internal parts, which are related to a type of form as well. All of these decisions are made with regards to the total recording duration and the tempo, both of which are fixed and given by a user. Specific tempo-duration combinations can accommodate specific types of forms, which is another rule-based decision. Finally, instruments or tracks (such as ambient) are chosen, including a single or a pair of lead instruments--again, this choice is guided by the genre. A form needs to be substantiated into a specific structure. This purpose may be served by the concept of patterns and order adapted from music trackers and groove boxes [33]. Thus, the structure of a composition is represented by a two-dimensional plan consisting of a set of instrument-assigned tracks, each with its own sequence of sections. A section represents a constant-length segment of a track, usually a few measures. It is common for musical material to be reused throughout a composition. Therefore, each track has its own set of unique sections to pick from, and the plan stores a sequence of section IDs, arranged in any order within tracks, including repetitions or omissions (Figure 3). It is here that particular forms, symmetric or asymmetric, such as a reprise form, rondo, variations, chorus-verse, and others, are substantiated into a layout, such as in Figure 3, considering internal sub-parts, use of instruments, breaks, etc. These choices are rule-based, with different rules for particular genres. Elements of fuzzy logic are used to guide probability-based decisions. Before sections can be populated with rhythms and melodies, a layer of harmony needs to be considered. It imposes certain restrictions on the plan; hence, both need to be designed in parallel. The harmony is represented by a sequence of root pitch distances, measured in semitones in relation to a pitch assumed as an initial tonic. In many genres, such a sequence may be looped, and its length may vary between generated works. One section of a track in a plan of composition is assigned to a single step of the harmonic sequence. Longer sequences may be paired with shorter sections. Looped sequences are reflected in particular patterns within the plan. The type of harmonic sequence is related to the selected genre. The simplest one is used in relaxation and electronic genres only, though less frequently in the latter. It is based on the concept of minimal music and on the repetition of a single chord rooted in a single scale. A bit more complex sequence type consists of two alternating chords in one of several root relations, such as the dominant, subdominant, mediant, or next-step. This type can be used in all genres.