{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# `pretty_midi` tutorial\n", "\n", "This tutorial goes over the functionality of [pretty_midi](http://github.com/craffel/pretty_midi), a Python library for creating, manipulating, and extracting information from MIDI files. For more information, check [the docs](http://craffel.github.io/pretty-midi/)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# For Python2.6 compatibility\n", "from __future__ import print_function\n", "\n", "import pretty_midi\n", "import numpy as np\n", "# For plotting\n", "import mir_eval.display\n", "import librosa.display\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "# For putting audio in the notebook\n", "import IPython.display\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Building a MIDI file from scratch\n", "\n", "To start, we'll build a MIDI sequence from the ground up. More specifically, we'll build up a MIDI \"object\" using `pretty_midi`'s representation of MIDI (which we can optionally write out to a MIDI file later on). This representation is actually a little different than standard MIDI files (it's intended to be less ambiguous and a little easier to work with), but the two are mostly interchangeable. Relevant differences will be pointed out as we go.\n", "\n", "### The `PrettyMIDI` class\n", "\n", "The `PrettyMIDI` class is the main container in `pretty_midi`. It stores not only all of the events that constitute the piece, but also all of the timing information, meta-events (like key signature changes), and utility functions for manipulating, writing out, and inferring information about the MIDI data it contains." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Construct a PrettyMIDI object.\n", "# We'll specify that it will have a tempo of 80bpm.\n", "pm = pretty_midi.PrettyMIDI(initial_tempo=80)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The `Instrument` class\n", "\n", "One of the most important functions of the `PrettyMIDI` class is to hold a `list` of `Instrument` class instances. Each `Instrument` is able to store different events (for example, notes) which are meant to be played on a given general MIDI instrument (for example, instrument 42, \"Cello\"). The `Instrument` class also has functions for extracting useful information based solely on the events that occur on that particular instrument." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[]\n" ] } ], "source": [ "# The instruments list from our PrettyMIDI instance starts empty\n", "print(pm.instruments)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Let's add a Cello instrument, which has program number 42.\n", "# pretty_midi also keeps track of whether each instrument is a \"drum\" instrument or not\n", "# because drum/non-drum instruments share program numbers in MIDI.\n", "# You can also optionally give the instrument a name,\n", "# which corresponds to the MIDI \"instrument name\" meta-event.\n", "inst = pretty_midi.Instrument(program=42, is_drum=False, name='my cello')\n", "pm.instruments.append(inst)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Event containers\n", "\n", "`pretty_midi` has individual classes for holding MIDI events: `Note`, `PitchBend`, and `ControlChange`. These classes store information analogous to their corresponding MIDI events. The `Instrument` class has separate `list`s for each of these event types.\n", "\n", "#### Note\n", "\n", "The `Note` class represents a MIDI note, which has a pitch, a start time, and and end time. Notes have a pitch number from 0 to 127, representing the notes from C-1 to G9. In addition, notes have a velocity (volume) from 1 to 127, from quietest to loudest. The way `pretty_midi` stores notes is slightly different from standard MIDI, in the sense that in MIDI the note-on and note-off events are separate and their correspondences must be guessed from the MIDI stream. `pretty_midi` keeps the start and end times of a note coupled together, so things are less ambiguous. Furthermore, `pretty_midi` stores all times in terms of actual wall clock time from the start of the MIDI sequence, rather than in \"ticks\" (discussed further below). This is much easier to work with!" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[Note(start=0.200000, end=1.100000, pitch=60, velocity=100), Note(start=0.600000, end=1.700000, pitch=62, velocity=100), Note(start=1.000000, end=2.300000, pitch=64, velocity=100)]\n" ] } ], "source": [ "# Let's add a few notes to our instrument\n", "velocity = 100\n", "for pitch, start, end in zip([60, 62, 64], [0.2, 0.6, 1.0], [1.1, 1.7, 2.3]):\n", " inst.notes.append(pretty_midi.Note(velocity, pitch, start, end))\n", "print(inst.notes)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Pitch bends\n", "\n", "Since MIDI notes are all defined to have a specific integer pitch value, in order to represent arbitrary pitch frequencies we need to use pitch bends. A `PitchBend` class in `pretty_midi` holds a time (in seconds) and a pitch offset. The pitch offset is an integer in the range [-8192, 8191], which in General MIDI spans the range from -2 to +2 semitones. As with `Note`s, the `Instrument` class has a `list` for `PitchBend` class instances." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "# We'll just do a 1-semitone pitch ramp up\n", "n_steps = 512\n", "bend_range = 8192//2\n", "for time, pitch in zip(np.linspace(1.5, 2.3, n_steps),\n", " range(0, bend_range, bend_range//n_steps)):\n", " inst.pitch_bends.append(pretty_midi.PitchBend(pitch, time))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Control changes\n", "\n", "The `Instrument` class also holds control changes. Control changes include things like modulation, reverb, etc., which may or may not be supported by a given General MIDI synthesizer. As usual, they are stored in an `Instrument`'s `control_changes` `list`. We won't be covering them here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Putting it all together\n", "\n", "To give you a taste of what sorts of analysis you can do (which we'll cover in more detail in the next section), here are some examples using the (simple) MIDI sequence we just constructed.\n", "\n", "#### Plotting a piano roll\n", "\n", "A great way to visualize MIDI data is via a piano roll, which is a time-frequency matrix where each row is a different MIDI pitch and each column is a different slice in time. `pretty_midi` can produce piano roll matrices for each indivual instrument (via `Instrument.get_piano_roll`) or the entire `PrettyMIDI` object (summed across instruments, via `PrettyMIDI.get_piano_roll`). The spacing in time between subsequent columns of the matrix is determined by the `fs` parameter." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAfoAAAEKCAYAAAD6h5dQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAGR5JREFUeJzt3Xuw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}, "output_type": "display_data" } ], "source": [ "def plot_piano_roll(pm, start_pitch, end_pitch, fs=100):\n", " # Use librosa's specshow function for displaying the piano roll\n", " librosa.display.specshow(pm.get_piano_roll(fs)[start_pitch:end_pitch],\n", " hop_length=1, sr=fs, x_axis='time', y_axis='cqt_note',\n", " fmin=pretty_midi.note_number_to_hz(start_pitch))\n", "\n", "plt.figure(figsize=(8, 4))\n", "plot_piano_roll(pm, 56, 70)\n", "# Note the blurry section between 1.5s and 2.3s - that's the pitch bending up!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Sonification\n", "\n", "`pretty_midi` has two main ways to sonify MIDI data: the `synthesize` and `fluidsynth` functions. `synthesize` is a simple and rudimentary method which just synthesizes each note as a sine wave. `fluidsynth` uses the Fluidsynth program along with a SoundFont file (a simple one is installed alongside `pretty_midi`) to create a General MIDI synthesis. Note that you must have the Fluidsynth program installed to use the `fluidsynth` function. Both the `Instrument` and `PrettyMIDI` classes have these methods; the `PrettyMIDI` versions just sum up the syntheses for all of the contained instruments." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Synthesis frequency\n", "fs = 16000\n", "IPython.display.Audio(pm.synthesize(fs=16000), rate=16000)\n", "# Sounds like sine waves..." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "IPython.display.Audio(pm.fluidsynth(fs=16000), rate=16000)\n", "# Sounds (kind of) like a cello!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Writing it out\n", "\n", "Finally, we can easily write out what we just made to a standard MIDI file via the `write` function. `pretty_midi` puts each `Instrument` on a separate track in the MIDI file. Note that because `pretty_midi` uses a slightly different representation of MIDI data (for example, representing time as absolute seconds rather than as ticks), the information written out to the file will be slightly different. Otherwise, everything in your `PrettyMIDI` object will be included in the generated MIDI file." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "pm.write('out.mid')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Parsing a MIDI file\n", "\n", "The other intended use of `pretty_midi` is to parse MIDI files, so that they can be manipulated and analyzed. Loading in a MIDI file is simple. `pretty_midi` should be able to handle all valid MIDI files, and will raise an Exception of the MIDI data is corrupt." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "# We'll load in the example.mid file distributed with pretty_midi\n", "pm = pretty_midi.PrettyMIDI('example.mid')" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAtEAAAELCAYAAAAfhNrTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAIABJREFUeJzt3XmcU+XZ//HPNcMOkmQQRcUFXHBhEUFccC88VKtSLAWU8uBSlMeCFWVfbH/u1rZat+IutVrErbjgbl3rUiiioEUQEBUpyiyKyjZz//44SeZkJplJZnImmeH7fr3mxcl9Ts65cyc5uUmuc13mnENERERERNJXkOsOiIiIiIg0NppEi4iIiIhkSJNoEREREZEMaRItIiIiIpIhTaJFRERERDKkSbSIiIiISIYCnUSbWSczm2tmn5jZIjNbYGYHmNleZva8mX1kZh+a2T5B9kNEREREJJssqDzRZmbAP4E5zrnZ0bZeQHvgCuAq59wLZtYOqHDOfR9IR0REREREsizIb6JPBLbFJtAAzrklwEagmXPuhWjbJk2gRURERKQxCXIS3R1YlKT9AKDUzB4zs8Vmdr2ZFQbYDxERERGRrGqWo2MeC/QG1gIPAWcDd/s3MrPzgfOjN/s0YP9ERBpc+8JOf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kWI3rPyqZ10A9CVLuwzlERERERJokTaJFRERERDKU1zESiokWERERkXykmGiRFO7pVVle+twGLrkrmXuy3+T48u0rUNo7ERGpI8VEi4iIiIgEQpNoEREREZEM5XWMhGKiRURERCQfKSZaJA2nhCdx9r7NGiQXcSZ6R86JLy8uubfBjltTmfB8KQn+4lETGfBW9vI3S/piOYSHdpjGIxvz6z3TFJwQuphXym4MbP9B5lMeGL6UNgXe53mqvM713X9jyQXdGFx5QPU8/jM/Tj+Hf+OlmGgRERERkUDk9de7CucQERERkXykcI4sGRi+NGm7flZKz82HzEzaPn5Z9spL39I9+THGZVDC+r5eMzhb6e64s+eMlOuyVcI91TEy2f8zR0xi9oqCQH42lvQEHXogdeMPezg5PJFnsli6Pl/EyoUDCSXDd1Sp0rb2DY/h7M67AnDf5/9lYemdDd63/KNwDhERERGRQGgSLSIiIiKSobyOkVBMtIiIiIjkI8VEi4iIiIjEKSZaRERERCQQmkSLiIiIiGQor2MkFBMtIiIiIvlIMdEiIiKSM0OKprKlopwFpdfH2waFJ1KBY6vbxqtlN+Wwd7JjUky0iIiIiEgg8vrrXYVziIiIiEg+UjiHiIiIiEicwjlERERERAKhSbSIiIiISIbyOkZCMdEiIiIiko8UEy0iIiIiEqeYaBERERGRQOT117sK5xARERGRfKRwDhERERGROIVziIiIiIgEQpNoEREREZEM5XWMhGKiRURERCQfKSZaRERERCROMdEiIiIiIoHQJFpEREREJEOBTqLNrJOZzTWzT8xskZktMLMDzOxZMys1s6dquf9pZnZHkH0UEREREclUYDHRZmbAP4E5zrnZ0bZeQHugBdAGuMA5d2oa+1JMtIiIiIg0gPRiooOcmZ4IbItNoAGcc0tiy2Z2QoDHFhEREREJTJCT6O7Aorre2czOB87PXndERERERLIjb2MknHN3AHcAmNm3sH15jru0I9oZ+DrXndhBaexzQ+OeGxr33NC454bGPTcyGfe909koyEn0MmBolva1PJ3YFMkuM1uocc8NjX1uaNxzQ+OeGxr33NC450YQ4x5kdo6XgZbRsAwAzKynmR0b4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IiIiISIY0iRYRERERyVBeViwUEZHqzKwD8FL0ZiegHPgqevt759zROemYiMgOSCnuREQaITP7LbDJOff7XPdFRGRHpHAOEZEmwMw2Rf89wcxeNbP5ZrbKzK41s5Fm9q6ZfWBm+0a362hmj5rZv6J//XP7CEREGhdNokVEmp5ewFjgILxqjQc45/oBdwHjo9v8CbjBOXc4XsXGu3LRURGRxkox0SIiTc+/nHNfApjZJ8Dz0fYPgBOjywOAg6PlcgHam1k759ymBu2piEgjpUm0iEjTs8W3XOG7XUHleb8AONI5t7khOyYi0lQonENEZMf0PJWhHZjZoTnsi4hIo6NJtIjIjukioK+ZvW9mH+LFUIuISJqU4k5EREREJEP6JlpEREREJEOaRIuIiIiIZEiTaBERERGRDGkSLSIiIiKSIU2iRUREREQypEm0iIiIiEiGNIkWEREREcmQJtEiIiIiIhn6/747V4Zr54kkAAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "plt.figure(figsize=(12, 4))\n", "plot_piano_roll(pm, 24, 84)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "There are 12 time signature changes\n", "There are 13 instruments\n", "Instrument 3 has 888 notes\n", "Instrument 4 has 26 pitch bends\n", "Instrument 5 has 169 control changes\n" ] } ], "source": [ "# Let's look at what's in this MIDI file\n", "print('There are {} time signature changes'.format(len(pm.time_signature_changes)))\n", "print('There are {} instruments'.format(len(pm.instruments)))\n", "print('Instrument 3 has {} notes'.format(len(pm.instruments[0].notes)))\n", "print('Instrument 4 has {} pitch bends'.format(len(pm.instruments[4].pitch_bends)))\n", "print('Instrument 5 has {} control changes'.format(len(pm.instruments[5].control_changes)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### A note on timing information\n", "\n", "As discussed above, `pretty_midi` stores the time of different events in absolute seconds. This is different from MIDI, where the timing of events is determined in terms of relative \"ticks\" from the previous event. The amount of time each tick corresponds to depends on the current tempo and the file's resolution. Naturally, this is a woefully difficult way to deal with timing, which is why `pretty_midi` represents time in terms of absolute seconds. Hoever, we don't want to totally get rid of the metrical grid, so `pretty_midi` retains a mapping between times and ticks which is based on tempo change events." ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "24.271851000000005\n", "2688\n", "24.271851000000005\n" ] } ], "source": [ "# What's the start time of the 10th note on the 3rd instrument?\n", "print(pm.instruments[2].notes[10].start)\n", "# What's that in ticks?\n", "tick = pm.time_to_tick(pm.instruments[2].notes[10].start)\n", "print(tick)\n", "# Note we can also go in the opposite direction\n", "print(pm.tick_to_time(int(tick)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Modifying the MIDI data\n", "\n", "Anything we did above when creating a MIDI file can now be done to the parsed MIDI object. For example, we can add or remove notes from instruments, add or remove instruments from the MIDI sequence, or even modify the attributes of individual events." ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "# Let's shift the entire piece up by 2 semitones.\n", "for instrument in pm.instruments:\n", " # Skip drum instruments - their notes aren't pitched!\n", " if instrument.is_drum:\n", " continue\n", " for note in instrument.notes:\n", " note.pitch += 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Adjusting timing\n", "\n", "There are two ways to modify the timing of a MIDI sequence in `pretty_midi`. The first way is to directly changing the timing attributes of all of the events in the `PrettyMIDI` object (and its `Instrument`s). While simple, the issue with this approach is that the timing of these events will no longer match the metrical information in the MIDI file. The second approach is to use the `adjust_times` function, which effectively takes an original and adjusted temporal grid and correctly performs the warping - ensuring that the timing/metrical information remains correct. This can also be used for cropping out portions of the MIDI file." ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "26.699036100000004\n" ] } ], "source": [ "# Get the length of the MIDI file\n", "length = pm.get_end_time()\n", "# This will effectively slow it down to 110% of its original length\n", "pm.adjust_times([0, length], [0, length*1.1])\n", "# Let's check what time our tick from above got mapped to - should be 1.1x\n", "print(pm.tick_to_time(tick))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Analyzing the MIDI data\n", "\n", "`pretty_midi` contains extensive functionality for deriving information from a MIDI sequence. Much of this information is not readibly accessible from the MIDI file itself, so a primary goal of `pretty_midi` is to take care of all of the parsing and analysis in a correct, efficient, and easy-to-use way.\n", "\n", "#### Timing information\n", "\n", "Inferring, for example, the beat or downbeat times from a MIDI file requires keeping careful track of tempo change and time signature change events. `pretty_midi` handles this for you, and keeps them correct when you use `adjust_times`." ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAIABJREFUeJzt3Xt0nHW97/H3N0lTKBQa0lgKaVMCtUq7t9gUDOCWmyIg23JApchBtoJFRbeX7VFRd0XWYS/1eMMlW6zQDXhKC4oKmyNbFLnolpQ2yCUFKyWQklLaNA3lUmku8z1/zDPtdDozeZJmnmcmz+e1Vlbm95tnkm+erMw3v7u5OyIiIoVUxR2AiIiUNyUKEREpSolCRESKUqIQEZGilChERKQoJQoRESlKiUJERIpSohARkaKUKEREpKiauAPYF1OnTvVZs2bFHYaISEVpb2/f6u4NYa+v6EQxa9Ys1qxZE3cYIiIVxcy6RnK9up5ERKQoJQoRESlKiUJERIpSohARkaKUKEREpCglChERKUqJQkTGXHtXH9fet572rr64Q5ExUNHrKESk/LR39XHh9W30D6aorali+aWttDTVxR2W7AO1KERkTLV19tI/mCLlMDCYoq2zN+6QZB8pUYjImGptrqe2popqgwk1VbQ218cdkuwjdT2JyJhqaapj+aWttHX20tpcr26ncUCJQkTGXE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JERIpSohARkaKUKEREpCglChERKSqOo1BFKo6ZZaa4AhwKDAE9QXmHu58QS2AiEdD0WJERMrMrgVfd/dtxxyISBXU9iewjM3s1+HyymT1gZneYWaeZfcPMLgzOMXjCzI4Mrmsws9vNbHXwcWK8P4FIcUoUImPrLcDHgDcDFwFvdPfjSG///KngmmuA77n7scB5wXMiZUtjFCJja7UHe/qY2TPAPUH9E8ApweN3AkdnHQFwkJkd6LvPOxApK0oUImNrZ9bjVFY5xe6/tyqg1d1fjzIwkdFS15NI9O5hdzcUFpyzLFKulChEovfPwILgVLQnSY9piJQtTY8VEZGi1KIQEZGilChERKQoJQoRESlKiUJERIpSohARkaKUKEREpCglChERKUqJQkREivr/cvr92YlrT+QAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "# Plot the tempo changes over time\n", "# Many MIDI files won't have more than one tempo change event,\n", "# but this particular file was transcribed to somewhat closely match the original song.\n", "times, tempo_changes = pm.get_tempo_changes()\n", "plt.plot(times, tempo_changes, '.')\n", "plt.xlabel('Time')\n", "plt.ylabel('Tempo');" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAtQAAAEKCAYAAAAy8cIyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAIABJREFUeJzt3XucFPWZ7/HvA4PcmRnkfh3UxWhQNBpfGkIEgibGy+oej+tZ9ZhsXqIbL8mJyUYTIuslq4lB3WgMYm6sR4/JmnUVY4wol7gmhoVERGSNoiiCBi8zyD2MPOePrh4G6Jnp7uqq+s305/16zcuu6qp6ft1dUzzWPP38zN0FAAAAoDzdsh4AAAAA0JmRUAMAAAAxkFADAAAAMZBQAwAAADG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ADCTUAAAAQAwk1AAAAEAMJNQAAABADCTUAAAAQAwk1AAAAEAM/x/Ns00pza4uPQAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "# Get and downbeat times\n", "beats = pm.get_beats()\n", "downbeats = pm.get_downbeats()\n", "# Plot piano roll\n", "plt.figure(figsize=(12, 4))\n", "plot_piano_roll(pm, 24, 84)\n", "ymin, ymax = plt.ylim()\n", "# Plot beats as grey lines, downbeats as white lines\n", "mir_eval.display.events(beats, base=ymin, height=ymax, color='#AAAAAA')\n", "mir_eval.display.events(downbeats, base=ymin, height=ymax, color='#FFFFFF', lw=2)\n", "# Only display 20 seconds for clarity\n", "plt.xlim(25, 45);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Harmonic information\n", "\n", "Beyond metrical information, `pretty_midi` contains a few utility functions for measuring statistics about the harmonic content of the MIDI sequence. However, it's also designed so that additional analysis is easy." ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Text(0, 0.5, 'Proportion')" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvqOYd8AAAEj5JREFUeJzt3X+wZ3Vdx/Hny0WlxkCQrQxYFgU1TMRxwdLCtJQ1Ekix1rJBx9w0KfshudUM2JpKNv4oRQWHNaJsUaxpy01yXCkTtV0QtaUhlwVlmUpiSc0QXHj3x/esfbmt93P27j33+72X52PmO3vO55zPOe87fO99cc7n/EhVIUnSbB406QIkSdPPsJAkNRkWkqQmw0KS1GRYSJKaDAtJUpNhIUlqMiwkSU2GhSSp6aBJF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4BvALcCvTrSwudt7TvTBjB6ncjnwlsmWdEBmjll8uKoGuXx2Kei+z2cBb03ym8DtwNeB10y2sjl7Id2L08Z8sGv/h4Uv54CNf58DnDMNjzvy0llJUpOnoSRJTYaFJKnJsJAkNRkWkqQmw0KS1GRYSHPUPeH0zWPzr07y2kafs5KcMHhx0jwzLKS5uxt4XneHbV9nAYaFFh3DQpq7PYxee/lrMxckWZlkS5LPJflokhXdewnOAP6ge1/Bo7vPh7t3Snx8sb+LQUuXYSEdmIuAn0ty6Iz2tzN6X8SJwJ8Bf1RV1wCbgPOq6qSquolR2PxyVT0ZeDXwzgWsXerNx31IB6CqvprkT4BfAe4aW/RDwPO66cuBN83s272D4anAB8ZeJfLQ4aqV5s6wkA7c2xi9H+K9+9nvQcB/LcXHnmvp8TSUdICqajfwfkZvadvrGv7vjW0/B+x9q+LXgO/q+n0VuDnJC2D0utPudb3S1PFBgtIczXhX8vcweiz2m6rqtd07rd8LHMHoqa4vqaovJXka8B5GV1KdDdwHvIvRG9EeDGysqvUL/9NIszMsJElNnoaSJDUZFpKkJsNCktRkWEiSmgwLSVKTYSFJajIsJElNhoUkqel/ARJUCMPxrENpAAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "# Plot a pitch class distribution - sort of a proxy for key\n", "plt.bar(np.arange(12), pm.get_pitch_class_histogram());\n", "plt.xticks(np.arange(12), ['C', '', 'D', '', 'E', 'F', '', 'G', '', 'A', '', 'B'])\n", "plt.xlabel('Note')\n", "plt.ylabel('Proportion')" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "60 C-to-D transitions.\n" ] } ], "source": [ "# Let's count the number of transitions from C to D in this song\n", "n_c_to_d = 0\n", "for instrument in pm.instruments:\n", " # Drum instrument notes don't have pitches!\n", " if instrument.is_drum:\n", " continue\n", " for first_note, second_note in zip(instrument.notes[:-1], instrument.notes[1:]):\n", " n_c_to_d += (first_note.pitch % 12 == 0) and (second_note.pitch % 12 == 2)\n", "print('{} C-to-D transitions.'.format(n_c_to_d))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Utility functions\n", "\n", "Since the MIDI specification is not a terribly user-friendly format (e.g. instruments are identified by integers with no discernible order), `pretty_midi` provides various functions for converting between MIDI format and human-friendly/readable format." ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Program number 42 is Cello\n", "... and has instrument class Strings\n", "Bassoon has program number 70\n" ] } ], "source": [ "print('Program number 42 is {}'.format(pretty_midi.program_to_instrument_name(42)))\n", "print('... and has instrument class {}'.format(pretty_midi.program_to_instrument_class(42)))\n", "print('Bassoon has program number {}'.format(pretty_midi.instrument_name_to_program('Bassoon')))" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Splash Cymbal has note number 55 on drum instruments\n" ] } ], "source": [ "print('Splash Cymbal has note number {} on drum instruments'.format(\n", " pretty_midi.drum_name_to_note_number('Splash Cymbal')))" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "A pitch bend value of 1000 is 0.244 semitones\n", "To pitch bend by -1.3 semitones, use the value -5324\n" ] } ], "source": [ "print('A pitch bend value of 1000 is {:.3f} semitones'.format(\n", " pretty_midi.pitch_bend_to_semitones(1000)))\n", "print('To pitch bend by -1.3 semitones, use the value {}'.format(\n", " pretty_midi.semitones_to_pitch_bend(-1.3)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Additional resources\n", "\n", "As mentioned above, [the docs](http://craffel.github.io/pretty-midi/) cover all of the functionality in `pretty_midi`. For additional usage examples, check the [examples directory](https://github.com/craffel/pretty-midi/tree/master/examples). If you encounter an issue or have a feature request, feel free to [create an issue](https://github.com/craffel/pretty-midi/issues/new)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.6" } }, "nbformat": 4, "nbformat_minor": 2 }