Last active
November 11, 2022 13:24
-
-
Save mscuthbert/fe87853ddb942df9ad5c88784e44ed1d to your computer and use it in GitHub Desktop.
music21_setup.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "music21_setup.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/mscuthbert/431dee45c01598a0c11bc27823bd1c5b/music21_setup.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "7ayYu78SYWs7", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"# Set up music21 and MuseScore to use in Google Colab" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "0bh1YgqP56Gq", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"!pip install --upgrade music21" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "8r3K2_Tu7NUo", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"!add-apt-repository ppa:mscore-ubuntu/mscore-stable -y\n", | |
"!apt-get update\n", | |
"!apt-get install musescore" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "Yxxz3oEIVkeI", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"!apt-get install xvfb" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "jlUJpNN4Ve8K", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"!sh -e /etc/init.d/x11-common start" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "lToMN9CS9yac", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"import os\n", | |
"os.putenv('DISPLAY', ':99.0')" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "-O9gCut2XFvd", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"!start-stop-daemon --start --pidfile /var/run/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "CP91XD_o8nr4", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"from music21 import *\n", | |
"us = environment.UserSettings()\n", | |
"us['musescoreDirectPNGPath'] = '/usr/bin/mscore'\n", | |
"us['directoryScratch'] = '/tmp'\n", | |
"\n", | |
"# music21 is Open Source under the BSD License\n", | |
"# Copyright (c) 2006-20 Michael Scott Cuthbert and cuthbertLab\n", | |
"# Support music21 by citing it in your research:\n", | |
"# Cuthbert, Michael Scott. _music21: a Toolkit for Computer-Aided Music Research_, http://web.mit.edu/music21. 2006-20." | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "6C3G6bMAYQSz", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"# Begin music21 code here..." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "RtkrxnZAYVg7", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"n = note.Note('C#5')\n", | |
"n.show()" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "RQE81xRKZhTV", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"source": [ | |
"" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
} | |
] | |
} |
I'll still be working on it. Apparently the HTML injection from Jupyter isn't working here, and I don't know enough yet on how to debug. It is a priority.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to connect midi to google colab ?