Introduction: Pi Digits MIDI Sonification With Visualization

This project transforms the digits of Pi into a musical composition using MIDI. Each digit is mapped to a specific note, and additional harmonies are introduced to create a rich soundscape. The project also includes a visualization of the Pi digits and their corresponding musical notes, providing an engaging way to explore the beauty of mathematics through music.

Supplies

Tools/Materials:

  1. Python programming environment
  2. Libraries: mido, matplotlib

Step 1: Step-by-Step Instructions

Step 1: Setup and Libraries

  1. Title: "Setting Up the Environment"
  2. Description:
  3. Begin by setting up your Python environment. Ensure you have Python installed, and then install the necessary libraries using pip:

pip install mido matplotlib

  1. These libraries will allow to create and manipulate MIDI files and generate visualizations.

Step 2: Generating Pi Digits

  1. Title: "Generating Pi Digits"
  2. Description:
  3. Use Python to generate the digits of Pi. We'll use the first 150 digits for this project.
  4. This code extracts the digits of Pi and stores them in a list for further processing.

Step 3: Creating the MIDI File

  1. Title: "Creating the MIDI File"
  2. Description:
  3. Create a new MIDI file and add a track for the musical notes.
  4. Set the instrument to Acoustic Grand Piano and the tempo to 120 BPM.
  5. Add metadata for better identification.

Step 4: Mapping Pi Digits to Notes

  1. Title: "Mapping Pi Digits to Musical Notes"
  2. Description:
  3. Map each digit of Pi to a MIDI note and add it to the track.
  4. This code maps each digit to a note, adds dynamic velocity, and introduces harmony every third note.

Step 5: Saving the MIDI File

  1. Title: "Saving the MIDI File"
  2. Description:
  3. Save the MIDI file to your desired location.
  4. This file can be opened with any MIDI player to listen to the sonification of `Pi`.

Step 6: Visualizing the Data

  1. Title: "Visualizing the Pi Digits and Notes"
  2. Description:
  3. Create a visualization of the Pi digits and their corresponding notes using Matplotlib.
  4. This visualization helps illustrate the relationship between the digits of Pi and the musical notes they represent.

Step 2: References

Designed with the assistance of Mistral AI, showcasing the intersection of mathematics and music through a visually appealing design.