Navigation

  • index
  • modules |
  • next |
  • previous |
  • music21 »
  • Documentation and tests in progress »
  • User’s Guide, Chapter 56: Segmented and Approximate Search

Previous topic

User’s Guide, Chapter 46: Streams 3: Manipulation, inPlace, and deepcopy

Next topic

User’s Guide, Chapter 57: Speeding up music21

Table of Contents

  • About music21
  • User’s Guide
  • Module Reference
  • Installation
  • Developer Reference
  • Documentation and tests in progress

Quick search

This Page

  • Show Source

User’s Guide, Chapter 56: Segmented and Approximate Search¶

Previously we have looked at ways of finding passages of notes within a single score, but what if we want to search across scores, or find only approximate matches? The music21.search and music21.search.segment modules have tools for making this possible. Let’s load up a piece by Palestrina to start:

from music21 import *

pal = corpus.parse('palestrina/Agnus_0')
pal.measures(0, 7).show()
../_images/usersGuide_56_searching2_1_0.png

It looks like the opening motive in the first part (let’s call it “Cantus” even though it’s unlabeled) will reoccur in the Tenor, and maybe elsewhere in the piece. Let’s divide the score up into four-note segments:

Navigation

  • index
  • modules |
  • next |
  • previous |
  • music21 »
  • Documentation and tests in progress »
  • User’s Guide, Chapter 56: Segmented and Approximate Search
© Copyright 2006-2024 Michael Scott Asato Cuthbert. Last updated on May 22, 2025.