## 2 Materials and Methods
In general, the longer the sample, the better the chance that the correct key will be recognized. Obviously, we would like to be able to correctly detect keys based on the analysis of very short fragments of music. In this context, there is an important difference between key recognition approaches based strictly on the key-profiles and the method utilizing the signature of fifths. In the case of the former, there is a tendency for changing the decision (the detected key) as the length of the analyzed sample is increased, especially for very short fragments of music (the key is indicated even for a single note, treating it as a tonic). In the case of the method based on the signature of fifths, the decision is made only after the main directed axis of the signature of fifths is determined. More notes are usually needed to recognize the key, but once the decision is made, it is much less likely to undergo further changes. **Example 3**. : _The comparison of different key-finding approaches._  
Let us examine the results of the key recognition performed on the fragment of the composition shown in Figure 1.0 We will use the two ways of creating the signature of fifths, first by calculating the multiplicities of occurrences of individual pitch-classes and then by calculating the aggregate durations of the pitch-classes. The key will be evaluated for a successively increased number of initial notes. The results obtained for the two representations of the analyzed fragment are presented in Figures 6 and 7. These figures also illustrate the results obtained as the outcome of the strictly correlational analysis using the key-profiles of Krumhansl-Kessler (K-K), Temperley (T), and Albrecht-Shanahan (A-S). Incorrectly recognized keys are marked in red. It is clear that, in the case of the approach based strictly on the key-profiles, decisions were made at any sample size of the musical piece; thus, for very short numbers of notes they were not correct. However, in the case of the method implementing the signature of fifths the decision was made when the sample length reached four notes and it was correct. Expanding the sample size to five notes resulted in the detection of the correct key (D-major) for the approaches based on Temperley and Albrecht-Shanahan key-profiles. In the case of the sample comprised of six notes, the direction of the main directed axis of the signature of fifths could not be determined, making it impossible to indicate the key. Further extension of the sample size, however, resulted in confirmation of the previous decision, indicating the key of D-major. Interestingly, the strictly correlational method using Krumhansl-Kessler (K-K) profiles identified incorrect keys regardless of the number of notes that were analyzed. Besides the algorithm that utilized the signature of fifths, the best results were obtained with the strictly correlational method based on Temperley (T) key-profiles. In the case of the approach implementing the Albrecht-Shanahan (A-S) key-profiles, the correct key was indicated for six notes; however, the decision was changed after extending the sample by another two notes. The results obtained for all the considered key detection approaches, and for both ways of representing the sample of music (i.e., the weighting of the tones comprising the  
Figure 1.1 Finding the key of a piece of music based on the signature of fifths. analyzed sample with the multiplicities of occurrences or aggregate durations of individual pitch-classes) are shown in Figures 6 and 7.