#4623 Sheet Music to Knowledge Graph (#1)

#4623 Sheet Music to Knowledge Graph (#1)


#4623 Are there online libraries of sheet music?

Yes, there are several extensive online libraries for sheet music, ranging from public-domain classical repositories to community-driven user-submitted archives and digital retail sites.

Here are some of the best online libraries categorized by what they offer:

1. Public Domain & Classical Archives (Free)

  • IMSLP (Petrucci Music Library): The absolute gold standard for public domain classical music. It contains hundreds of thousands of out-of-copyright scores, parts, and historical manuscripts uploaded by a global community.

  • Musopen: A non-profit site dedicated to providing free, public domain sheet music, recordings, and educational resources. Its interface is exceptionally clean and easy to navigate by instrument, composer, or era.

  • Choral Public Domain Library (CPDL): A massive archive focused specifically on choral and vocal sheet music, including SATB scores, liturgical music, and folk arrangements.

  • Library of Congress / National Libraries: Archives like the Library of Congress (Historic American Sheet Music collection) and the Gallica archive (Bibliothèque nationale de France) host digitized original manuscripts and historical American popular music.

2. Community & Modern Transcriptions

  • MuseScore.com: A massive community platform where users share user-created arrangements, pop/rock transcriptions, video game soundtracks, and original compositions. (Note: Interfacing requires the free MuseScore software, though advanced downloads may require a subscription depending on copyright).

  • Mutopia Project: An open collection of public domain music that has been re-typeset using modern notation software, making it much easier to read than old scans.

3. Digital Retail & Official Publishers

  • Musicnotes & Sheet Music Plus: The primary commercial platforms for purchasing licensed, officially published arrangements of modern pop, rock, jazz, and movie/TV soundtracks.

  • Scribd / SlideShare: While not exclusively for music, many users upload user-made lead sheets, fake books, and songbooks here.


Are there tools to convert the sheet music to sequencer sequences?

Yes, tools that perform this process use Optical Music Recognition (OMR). OMR software scans printed sheet music or PDF scores, interprets the musical notation (pitches, rests, time signatures, and dynamics), and converts it into structured digital formats like MIDI or MusicXML. Once in MIDI or MusicXML format, the notes can be directly loaded into hardware sequencers, DAWs, or custom control pipelines.

The main categories of tools for converting sheet music to sequences break down as follows:

1. Open-Source & Local CLI/Python Engines

For local, scriptable, or offline workflows, open-source AI models process images directly into standard formats.

  • oemer (End-to-End OMR): A Python package using deep learning and computer vision to transcribe sheet music photos or scans into MusicXML/MIDI. It is optimized to handle skewed images and phone photos.

  • homr: A lightweight OMR tool that uses a two-stage UNet segmentation + Transformer model pipeline to convert camera shots of scores into MusicXML files.

  • Audiveris: An open-source, desktop-based OMR engine written in Java. It provides a visual interface to review note segmentation and bounding boxes before exporting to MusicXML or MIDI.

2. Desktop Applications & Dedicated OMR Software

For complex, multi-stave orchestral scores or precise layout control, desktop OMR applications offer editing suites to fix recognition errors before exporting.

  • PhotoScore & NotateMe Ultimate (Neuratron): The engine integrated into Avid Sibelius. It excels at reading complex polyphonic scores, hand-written manuscripts, and printed pages, exporting directly to MIDI or MusicXML.

  • SmartScore (Musitek): A dedicated score recognition suite designed for full score extraction, instrument track separation, and MIDI sequencing export.

  • PlayScore 2: An app for iOS, Android, and desktop that reads scores directly using a smartphone camera or PDF import and exports playable MIDI/MusicXML.

3. Score Editors with Built-in AI Conversion

Most modern music notation software includes automated PDF/image transcription engines.

  • MuseScore Studio: Features an integrated AI conversion pipeline (NoteVision engine) that allows you to import PDFs or images, edit the transcription in the score editor, and export as standard .mid files or MusicXML.

  • Dorico / Finale / Sibelius: While they use underlying OMR plugins (like PhotoScore), these platforms accept MusicXML imports from open-source tools to route multi-channel MIDI outputs directly to hardware or software instruments.

4. Online AI Converters

For quick, browser-based conversions without local setup:

  • Lacuna.fm / Soundslice: Web-based OMR engines that take PNG, JPG, or PDF score uploads and return downloadable Standard MIDI Files (.mid).

  • Newzik (LiveScores): Uses deep learning models trained on score datasets to convert PDFs into interactive MusicXML/MIDI tracks for immediate playback or routing.

