# Fuzzy Retrieval of Musical Scores Based on Melodic Patterns

Adel Aly, Olivier Pivert, Virginie Thion

► To cite this version:

Adel Aly, Olivier Pivert, Virginie Thion. Fuzzy Retrieval of Musical Scores Based on Melodic Patterns. Proceedings of the IEEE International Conference on Fuzzy Systems (FUZZ-IEEE'25), Jul 2025, Reims, France. hal-05050369

HAL Id: hal-05050369

https://hal.science/hal-05050369v1

Submitted on 29 Apr 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Fuzzy Retrieval of Musical Scores
Based on Melodic Patterns

Adel Aly

Univ. Rennes, CNRS, IRISA

Lannion, France

adel.aly@irisa.fr

Olivier Pivert

Univ. Rennes, CNRS, IRISA

Lannion, France

olivier.pivert@irisa.fr

Virginie Thion

Univ. Rennes, CNRS, IRISA

Lannion, France

virginie.thion@irisa.fr

*Abstract*—Retrieving music pieces based on their content is a growing area of research in the field of database management. This paper addresses the challenge of flexible musical score retrieval based on melodic patterns, offering two contributions. First, it introduces a theoretical framework that leverages fuzzy logic to enable flexibility. The approach allows a user to define fuzzy tolerance thresholds for pitch, duration, and sequencing, and returns ranked answers that “more or less” match a given pattern, offering both explainability and customization. Second, it presents MAELIS, an implementation of this framework as an extension of the CYPHER graph-pattern query language. MAELIS is integrated inside the SKRID platform, a digital library that stores musical scores of folk music from the French region of Brittany.

I. INTRODUCTION

Music Information Retrieval (MIR) is a multidisciplinary field encompassing digital library management, information science, musicology, and computer science, among others [?]. Among the key challenges in MIR is the retrieval and analysis of digitized music data [?]. While metadata-based search remains dominant, content-based search is increasingly significant for performers, musicologists, and educators, enabling tasks such as identifying tunes, detecting plagiarism, and selecting pieces for specific performance contexts. Content-based search can be categorized into audio-based and symbolic-based approaches. This work uses a symbolic representation of music, specifically Western classical notation, and addresses the task of retrieving musical scores that contain a certain sequence of notes, called melodic pattern.

Most existing methods for melodic pattern search rely on exact matching techniques, with the risk of getting empty or plethoric answer sets [?, ?]. Being able to retrieve similar but not strictly identical patterns is essential for scenarios like exploratory search, identifying variations of motifs, or query-by-humming [?]. Current flexible approaches, however, lack fine-tuned customization and an answer explanation functionality.

In this paper, we introduce a framework for **melodic pattern search, based on fuzzy logic**. It supports **adjustable tolerance** for pitch, duration, and sequencing, enabling **approximate matching and ranking answers** on the basis of their relevance. To the best of our knowledge, **this is the first application of fuzzy logic in this context**. We also present an **implementation of the theoretical framework**, which consists of an extension of the graph pattern matching

functionality from the CYPHER language. This implementation has been integrated as a querying module inside the SKRID platform [?], which is devoted to the management of traditional corpora of music from Brittany.

The paper is structured as follows: Section II reviews existing melodic pattern searching methods. Sections III and IV present the theoretical framework and its implementation in the SKRID platform, respectively. Finally, Section ?? concludes the paper and outlines a few research perspectives.

II. STATE OF THE ART

Numerous approaches have been proposed for exact melodic pattern matching in musical score databases. These methods, ranging from textual representations to graph-based models, have their strengths and limitations. However, exact matching often fails to meet the needs of users who require flexibility in their search, as is the case when exploring music corpora for inspiration or identifying altered recurring motifs. Here, we focus on the few approaches in the literature that provide some degree of flexibility in their searches.

A common method for achieving flexibility in textual formats is through the use of edit distances, which measure the number of deletions, insertions, and substitutions required to transform one string into another [?, ?, ?]. While this method has been applied to musical scores represented as a text, it is inherently limited. Indeed, music contains specific attributes which require specialized treatment. Unlike text, which is strictly sequential and for which rhythm information is irrelevant, music involves notes with durations and allows multiple notes to be played simultaneously, as in chords or polyphonic pieces. Enhancements to basic edit distance approaches, such as normalization processes aimed to handle variations in pitch register or ornamentation [?], have been proposed, but they often sacrifice some aspects of musical information to matching simplicity, such as the removal of octave distinctions, measure separation, and precise note durations.

Another approach models melodic similarity using the Earth Mover's Distance (EMD) [?]. This method models musical notes as points in a two-dimensional space (e.g., pitch and onset time) and computes the cost of transforming one note distribution into another. While innovative, this approach lacks

<footnote n="1">¹This approach is implemented in the platform Musipedia [?].</footnote>
<figure><img src="image_2.png" /><figcaption>Fig. 1. An example of a musical score</figcaption></figure>

parameterization flexibility and does not provide explainable
answers at the note level, limiting its applicability for the use
cases considered in the present work.

### III. FLEXIBLE PATTERN MATCHING FRAMEWORK

In this section, we present a framework for retrieving the
scores that contain a given musical pattern or an acceptable
approximation of it. This framework relies on a data model
suited to the representation of musical scores, and an associ-
ated selection operator. Basic musical notation concepts will
be explained in footnotes for the unfamiliar reader.

#### A. Data Model for Musical Content

We first define an abstract data model for representing
musical content, considering the voice<fnref n="2" /> as being the core
element of a musical score, in which the patterns will be
searched. Our data model is “event-based” in the sense that
we view notes as temporally bound objects with specific
attributes, namely pitch and duration. This approach draws
inspiration from the work in [?], which conceptualizes voices
as temporal functions, with the set of sounds as the image
set and temporal intervals as the preimage set. Set-oriented
modelling being coherent with some existing musical data
formats, this choice allows for an intuitive implementation of
the theoretical framework, as will be seen in Section IV. Let
us first define the notion of a musical event.

**Definition 1 (Musical event):** A musical event, denoted by $s_{t_1}^{t_2}$, is defined by its pitch $s$, its onset time $t_1$, and its ending time $t_2$, where $t_2 > t_1$. Rests are denoted by $\perp_{t_1}^{t_2}$.

For instance, in the first staff of Fig. 1, which begins by
the treble key, the first musical event is the silence $\perp_0^1$, then
follows a note event $E4_1^2$, itself followed by $A4_2^3$, etc.

**Definition 2 (Event properties):** Let $e = s'_t$ be an event. We denote $start(e) = t$, $end(e) = t'$ and $sound(e) = s$. We also denote the duration of $e$ by $dur(e) = end(e) - start(e)$. By definition, $dur(e) > 0$ for any $e$.

**Definition 3 (Sound distance):** Let $e_1$ and $e_2$ be two events. We define a sound-wise distance between $e_1$ and $e_2$ as

$$D_{\text{sound}}(e_1, e_2) = |\text{sound}(e_2) - \text{sound}(e_1)|.$$

We consider that one tone<fnref n="3" /> corresponds to a distance of 1.
For the sake of notation simplicity, we extend $D_{\text{sound}}$ to
pitches: for instance, we consider that event $C4_0^4$ and sound
$D4$ are one tone apart, or simply $D_{\text{sound}}(C4_0^4, D4) = 1$. The

$\text{sound distance}$ corresponds to the notion of interval between
notes in music theory.

We can now turn to the notion of musical content of a *voice*,
defined by a set of musical events.

**Definition 4 (Voice):** A voice $V$ is a set $\bigcup_{j=1}^n \{s_j^{t_{j+1}}\}$ of musical events (with $t_1 = 0$) satisfying:

1) $\exists e \in V$ such that $start(e) = 0$,

