Skip to content
milanmuzPublic

About

Post-Tonal Music Midi File Analyzer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PoToMMA

Post-Tonal Music Midi (File) Analyzer

Python script for analyzing MIDI files to determine their musical characteristics, with a special focus on identifying atonal tendencies and detecting twelve-tone rows. The script uses the music21 library for musicological analysis and mido for MIDI file manipulation. It also integrates with the Gemini API to generate a comprehensive, human-readable musicological report based on the raw analysis data.

Features

  • MIDI Analysis: Analyzes a given MIDI file for basic information such as the number of parts, total duration, note/chord counts, and key/time signatures.
  • Atonal Tendency Detection: Provides quantitative data on atonal characteristics, including:
    • Global key correlation score.
    • Evenness of pitch-class distribution.
    • Prevalence of dissonant melodic and harmonic intervals.
  • Automated Segmentation: Splits the MIDI file into logical segments based on the completion of twelve-tone aggregates (i.e., when all 12 pitch classes have appeared).
  • Twelve-Tone Row Analysis: For each segment, the script attempts to identify a "prime row" and then searches for occurrences of its 48 standard forms (Prime, Inversion, Retrograde, Retrograde-Inversion) within the music.
  • Piano Reduction: Automatically generates a piano reduction of multi-part MIDI files to create a single-part score for a more focused analysis, if needed.
  • AI-Powered Report Generation: Uses the Gemini API to synthesize all the raw analysis data into a cohesive, academic-style musicological report. The report discusses form, tonality, compositional techniques, and the extent of serial application.

Prerequisites

Before running the script, you need to install the required Python libraries and set up your Gemini API key.

  1. Install Python Libraries:
    pip install music21 mido python-dotenv google-generativeai
  2. Download and Install MuseScore: The music21 library relies on a music notation software like MuseScore to render and display musical objects. You need to have it installed and configured on your system.
    • Download MuseScore.
    • After installation, music21 should be able to find it automatically. If not, you may need to configure the path in your music21 settings.
  3. Set up Gemini API Key:
    • Obtain an API key from the Google AI Studio.
    • Create a file named config.py in the same directory as the script.
    • Add your API key to the config.py file in the following format:
    API_KEY = "YOUR_API_KEY_HERE"

Usage

  1. Run the script from the command line:
    python main.py path/to/your/midi_file.mid
  2. Input Author and Title: The script will prompt you to enter the composition's title and author, which will be included in the final report.
    Enter composition title and author's name> Arnold Schoenberg - Piano Suite, Op. 25
    
  3. Review the Output: The script will print the analysis progress and findings directly to the console. The final, comprehensive musicological report generated by Gemini will be saved to a text file in a new analysis_reports directory.

Example

Assuming your MIDI file is named schoenberg_op25.mid:

python main.py schoenberg_op25.mid

About

Post-Tonal Music Midi File Analyzer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages