From 2640d2182ad0acea6f47fd9f2837d83523922858 Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 22 May 2026 16:48:16 -1000 Subject: [PATCH 1/2] Support marimo notebook Marimo uses a custom iFrame to allow javascript to be run. So it needed a slightly different fork in road. Otherwise looks pretty good. (but they don't support "from music21 import *" so a bit hard to use for people following the tutorials...) --- .../source/testsAndInProgress/midi.ipynb | 14 ++++---- music21/common/misc.py | 19 +++++++++-- music21/converter/subConverters.py | 7 ++-- music21/ipython21/converters.py | 33 +++++++++++++++---- 4 files changed, 53 insertions(+), 20 deletions(-) diff --git a/documentation/source/testsAndInProgress/midi.ipynb b/documentation/source/testsAndInProgress/midi.ipynb index 282d7288a..6768af826 100644 --- a/documentation/source/testsAndInProgress/midi.ipynb +++ b/documentation/source/testsAndInProgress/midi.ipynb @@ -13,12 +13,12 @@ "id": "f380fcf0-4e6a-4d90-a9c6-70b4fa398eea", "metadata": {}, "source": [ - "MIDI will only play from **Trusted** notebooks." + "MIDI will only reliably play from **Trusted** notebooks." ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "id": "72e204b7-409b-48ef-b404-a310d281b54c", "metadata": {}, "outputs": [], @@ -28,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "id": "c9b77464-389f-4dba-9ac8-aef5bd85e2e1", "metadata": {}, "outputs": [], @@ -38,7 +38,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 6, "id": "e0040c55-5bab-42f8-ad1c-284ea8170647", "metadata": {}, "outputs": [ @@ -46,7 +46,7 @@ "data": { "text/html": [ "\n", - "
\n", + "
\n", "

\n", " This MIDI player only runs in trusted notebooks.\n", " In JupyterLab: File → Trust Notebook, then re-run this cell.\n", @@ -54,7 +54,7 @@ "

\n", " ''')) + ''' # def vfshow(self, s): From 14014c9b9d56e6cf54906e5f1364ab4e095dca46 Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Sun, 24 May 2026 08:56:34 -1000 Subject: [PATCH 2/2] fix typing on converter + doc was trying to see how i otherwise did imports from non-package required files and checked for Gregoio, and realized, oh, we removed that. --- music21/alpha/__init__.py | 4 ++-- music21/ipython21/converters.py | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/music21/alpha/__init__.py b/music21/alpha/__init__.py index 47fd99cbc..399df65a2 100644 --- a/music21/alpha/__init__.py +++ b/music21/alpha/__init__.py @@ -15,8 +15,8 @@ The alpha module/directory contains features that are useful for some things, but not a core part of the system. Some of these modules may require external libraries that are obscure and not part of the recommended "additional music21 -features" set. (For instance, alpha.chant requires Gregorio and LaTeX -- a daunting -requirement) +features" set. (For instance, at one point alpha.chant required +Gregorio and LaTeX -- a daunting requirement) This directory is a compromise between removing the features altogether and putting them in the main documentation. Some of these features may "graduate" diff --git a/music21/ipython21/converters.py b/music21/ipython21/converters.py index 3650e8a67..859656cf4 100644 --- a/music21/ipython21/converters.py +++ b/music21/ipython21/converters.py @@ -152,14 +152,13 @@ def displayMusic21jMIDI( raise ValueError('Cannot run displayMusic21jMIDI if not running in a supported Notebook') def displayMusic21jMIDIJupyter(htmlOutput: str) -> None: - # noinspection PyPackageRequirements - from IPython.display import display, HTML # type: ignore + from IPython.display import display, HTML display(HTML(htmlOutput)) def displayMusic21jMIDIMarimo(htmlOutput: str) -> t.Any: # noinspection PyPackageRequirements - import marimo as mo # type: ignore - return mo.iframe(htmlOutput, width='100%', height='80px') + from marimo import iframe # type: ignore # pylint: disable=import-error + return iframe(htmlOutput, width='100%', height='80px') def htmlOutputForMidi(binaryMidiData: bytes) -> str: binaryBase64 = base64.b64encode(binaryMidiData)