Context-sensitive Search

MPS provides advanced context-sensitive search functionality to find musical material in a corpus of compositions. Musical search queries can be expressed in the domain-specific language introduced in chapter Composition Language and Context Tree Models. Conceptually, search queries are formulated in terms of a compositional fragment, which is transformed to a corresponding context layer model search pattern (see chapter Context Layer Models for more details) and matched against context layer model representations of the pieces in the corpus.

Formulating Search Queries

To search for the rhythm of Beethoven’s 5th Symphony motif, for instance, the search query can be formulated as:

composition
{
    rhythm _8 8 8 8 2
}

To search for a combination of this rhythm with the scale degrees 4 4 4 2 in the key C minor, the query syntax could be:

composition
{
    key Cm, rhythm _8 8 8 8 2, pitches 4 4 4 2
}

Performing Context-sensitive Search

After formulating a search query, the search process can be invoked by clicking the button in the toolbar. The search query file must either be opened in the active editor or be selected in a navigator-based view. Alternatively, the search process can be initiated by invoking the context menu with a right click and choosing Run AsContext-sensitive Search Query.

Search Configuration

When a search query is executed for the first time, a launch configuration is automatically created and a dialog is opened in which further search parameters can be set:

In this dialog, the corpus location, i.e. a file or folder to be searched, must be specified. Refer to the following table for descriptions of other search parameters:

ParameterDescription
Match pitches in all octavesEnables abstraction for octaves. For example, if the search query contains pitches in octave 4 (which is the middle octave), the same pitches will also be matched in other octaves.
Key AbstractionThis option will enable key context matching only based on the minor/major flag. For example, if the query contains a context specifying the key C minor, matches will be found in all minor keys.

Search launch configurations can be reused, edited and deleted at any time. Refer to section Launch Configurations for further details.

Search Result Presentation

Search results will be displayed in the Search view, which is located at the bottom of the MPS IDE by default. Search results are presented hierarchically in a table. For each search result, the workspace-relative file path, stream numbers, measures, beats (i.e. zero-based point of time in the corresponding measures) and absolute time is displayed as shown in the following screenshot: