Expand description
Finding music in streams: lyrics as text.
Finding music in streams: music21’s search package. A
StreamSearcher and the searches beside it find runs of notes by
name, rhythm or anything else; the translations turn notes into text,
which the approximate searches compare as Python’s difflib does; and a
LyricSearcher finds text in a stream’s lyrics, and the notes it is
sung to. index_score_parts cuts each part of a score into
overlapping stretches of that text, and score_similarity compares
every stretch of some scores with every other. A SegmentMatcher
finds rows and sets of pitch classes in the notes of a stream, and
labels them there.
Structs§
- Contiguous
Segment - A run of notes and chords of one part: music21’s
ContiguousSegmentOfNotes. - Contiguous
Segment Searcher - Finds every run of a stream’s notes and chords that is a segment of a
given length, part by part: music21’s
ContiguousSegmentSearcher. - Indexed
Lyric - One lyric of a stream and where its text sits in the text searched:
music21’s
IndexedLyric. Positions count characters, as Python’s do. - Lyric
Match - A stretch of lyrics a search found: music21’s
search.lyricsSearchMatch. - Lyric
Searcher - Finds text in a stream’s lyrics: music21’s
LyricSearcher. Each verse’s lyrics are read as one text, syllables of a word run together and words apart, and the verses one after another withLINE_BREAKbetween them; a search finds each place the text comes and the lyrics and notes there. - Measure
Rhythm - A rhythm the measures of a stream share, and which measures share it.
- Search
Match - A run of elements a search found: music21’s
search.baseSearchMatch. - Searched
- One element of a stream as a search meets it, with where it is: what music21’s stream iterators hand a search.
- Segment
At - Where a segment comes from in an index of scores.
- Segment
Matcher - Finds the runs of a stream’s notes and chords that are segments or
sets of pitch classes searched for: music21’s
SegmentMatcherand the matchers built on it, chosen byMatching. - Segment
Note - One note or chord of a
ContiguousSegment, and where it stands. - Segment
Similarity - How alike two segments are: one row of music21’s
scoreSimilarity. - Segments
- A part cut into stretches of its translated notes, and the measures each stretch runs from and to: one entry of music21’s score index.
- Stream
Searcher - Searches a stream for runs of elements matching a list of terms, the
terms compared by a list of algorithms: music21’s
StreamSearcher. A run matches unless an algorithm says one of its elements does not; with only the wildcard algorithm, as it starts, every run matches. - Translation
- Notes and rests as text to search, and the measure each piece of it comes from.
Enums§
- Algorithm
- How a
StreamSearchercompares an element of the stream with the search term it is lined up with: each answers that they match, that they do not, or nothing, leaving it to the next. - Filter
- Which elements of the stream a
StreamSearcherlooks at. - Lyric
Identifier - Which verse a lyric belongs to: the name a score gave it or, failing one, its number, which music21 keeps apart even where the name is a number written out.
- Matching
- How a
SegmentMatchertells a run of pitch classes the same as one searched for. - Repetitions
- How a
ContiguousSegmentSearcherreads notes that repeat a pitch class: music21’sreps. - Search
Term - One place in what is searched for: music21’s search list entry.
Constants§
- LINE_
BREAK - What music21 writes between the lyrics of one verse and the next in the
text it searches:
LINEBREAK_TOKEN.
Functions§
- approximate_
note_ search - How alike each other stream is to this one, as the text of their notes
and rests – pitch, length and tie – best first: music21’s
approximateNoteSearch. Each is the other stream’s index and its likeness, music21’smatchProbability. - approximate_
note_ search_ no_ rhythm - The same, by pitch alone: music21’s
approximateNoteSearchNoRhythm. - approximate_
note_ search_ only_ rhythm - The same, by length alone: music21’s
approximateNoteSearchOnlyRhythm. - approximate_
note_ search_ weighted - The same, three parts by pitch to one by length: music21’s
approximateNoteSearchWeighted. - index_
score_ parts - Each part of a score cut into segments, by music21’s defaults –
thirty characters a segment, twelve overlapping, pitches alone:
music21’s
indexScoreParts. - index_
score_ parts_ with - The same, cut as asked.
- iterated
- The elements of a stream itself, not of the streams it holds: music21’s
iter(). - most_
common_ measure_ rhythms - The rhythms of a stream’s measures, nested ones included, most common
first, those as common in the order first met: music21’s
mostCommonMeasureRhythms, without the copy of each first measure transposed to start on C5 that music21 keeps beside it. - note_
name_ rhythmic_ search - Where each run of elements starts whose names and lengths are those
searched for: music21’s
noteNameRhythmicSearch. - note_
name_ search - Where each run of elements starts whose names – a note’s pitch name,
rest– are those searched for, a wildcard matching any: music21’snoteNameSearch. - notes_
and_ rests - The notes, chords and rests of
recursed: music21’srecurse().notesAndRests. - recursed
- Every element of a stream, nested ones included, each before what it
holds: music21’s
recurse(). - rhythmic_
search - Where each run of elements starts whose lengths are those searched for,
a wildcard or a term of any length matching any: music21’s
rhythmicSearch. - score_
similarity - Every segment of an index of named scores at least
minimum_lengthcharacters long, compared with every such segment of each score after its own: music21’sscoreSimilarity, bydifflib. A score’s segments are not compared with each other, as music21 compares none. Withinclude_reverse, each comparison comes again with its two segments the other way round. - similarity
- How alike two stretches of text are, as music21’s approximate searches
measure it: Python’s
difflib.SequenceMatcher(None, a, b).ratio(). - translate_
diatonic_ stream_ to_ string - Notes and rests as text of their steps, a letter for each note –
AtoGwhere it is as long as the note before, seven letters on where it is longer, fourteen where it is shorter – andZfor a run of rests: music21’stranslateDiatonicStreamToString. A note tied on from the one before is left out. - translate_
duration_ to_ bytes - An element’s length as one character, ten times the base-two logarithm
of 256 times its quarter length, kept within one to 127: music21’s
translateDurationToBytes. - translate_
intervals_ and_ speed - Notes and rests as text of the intervals between them, up to thirteen
semitones either way, and whether each is as long as, shorter or longer
than the one before, a space for a run of rests: music21’s
translateIntervalsAndSpeed. The first note’s interval is from the first note. - translate_
monophonic_ part_ to_ segments - A part’s notes, written by
translate, cut into stretchessegment_lengthcharacters long, each startingsegment_length - overlapafter the one before, the last as long as what is left: music21’stranslateMonophonicPartToSegments. Each stretch’s measures are read off the translation’s measures at its first and last character, as music21 reads them, which is a note’s measure only where the translation writes one character a note, astranslate_stream_to_string_no_rhythm, music21’s default, does. - translate_
note_ tie_ to_ byte - An element’s tie as text:
sfor one starting,cfor one going on,efor one ending, and nothing otherwise: music21’stranslateNoteTieToByte. - translate_
note_ to_ byte - An element as one character: a note’s MIDI number, a chord’s first
pitch’s, and 127 for anything else – a rest, an unpitched stroke, a
chord of nothing: music21’s
translateNoteToByte. - translate_
note_ with_ duration_ to_ bytes - An element as its pitch, length and, if asked, tie characters:
music21’s
translateNoteWithDurationToBytes. - translate_
stream_ to_ string - Notes and rests as text, each its pitch, length and tie characters:
music21’s
translateStreamToString. - translate_
stream_ to_ string_ no_ rhythm - Notes and rests as text of their pitches alone: music21’s
translateStreamToStringNoRhythm. - translate_
stream_ to_ string_ only_ rhythm - Notes and rests as text of their lengths alone: music21’s
translateStreamToStringOnlyRhythm.