Typical Workflow Overview

  1. Source Capture: High-contrast scan or straight-on photo of the sheet music (PNG, JPG, or PDF).

  2. OMR Processing: Run through an OMR engine (oemer, Audiveris, or PhotoScore) to generate a MusicXML or MIDI file.

  3. Quantization / Cleanup: Open the resulting file in a notation editor or DAW (e.g., MuseScore, Reaper, Ableton) to fix any minor misread accidentals or duration errors.

  4. Sequencer Routing: Load the finalized .mid file into a hardware sequencer, software DAW, or custom script stream.


Are there recognizable repeated sequences across different songs, say sequences of one stanza or less?

Yes, absolutely. In music theory and composition, these recognizable repeated short sequences (typically lasting 1 to 4 bars, or roughly a stanza/phrase line) are known as harmonic sequences, stock chord progressions, or melodic tropes.

Because Western music relies on shared tonal relationships, the exact same underlying sequence often forms the structural backbone for hundreds of different songs across centuries and genres.

Here are some of the most recognizable repeated short sequences in music history:

1. The "50s Progression" (Doo-Wop Sequence)

  • The Sequence: $I - vi - IV - V$ (or in C Major: C – Am – F – G)

  • Length: 4 bars (one standard stanza line)

  • The Sound: Nostalgic, romantic, and circular. It continuously loops back to the starting chord.

  • Where You’ve Heard It: * "Stand by Me" – Ben E. King

    • "Every Breath You Take" – The Police

    • "Earth Angel" – The Penguins

    • "Duke of Earl" – Gene Chandler

2. The Andalusian Cadence (The Descending Tetrachord)

  • The Sequence: $i - \text{VII} - \text{VI} - V$ (or in A minor: Am – G – F – E)

  • Length: 4 bars (a descending baseline phrase)

  • The Sound: Dramatic, urgent, tense, and melancholic. It relies on a step-down bassline that forces a strong tension on the final chord ($V$).

  • Where You’ve Heard It: * "Sultans of Swing" (Solo section) – Dire Straits

    • "Hit the Road Jack" – Ray Charles

    • "Good Vibrations" (Chorus) – The Beach Boys

    • "Stairway to Heaven" (Intro/Verse baseline pattern) – Led Zeppelin

3. The "4-Chord" Pop Sequence

  • The Sequence: $I - V - vi - IV$ (or in C Major: C – G – Am – F)

  • Length: 4 bars

  • The Sound: Triumphant, heroic, and instantly memorable. It is arguably the most repeated 4-bar sequence in modern mainstream music.

  • Where You’ve Heard It: * "Don't Stop Believin'" – Journey

    • "Let It Be" – The Beatles

    • "With or Without You" – U2

    • "No Woman, No Cry" – Bob Marley

4. The Circle of Fifths Sequence (Baroque / Jazz Sequence)

  • The Sequence: $ii - V - I - IV - \text{vii}^\circ - iii - vi$ (or root motion jumping down a 5th / up a 4th)

  • Length: 4 to 8 bars

  • The Sound: Inevitable, cascading, and elegant. Each chord acts as a dominant resolution to the next.

  • Where You’ve Heard It: * Classical: Vivaldi’s Winter (The Four Seasons), Handel’s Passacaglia

    • Jazz Standards: "Autumn Leaves", "Fly Me to the Moon"

    • Pop/Rock: "I Will Survive" – Gloria Gaynor, "Still Got the Blues" – Gary Moore

5. The Pachelbel Sequence (The Romanesca Variant)

  • The Sequence: $I - V - vi - iii - IV - I - IV - V$

  • Length: 8 short bars or 4 long bars

  • The Sound: Grand, ground-anchored, and resolving.

  • Where You’ve Heard It: * Canon in D – Johann Pachelbel

    • "Memories" – Maroon 5

    • "Basket Case" – Green Day

    • "Cryin'" – Aerosmith

6. The "Passamezzo Moderno" / 12-Bar Blues Loop

  • The Sequence: $I - I - I - I - IV - IV - I - I - V - IV - I - V$

  • Length: 12 bars (3 stanzas/phrases of 4 bars each)

  • The Sound: The defining foundation of American rock, blues, and jazz.

  • Where You’ve Heard It: * "Johnny B. Goode" – Chuck Berry

    • "Hound Dog" – Big Mama Thornton / Elvis Presley

    • "Pride and Joy" – Stevie Ray Vaughan