2) $\forall e \in V$, either $start(e) = 0$ or $\exists e' \in V$ s.t. $e \neq e'$ and $start(e) = end(e')$, i.e. there are no "holes" in a voice,

3) $\forall (e, e') \in V_{\text{end}}, end(e) = end(e')$ where $V_{\text{end}} = \{e \in V \mid \nexists e' \text{ s.t. } e \neq e' \text{ and } start(e') = end(e)\}$, i.e. the "end events" all end at the same time.

**Example 1:** The score from Fig. 1 writes as follows, where a time step of 1 is equal to the duration of a ♫:

$$V = \{\begin{aligned} & \perp_0^1, E4_1^2, A4_2^3, E5_4^3, A5_4^5, A4_5^6, E5_6^7, A5_7^8, \\ & \perp_8^9, E4_9^{10}, A4_{10}^{11}, E5_{11}^{12}, A5_{12}^{13}, A4_{13}^{14}, E5_{14}^{15}, A5_{15}^{16}, \\ & \perp_{16}^{17}, D4_{17}^{18}, \#F4_{18}^{19}, A4_{19}^{20}, D5_{20}^{21}, \#F4_{21}^{22}, A4_{22}^{23}, D5_{23}^{24}, \\ & \perp_{24}^{25}, D4_{25}^{26}, \#F4_{26}^{27}, A4_{27}^{28}, D5_{28}^{29}, \#F4_{29}^{30}, A4_{30}^{31}, D5_{31}^{32}, \\ & C4_0^8, C4_8^{16}, C4_{16}^{24}, C4_{24}^{32} \end{aligned}\}$$

The first sixteen musical events correspond to the notes that
appear in the first measure of the treble key staff in Fig. 1, the
sixteen following ones to the notes that appear in the second
measure of the treble key, and the remaining events to the
notes that appear in the bass key staff.

This set-oriented model is chosen for its capability of
representing overlapping musical events in a simple manner,
which is useful for addressing polyphonic music. For instance,
in Fig. 1, the first rest on the top staff coincides with the first
note on the second staff.

Based on this modeling, we can now define how to retrieve
the sequences that match a melodic pattern inside a voice.

#### B. Melodic Pattern Selection

We denote by $\sigma_P(V)$ the selection of a melodic pattern over
a voice, where $V$ is a voice and $P$ is a pattern that takes the
form of a sequence $\langle N_1, ..., N_k \rangle$, where each $N_i$ has the form
$(s_i, d_i)$, $s_i$ denoting a sound and $d_i$ a duration.

**Definition 5 (Selection of a pattern over a voice):** Let $P = \langle N_1, ..., N_k \rangle$ be a melodic pattern where each $N_i$ has the form $(s_i, d_i)$, $s_i$ denoting a sound and $d_i$ a duration. Let $V$ be a voice. Let $\mathcal{P}(V)$ be the power set of $V$. The set of matches of $P$ in $V$ is defined by:

$$\sigma_P(V) = \{A \mid A \in \mathcal{P}(V) \text{ and } A \text{ "matches" } P\}$$

where $A = \bigcup_{j=1}^k s_j^{t'_j}$ "matches" $P$ iff there is an isomorphism $h$ from $\{N_1, ..., N_k\}$ to $A$ such that:

1) For each $N_i = (s_i, d_i)$ in $\{N_1, ..., N_k\}$, one has

$$D_{\text{sound}}(s_i, h(N_i)) = 0 \text{ and } \text{dur}(h(N_i)) = d_i$$

which states that $h(N_i)$ has the right pitch and duration.

2) For each $N_i = (s_i, d_i)$ in $\{N_1, ..., N_{k-1}\}$, one has

$$\text{start}(h(N_{i+1})) - \text{end}(h(N_i)) = 0$$

<footnote n="2">²A sequence of the notes played by a given instrument, cf. Fig. 1.</footnote>

<footnote n="3">³A tone is a standard interval between two pitches, equivalent to two semitones. For example, the interval between C and D is a tone.</footnote>
which states that each image follows the next in the correct order and with no gaps.

**Example 2:** Let $P_1 = \langle (D4, 1), (\#F4, 1), (A4, 1) \rangle$ be a pattern. There exists an isomorphism $h$ (that satisfies Definition 5) from $P_1$ to $A = \{D4_{17}^{18}, \#F4_{18}^{19}, A4_{19}^{20}\}$ defined as:

$$h((D4, 1)) = D4_{17}^{18}, h((\#F4, 1)) = \#F4_{18}^{19},$$

$$h((A4, 1)) = A4_{19}^{20}.$$

Exact matches have been considered so far. We now define an approximate matching mechanism that makes it possible to rank the answers it returns.

### C. Flexible Selection

In order to address the need for flexibility, we use fuzzy logic as a main component of our approach. The definition below shows how to make the operator $\sigma$ fuzzy so as to implement the approximate matching mechanism.

**Definition 6 (Fuzzy selection of a pattern over a voice):** Let $P = \langle N_1, \dots, N_k \rangle$ be a melodic pattern and $V$ be a voice. Let $\mathcal{P}(V)$ be the power set of $V$. The fuzzy set of matches of $P$ in $V$, denoted by $\sigma_P^f(V)$, is defined by:

$$\sigma_P^f(V) = \{(A, \mu_P(A)) \mid A \in \mathcal{P}(V)\}.$$

The degree $\mu_P(A)$ represents how well $A$ matches $P$ and is computed by aggregating the satisfaction degrees $\mu_{\text{note}}(e_i)$ for each note $e_i$ in $A$. An isomorphism $h$ from $\{N_1, \dots, N_k\}$ to $A$ maps each element of the pattern $P$ to an element in $A$, with the satisfaction degree depending on the following fuzzy conditions for each $N_i = (s_i, d_i)$ in $\{N_1, \dots, N_k\}$:

1) **Fuzzy height of the sound:** The sound-related satisfaction degree $\mu_{\text{sound}}(s_i, h(N_i))$ reflects the closeness of $s_i$ to $h(N_i)$ in terms of pitch.

2) **Fuzzy duration:** the degree $\mu_{\text{dur}}(d_i, h(N_i))$ reflects the closeness of $d_i$ to $h(N_i)$ in terms of duration.

3) **Fuzzy sequencing:** For each $N_i$ s.t. $i < k$, the degree $\mu_{\text{seq}}(h(N_i), h(N_{i+1}))$ assesses how closely $h(N_i)$ follows $h(N_{i+1})$ in terms of timing.

For each note of $A$, a degree $\mu_{\text{note}}(h(N_i))$ is obtained using an aggregation operator $\text{ag}_{\text{note}}$:

$$\mu_{\text{note}}(h(N_i)) = \text{ag}_{\text{note}}(\mu_{\text{sound}}(s_i, h(N_i)), \\ \mu_{\text{dur}}(d_i, h(N_i)), \\ \mu_{\text{seq}}(h(N_i), h(N_{i+1}))).$$

The overall satisfaction degree $\mu_P(A)$ is obtained by applying an aggregation operator $\text{ag}$ to the satisfaction degrees of each note:

$$\mu_P(A) = \text{ag}(\{\mu_{\text{note}}(e) \mid e \in A\}).$$

Of course, not all three aspects — pitch, duration, and sequencing — have to be used in every query. Different use cases may favour certain aspects over others. For example, a rhythm-centric search might focus on duration and sequencing, while a melody-centric search would involve the three dimensions. This highlights the high degree of customizability obtained by using fuzzy logic. Database application designers can select

<figure><img src="image_3.png" /><figcaption>Fig. 2. Membership function $\mu_{\text{dur}}$</figcaption></figure>

individual membership functions for each note aspect and determine how to aggregate these aspects using the two separate aggregation operators, depending on the specific requirements of their application. The following example illustrates (i) a way to infer triangular membership functions from tolerance values (expressed as real numbers) associated with pitch, duration and sequencing respectively, and (ii) the assessment of a match, on the basis of these membership functions.

**Example 3:** Let us assume we want to search for all the occurrences of a given pattern $P_2 = \langle (D4, 1), (E4, 1), (D5, 0.5) \rangle$. In addition to exact occurrences, we accept sequences where:

* each note's pitch corresponds to the associated pattern note's pitch with a tolerance of (strictly less than) 2 tones. For instance, for $(D4, 1)$, we accept any pitch that is at most 1.5 tones away from $D$ (i.e., anything between ♩B3 and #F4). This can be set by a user-defined parameter that we will call *pitch tolerance parameter*, here with the value of 2.

* each note's duration may vary proportionally, allowing matches where the duration is more than three times shorter and less than three times longer than the pattern note. For instance, for $(D4, 1)$, we accept any duration strictly between $\frac{1}{3}$ and 3. Fig. 2 illustrates this range of acceptance. Again, a *duration tolerance parameter* set to 3 can capture this flexibility.

* consecutive notes follow the sequencing of the pattern with a gap between notes strictly smaller than a ♩. This condition translates to a *sequencing tolerance parameter* set to 2, which corresponds to the duration of a ♩, as we implicitly defined the duration of a ♩ as 1 in Example 1.

To formalize these conditions, we define the following membership functions:

* $\mu_{\text{sound}}(e_1, e_2) = \max(1 - \frac{D_{\text{sound}}(e_1, e_2)}{2}, 0)$

* Taking $z = \max(\frac{\text{dur}(x)}{\text{dur}(y)}, \frac{\text{dur}(y)}{\text{dur}(x)})$,

$$\mu_{\text{dur}}(e_1, e_2) = \begin{cases} 0 & \text{if } z \ge 3 \\ \frac{3-z}{2} & \text{otherwise.} \end{cases}$$

* $\mu_{\text{seq}}(e_1, e_2) = \max(1 - \frac{\text{start}(e_2) - \text{end}(e_1)}{2}, 0)$

Now consider $A = \{D4_{17}^{18}, \#F4_{18}^{19}, D5_{20}^{21}\}$, a subset of notes from the score of Fig. 1 (see also Example 1 for details). $A$ plays the role of the homomorphism image from Definition 6.

Let us compute the matching degree for $A$ with respect to $P$. For the first note, which is identical to the pattern note, we get three membership degrees of 1:

$$\begin{aligned} & D_{\text{sound}}((D4, 1), D4_{17}^{18}) = 0 \\ & \text{thus } \mu_{\text{sound}}((D4, 1), D4_{17}^{18}) = 1 \end{aligned}$$
<figure><img src="image_4.png" /><figcaption>Fig. 3. Graph-based modelling of the score from Fig. 1</figcaption></figure>

<figure><img src="image_5.png" /><figcaption>Fig. 4. Graph pattern modelling $P_2$</figcaption></figure>

* likewise, $\mu_{dur}((D4, 1), D4^{18}_{17}) = 1$

* sequencing does not apply to the first note, as there is no previous note, so it gets a value of 1 by default.

For $D5^{21}_{20}$, the last note in A, pitch matching is exact but duration and sequencing are not:

* $\mu_{sound}((D5, 0.25), D5^{21}_{20}) = 1$

* $\mu_{dur} = \frac{3-2}{2} = 0.5$

* start($D5^{21}_{20}$) - end($\#F4^{19}_{18}$) = 20 - 19 = 1 therefore $\mu_{seq}(\#F4^{19}_{18}, D5^{21}_{20}) = 0.5$.

To aggregate the three degrees associated with each note, let us assume that the minimum t-norm is chosen. We get an aggregated degree equal to 1 for the first note of A, and to 0.5 for the third note.

Now, to compute the overall degree of a match, we have to aggregate the degrees obtained by the different notes. Let us take the arithmetic mean as the aggregation function. Assuming that the degree of the second note is equal to 0.5, we get 0.67 as the overall matching degree for A.

## IV. IMPLEMENTATION

In this section, we present an implementation of the framework introduced above through a software tool called MAELIS (Subsection IV-A), that is integrated inside a (real) digital score library (Subsection IV-B).

### A. The MAELIS Tool

The MAELIS tool makes it possible to search for a melodic pattern in a musical score database managed by the Neo4j database management system (DBMS), while taking into account the tolerance authorized by the user as explained above. It consists in a software layer that extends the CYPHER graph-pattern query language with flexible querying capabilities.

a) **Data model:** The data model that underlies the tool uses property graphs and has the advantage of clearly representing the two primary ways a musical score is usually read: from a time series perspective, where each note of a voice follows the previous one, and from a synchronization perspective, where each note is seen as belonging to its

measure regardless of its voice, providing a comprehensive view of the notes played together across all instruments and voices. This structure enables musical score retrieval through graph-pattern queries. The model is presented in detail in [?]. Fig. 3 illustrates the modelling of the music piece from Fig. 1 in this framework.

b) **Querying:** The data is queried through graph-pattern queries. A graph-pattern query corresponds to a subgraph that defines the structure and property values one wants to retrieve. The DBMS searches the graph database to find all the instances that match this subgraph. Fig. 4 shows the representation of $P_2$, the pattern from Example 3, in the form of a subgraph. The DBMS used in our tool is Neo4j [?], a property graph DBMS. Queries addressed to Neo4j are written in the CYPHER query language [?], which allows users to describe a subgraph pattern with an ASCII-art based syntax. Listing 1 shows how $P_2$ can be written in CYPHER<fnref n="4" />.

1. MATCH

2. // Chain of 3 consecutive events

3. (e0:Event)-[:NEXT]->(e1:Event)-[:NEXT]->(e2: Event),

4. // e0 is a sixteenth note D4

5. (e0)--(f0{class:'d', octave:4, dur:16}),

6. // e1 is a sixteenth note E4

7. (e1)--(f1{class:'e', octave:4, dur:16}),

8. // e2 is a thirty-second note D5

9. (e2)--(f2{class:'d', octave:5, dur:32})

10. // Information returned in the answer

11. RETURN e0.source AS source, e0.start AS start

<caption>Listing 1. Cypher syntax for pattern $P_2$</caption>

For readers unfamiliar with the CYPHER syntax, we provide a brief overview using the example. Line 3 describes the structure of the subgraph we are searching for. In this case, we are looking for a simple chain of three events connected by the `:NEXT` relationship, representing three sequential notes in a melody. Lines 5 to 9 specify the attributes of the notes we are searching for, including pitch (denoted by `class`), octave, and duration. These attributes must match the values defined in the query for each note. Finally, the `RETURN` clause specifies

<footnote n="4">⁴In our collections, the ♫ has a duration of 16, as in classical encoding formats [?, ?].</footnote>
<figure><img src="image_6.png" /><figcaption>Fig. 5. Architecture of MAELIS</figcaption></figure>

the output of the query, which in this case includes the source of the first event (e0.source), representing the name of the song, and the start time of the event (e0.start).

c) Adding flexibility to queries: MAELIS implements an extended CYPHER syntax that incorporates the flexibility parameters discussed in Subsection III-C, as shown in Listing 2. The extended language is called CYPHER⁺ in the following.

1. MATCH
2. // Flexibility parameters for pitch,
3. // duration, and sequencing tolerance
4. TOLERANT pitch=1.0, duration=2.0, gap=0.0625
5. // Threshold for the minimum
6. // acceptable global matching degree
7. ALPHA 0.7
8. ...

<caption>Listing 2. Syntax add-on for flexibility expression</caption>

In terms of architecture, MAELIS is composed of two modules: a Transcriptor and a Score Calculator (cf. Fig. 5).

The Transcriptor module allows the user to express a fuzzy melodic pattern query in CYPHER⁺. From the tolerance parameters specified in the query, triangular membership functions for µsound, µdur and µseq are inferred (cf. Example 3), that will be used by the Score calculator module.

This fuzzy query is then transcribed into a regular (non-fuzzy) CYPHER query, thanks to a mechanism called derivation, initially introduced in a relational database context [?] and later extended to a graph database framework [?]. The crisp query captures both exact and approximate matches within the specified tolerance intervals. The Neo4j DBMS evaluates the crisp query against the database entries and retrieves all the satisfactory matches. The second part of MAELIS, implemented in the Score Calculator module, calculates a matching degree for each retrieved answer. This allows to rank-order the answers before presenting them to the user.

## B. A Practical Use in a Digital Score Library

MAELIS, which is an open-source software developed in Python<fnref n="5" />, serves as the search engine for the SKRID digital score library [?], a web application that stores collections of folk music from Brittany. SKRID is a collaborative effort with DASTUM [?], an association dedicated to preserve and disseminate the region's folk heritage. Given that the platform's users are musicians and musicologists, not computer

<figure><img src="image_7.png" /><figcaption>Fig. 6. Pattern $P_3$ in music notation</figcaption></figure>

scientists, we developed an interface that allows users to define a pattern using a piano keyboard and sliders for setting the flexibility parameters, rather than requiring knowledge of the CYPHER syntax. For the same reason, melodic patterns and results are displayed in Western classical notation. Let us consider an example query aimed to search for a sequence of four notes denoted by $P_3$ (see Fig. 6) with a pitch flexibility of at most one whole tone in either direction, as well as a duration flexibility corresponding to a multiplicative factor of at most 3. The platform's interface uses a color gradient to visually indicate the extent to which a match is satisfactory, and explains the degrees obtained by each note.

Fig. ?? is a screenshot of the user interface of the platform displaying two (among twelve) of the results for the aforementioned query. In the first match, all notes are highlighted in green, indicating that each note exactly matches the user's query. This match has a matching degree of 1. The second match is approximate, with each note deviating slightly from the original query. The degrees for each note are displayed when the user hovers over it (cf. the rectangular box in Fig. ??). Table I details the values of the degrees for this match, showing how the overall matching degree of 0.54, which is calculated (with an arithmetic mean) based on the specified flexibility parameters. Note that we used the min function for aggregating the three partial degrees attached to a given note. In the right part of Fig. ??, we can see the clickable list of the matching occurrences, ranked according to their degree.

<table><caption>TABLE I
NOTE SCORES FOR THE SECOND MATCH IN FIG. ??</caption><thead><tr><td>Pattern notes (pitch, dur.)</td><td>Approximate Match notes (pitch, dur.)</td><td>Pitch score</td><td>Dur. note score</td><td>Overall note score</td></tr></thead><tbody><tr><td>G4, 1/16</td><td>G4, 1/32</td><td>1.0</td><td>0.69</td><td>0.69</td></tr><tr><td>B4, 1/32</td><td>A4, 1/32</td><td>0.39</td><td>1.0</td><td>0.39</td></tr><tr><td>C5, 1/32</td><td>B4, 1/32</td><td>0.69</td><td>1.0</td><td>0.69</td></tr><tr><td>D5, 1/16</td><td>C5, 1/32</td><td>0.39</td><td>0.69</td><td>0.39</td></tr></tbody></table>

While performance is not the primary focus of this paper, execution time is an important factor in establishing the tractability of the approach. The query described in this section, where we search for the pattern $P_3$ with a tolerance of less than 1.5 tone for pitch and a factor of less than 3 for duration, takes 0.5 second to execute on a “modest” machine<fnref n="6" />. This query returns 378 occurrences from a database containing 628 musical scores<fnref n="7" /> and 68,770 nodes. Initial testing shows that execution time grows slowly with pattern length and

<footnote n="6">⁶Intel Core i7-13700H 13th generation processor with 16 GB of RAM.</footnote>

<footnote n="7">⁷Multiple occurrences can appear within a single musical score result.</footnote>

<footnote n="5">⁵Available at https://gitlab.inria.fr/skrid/ backend.</footnote>
<figure><img src="image_8.png" /><figcaption>Fig. 7. Two matches for $P_3$, one exact and one approximate</figcaption></figure>

remains very reasonable for patterns of up to 15 notes when tolerance concerns pitch and/or duration. However, when it concerns sequencing, the computational cost is significantly higher. For instance, tolerating up to a ♫ gap between each note increases the querying time to 2.3 seconds for 420 results.

## V. CONCLUSION AND PERSPECTIVES

This work presents a fuzzy logic-based framework for melodic pattern matching in musical scores, allowing flexible conditions on pitch, duration, and sequencing. The approach was implemented in a query engine called MAELIS, integrated into the SKRID platform, a digital library for traditional musical scores from Brittany.

Future work will aim to extend the framework so as to be able to handle polyphonic and homophonic queries (i.e. queries dealing with multiple voices or chords), enriching retrieval capabilities. Additionally, integrating melodic contours, which capture the general shape of melodies, could further enhance flexibility. Practical evaluations through in-depth user testing with musicians will provide valuable insights for refinement. Addressing the computational cost of flexible queries is also a priority, with planned investigations into optimization mechanisms to improve performance without sacrificing accuracy.

## VI. ACKNOWLEDGEMENTS

We would like to thank DASTUM for their collaboration, with special thanks to Anne-Marie Nicol and Gwenaël Piel for their involvement. We also extend our gratitude to Vincent Barreaud and Tommaso Padovano for their work on the first version of SKRID. For the current version of the platform, and the development of the fuzzy engine, we thank Louis Thomas-Girardey for his contributions.

## REFERENCES

[1] J. S. Downie, "Music Information Retrieval," *Annual review of Information Science and Technology*, vol. 37, pp. 295–340, 2003.

[2] M. A. Casey, R. Veltkamp, M. Goto, M. Leman, C. Rhodes, and M. Slaney, "Content-based music information retrieval: current directions and future challenges," *Proceedings of the IEEE*, vol. 96, no. 4, pp. 668–696, 2008.

[3] J. Ganseman, P. Scheunders, and W. D'haes, "Using XQuery on MusicXML Databases for Musicological Analysis," in *Proc. of the Intl. Conference on Music Information Retrieval (ISMIR)*, 2008.

[4] R. Fournier-S'niehotta, P. Rigaux, and N. Travers, "Querying XML score databases: XQuery is not enough!" in *Proc. of the Intl. Conference on Music Information Retrieval (ISMIR)*, 2016, pp. 723–729.

[5] B. Duggan, B. O'Shea, M. Gainza, and P. Cunningham, "Compensating for expressiveness in queries to a content based music information retrieval system," in *Proc. the Intl. Computer Music Conference (ICMC)*, 2009.

[6] "The SKRID platform," https://shaman.enssat.fr/skrid/, 2024.

[7] C. Walshaw, "Abc notation," https://abcnotation.com/, 1993.

[8] D. Huron, "Music information processing using the humdrum toolkit: Concepts, examples, and lessons," *Computer Music Journal*, vol. 26, no. 2, pp. 11–26, 2002.

[9] "Themefinder," http://www.themefinder.org/.

[10] R. Typke, P. Giannopoulos, R. C. Veltkamp, F. Wiering, and R. van Oostrum, "Using transportation distances for measuring melodic similarity," in *Proc. of the Intl. Conference on Music Information Retrieval (ISMIR)*, 2003.

[11] "Musipedia," www.musipedia.org, 2025, (consult. date).

[12] R. Fournier-S'niehotta, P. Rigaux, and N. Travers, "Modeling music as synchronized time series: Application to music score collections," *Inf. Syst.*, vol. 73, pp. 35–49, 2018.

[13] P. Rigaux and V. Thion, "Topological querying of music scores," *Data and Knowledge Engineering (DKE)*, vol. 153, 2024.

[14] Neo Technology, "Neo4j web site," www.neo4j.org, 2025 (consult. date).

[15] —, "The Cypher Manual," 2025 (consult. date), https://neo4j.com/docs/cypher-manual/current.

[16] M. Good, *The Virtual Score: Representation, Retrieval, Restoration*. MIT Press, 2001, ch. MusicXML for Notation and Analysis, pp. 113–124.

[17] P. Rolland, "The Music Encoding Initiative (MEI)," in *Proc. of the Intl. Conf. on Musical Applications Using XML*, 2002, pp. 55–59.

[18] P. Bosc and O. Pivert, "SQLf query functionality on top of a regular relational database management system," in *Knowledge Management in Fuzzy Databases*. Physica-Verlag, 2000, pp. 171–190.

[19] O. Pivert, G. Smits, and V. Thion, "Expression and efficient processing of fuzzy queries in a graph database context," in *of the IEEE Intl. Conference on Fuzzy System (FUZZ-IEEE)*, 2015, pp. 1–8.

[20] "Dastum association," https://www.dastum.bzh/association/, 1993.