Navigation

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

Previous topic

User’s Guide, Chapter 55: Advanced Meter Topics

Next topic

User’s Guide, Chapter 57: Speeding up music21

Table of Contents

  • About music21
  • User’s Guide
    • User’s Guide: Table of Contents
    • User’s Guide, Chapter 1: Installing and Getting Started with music21
    • User’s Guide, Chapter 2: Notes
    • User’s Guide, Chapter 3: Pitches, Durations, and Notes again
    • User’s Guide, Chapter 4: Lists, Streams (I) and Output
    • User’s Guide, Chapter 5: Lists of Lists, Functions, and Recursion
    • User’s Guide, Chapter 6: Streams (II): Hierarchies, Recursion, and Flattening
    • User’s Guide, Chapter 7: Chords
    • User’s Guide, Chapter 8: Installing MusicXML Readers and File Formats (1)
    • User’s Guide, Chapter 9: Chordify
    • User’s Guide, Chapter 10: Examples 1
    • User’s Guide, Chapter 11: Corpus Searching
    • User’s Guide, Chapter 12: Getting Back to Basics: The Music21Object
    • User’s Guide, Chapter 13: More Music21Object Attributes and Properties
    • User’s Guide: Chapter 14: Time Signatures and Beats
    • User’s Guide, Chapter 15: Keys and KeySignatures
    • User’s Guide, Chapter 16: TinyNotation
    • User’s Guide: Chapter 17: Derivations
    • User’s Guide: Chapter 18: Intervals
    • User’s Guide, Chapter 19: Advanced Durations (Complex and Tuplets)
    • User’s Guide, Chapter 20: Examples 2
    • User’s Guide, Chapter 21: Ordering and Sorting of Stream Elements
    • User’s Guide, Chapter 22: Graphing and plotting
    • User’s Guide, Chapter 23: Roman Numeral Analysis
    • User’s Guide, Chapter 24: Configuring Environment Settings
    • User’s Guide, Chapter 25: Post-Tonal Tools (1)
    • User’s Guide, Chapter 26: Stream Iteration and Filtering
    • User’s Guide, Chapter 27: Grace Notes
    • User’s Guide, Chapter 28: Lyric Searching
    • User’s Guide, Chapter 29: Spanners 1 (Slurs)
    • User’s Guide, Chapter 30: Examples 3
    • User’s Guide, Chapter 31: Clefs, Ties, and Beams
    • User’s Guide, Chapter 32: Articulations
    • User’s Guide, Chapter 33: Expressions and Ornaments
    • User’s Guide, Chapter 36: Clients and Weak References
    • User’s Guide, Chapter 41: Figured Bass
    • User’s Guide, Chapter 43: Searching in and Among Scores
    • User’s Guide, Chapter 44: Advanced Graphing (Axes, Plots, and Graphs)
    • User’s Guide, Chapter 46: Streams 3: Manipulation, inPlace, and deepcopy
    • User’s Guide, Chapter 53: Advanced Corpus and Metadata Searching
    • User’s Guide, Chapter 54: Extending Converter with New Formats
    • User’s Guide, Chapter 55: Advanced Meter Topics
    • User’s Guide, Chapter 56: Segmented and Approximate Search
    • User’s Guide, Chapter 57: Speeding up music21
    • User’s Guide, Chapter 58: Understanding Sites and Contexts
    • User’s Guide, Chapter 61: TimespanTrees and Verticalities
  • Module Reference
  • Installation
  • Developer Reference

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 »
  • User’s Guide »
  • User’s Guide, Chapter 56: Segmented and Approximate Search
© Copyright 2006-2022, Michael Scott Asato Cuthbert and cuthbertLab. Last updated on Sep 18, 2022.