Why Do These Sequences Repeat Across History?

From a mathematical and psychoacoustic perspective, these short sequences work because they balance predictability (tension leading smoothly into resolution via step-wise motion or 5th intervals) with voice leading (moving smoothly between chords without drastic pitch leaps).

Whether in a 17th-century baroque piece or a 20-channel hardware synthesizer loop, these short sequences form the core structural building blocks of musical memory.


Describe a procedure to convert sheet music to a knowledge graph where sequences of one stanza (or less) have preceded-by and follow-by associates to other sequences, and these associations can be built up by adding new sheet music to its library

Building a knowledge graph (KG) that parses sheet music into short structural building blocks (sequences of a stanza, measure, or phrase) and links them via temporal relationship chains creates a powerful framework for musicological analysis, generative sequencing, and pattern discovery.

Below is a end-to-end procedural architecture to ingest sheet music, extract sub-phrase sequences, and construct an additive directional graph.

Architectural Overview & Data Model

To make the graph queryable and scale gracefully as new scores are ingested, we separate abstract musical patterns (canonical sequences) from concrete occurrences (instances in a specific piece/measure).

Graph Ontology Schema

  • Nodes:

    • :Piece — Metadata (Title, Composer, Key Signature, Time Signature).

    • :Sequence — A unique canonical string, vector hash, or MusicXML/MIDI snippet representing a normalized phrase or stanza.

    • :Occurrence — A specific instance of a :Sequence occurring at a specific bar/stanza index within a :Piece.

  • Edges / Relationships:

    • (:Sequence)-[:PRECEDED_BY]->(:Sequence) (or [:FOLLOWED_BY]) — Directed weighted edges indicating temporal progression between canonical patterns across the whole library.

    • (:Piece)-[:CONTAINS]->(:Occurrence) — Maps a score to its structural parts.

    • (:Occurrence)-[:INSTANCE_OF]->(:Sequence) — Connects a specific location in a score to its canonical abstract pattern.

    • (:Occurrence)-[:NEXT_IN_PIECE]->(:Occurrence) — Preserves exact sequential playback order within a specific composition.

Step-By-Step Conversion Procedure

[ Sheet Music Scan/PDF ]
           │
          ▼ (1. Optical Music Recognition)
[ Standardized Digital File (MusicXML/MIDI) ]
           │
          ▼ (2. Segmentation Strategy)
[ Phrase / Measure / Stanza Sub-Sequences ]
           │
          ▼ (3. Normalization & Pitch Transposition)
[ Canonical Key-Agnostic Sequence Hashes ]
           │
          ▼ (4. Sequential Pair Extraction)
[ Node-Edge Tuple Generation (A -> B) ]
           │
          ▼ (5. Graph Ingestion & Weight Update)
[ Updated Graph Database ]

Step 1: Ingestion & Digitization (OMR)

Convert physical scores, PDFs, or image files into machine-readable symbolic representations.

  1. Run the raw input through an OMR engine (e.g., oemer, Audiveris, or PhotoScore).

  2. Export the output to MusicXML or Standard MIDI File (.mid).

  3. Extract baseline structural metadata (e.g., key signature K, time signature T, tempo).

Step 2: Segmentation (Stanza / Phrase Boundary Extraction)

Divide the continuous symbolic stream into discrete blocks corresponding to a stanza or short phrase (typically 1 to 4 bars).

  • Option A (Fixed Structural Windows): Segment every N measures (e.g., N = 2 or N = 4 bars).

  • Option B (Musical Phrase Detection): Detect natural boundaries using breath marks, explicit double bar-lines, repeating rhythmic cadences, or rests exceeding a minimum duration.

Step 3: Sequence Normalization & Encoding

To ensure the graph recognizes when two different pieces use the same underlying sequence, sequences must be converted to key-agnostic and rhythmically standardized signatures.

  1. Relative Pitch / Interval Vector Translation:

    Convert absolute pitch numbers (e.g., MIDI values [60, 64, 67]) into relative interval progressions (e.g., [+4, +3]) or Roman Numeral Analysis progressions for harmonic tracks (e.g., I - vi - IV - V).

  2. Rhythmic Quantization:

    Standardize note durations relative to the time signature (e.g., quarter note = 1.0, eighth note = 0.5) to normalize minor tempo variations.

  3. Hashing / Canonical String Generation:

    Generate a deterministic string representation or SHA-256 hash of the normalized sequence.

    • Example String: INTERVALS:[0,4,7,12]|DURATIONS:[1.0,1.0,1.0,1.0]

Step 4: Pairwise Relationship Extraction

For a given piece segmented into an ordered array of normalized sequences [S_1, S_2, S_3, \dots, S_n]:

  1. Traverse the array sequentially.

  2. Form directional pairs representing adjacent transitions:

    • Pair 1: S_1 --> S_2

    • Pair 2: S_2 --> S_3

    • Pair i: S_i --> S_{i+1}

Step 5: Graph Ingestion & Weight Accumulation

Upsert the extracted pairs into the graph database (e.g., Neo4j or networkx).

For each pair S_i --> S_{i+1}:

  1. Merge Canonical Nodes:

    • Find or Create Node for S_i.

    • Find or Create Node for S_{i+1}.

  2. Merge Directed Relationship:

    • Create a directed edge: (S_i)-[r:FOLLOWED_BY]->(S_i+1)

    • Reverse edge: (S_i+1)-[r2:PRECEDED_BY]->(S_i)

  3. Increment Edge Weight & Track Context:

    • If the edge already exists, increment its global transition count attribute: r.weight = r.weight + 1.

    • Append the metadata (Piece_ID, Measure_Range) to the edge's occurrence log to trace provenance.

Example Ingestion Pipeline Implementation (Python Data Logic)

Below is a conceptual Python implementation illustrating how to process a sequence array and construct Cypher queries for a graph database:

import hashlib

def generate_sequence_hash(sequence_data):
    """Creates a deterministic canonical hash for a normalized phrase."""
    raw_str = f"PITCHES:{sequence_data['intervals']}|RHYTHM:{sequence_data['durations']}"
    return hashlib.sha256(raw_str.encode('utf-8')).hexdigest()[:16]

def ingest_piece_to_graph(piece_metadata, extracted_phrases, db_session):
    """
    Parses ordered phrases from a piece and commits nodes/edges to the Graph.
    """
    piece_id = piece_metadata['id']
    sequence_nodes = []

    # 1. Normalize and hash each phrase in the piece
    for idx, phrase in enumerate(extracted_phrases):
        seq_hash = generate_sequence_hash(phrase)
        sequence_nodes.append({
            'hash': seq_hash,
            'raw_data': phrase,
            'order': idx
        })

    # 2. Construct transitions and execute graph upserts
    for i in range(len(sequence_nodes) - 1):
        source = sequence_nodes[i]
        target = sequence_nodes[i+1]

        cypher_query = """
        MERGE (a:Sequence {id: $source_id})
          ON CREATE SET a.pattern = $source_pattern
        MERGE (b:Sequence {id: $target_id})
          ON CREATE SET b.pattern = $target_pattern
        
        MERGE (a)-[r:FOLLOWED_BY]->(b)
          ON CREATE SET r.weight = 1, r.occurrences = [$piece_id]
          ON MATCH SET r.weight = r.weight + 1, r.occurrences = r.occurrences + $piece_id

        MERGE (b)-[p:PRECEDED_BY]->(a)
          ON CREATE SET p.weight = 1
          ON MATCH SET p.weight = p.weight + 1
        """
        
        db_session.run(cypher_query, 
                       source_id=source['hash'], 
                       source_pattern=str(source['raw_data']),
                       target_id=target['hash'], 
                       target_pattern=str(target['raw_data']),
                       piece_id=piece_id)

Benefits of Incremental Library Growth

As new sheet music is ingested into this system over time:

  • Hub Identification: Common sequences (like the Andalusian Cadence or 50s Progression) naturally become high-degree "hub nodes" with incoming/outgoing edges from scores across different genres and historical eras.

  • Markov / Generative Traversal: By calculating edge probabilities ({weight}(S_i to S_j) / {sum {weights from } S_i}), you can perform random walks across the graph to synthesize novel, musically coherent compositions derived from your library.

  • Cross-Piece Structural Search: You can query the graph to find every piece that shares a specific 2-bar bridge transition or discover surprising thematic links between disparate composers.


From <https://gemini.google.com/app/0da16e580d135260>  Google Gemini (3.6 Flash)

Comments

Popular posts from this blog

#4297 ISS Astronaut Unable to Speak

#3679 Google Gemini 2.5 Pro: Create Python Application to View and Query Neo4j KG