{
  "id": "task_libraries:midi/python",
  "path": "/exapedia/python-midi-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python MIDI libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python MIDI libraries read and write MIDI files and exchange MIDI messages with instruments and software in real time. A file library edits the notes and timing stored in a file rather than the live messages that a port library sends to connected devices. These libraries let music apps and AI music models read and generate notes as data."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python MIDI libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#pygame",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F122"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F123"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F131"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F126"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F124"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#mido",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#musictwoone",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F155"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F156"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F157"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#pretty-midi",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F172"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F179"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F176"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#symusic",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F187"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F188"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F189"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#python-rtmidi",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F204"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F205"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F208"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F206"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#midiutil",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F222"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F223"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#miditoolkit",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F237"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F238"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F244"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F241"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F239"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#mido",
          "label": [
            {
              "t": "text",
              "text": "Mido"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads among the dedicated MIDI libraries in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F141"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Parses MIDI files",
            "Opens MIDI ports"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#pygame",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F122"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F132"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F133"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#mido",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F148"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#musictwoone",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F155"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F165"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F166"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#pretty-midi",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F172"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F180"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#symusic",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F187"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F197"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F198"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#python-rtmidi",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F204"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F214"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#midiutil",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F222"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F230"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F231"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#miditoolkit",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F237"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F245"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F246"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "pygame",
          "name": [
            {
              "t": "fact",
              "fact": "F122"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/pygame/pygame"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/pygame"
            },
            {
              "label": "Docs",
              "href": "https://www.pygame.org/docs/ref/midi.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F129"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F123"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F131"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F125"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F124"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://www.pygame.org/docs/ref/midi.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F122"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F138"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F139"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/mido/mido",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F138"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def _open(self, **kwargs):\n    if kwargs.get('virtual'):\n        raise ValueError('virtual ports are not supported'\n                         ' by the Pygame backend')\n    elif kwargs.get('callback'):\n        raise ValueError('callbacks are not supported'\n                         ' by the Pygame backend')\n\n    midi.init()\n\n    if self.name is None:\n        device = _get_default_device(self.is_input)\n        self.name = device['name']\n    else:\n        device = _get_named_device(self.name, self.is_input)\n\n    if device['opened']:\n        if self.is_input:\n            devtype = 'input'\n        else:\n            devtype = 'output'\n        raise OSError('{} port {!r} is already open'.format(devtype,\n                                                            self.name))\n    if self.is_input:\n        self._port = midi.Input(device['id'])\n    else:\n        self._port = midi.Output(device['id'])\n\n    self._device_type = 'Pygame/{}'.format(device['interface'])\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/mido/mido/blob/d261ee41db32717fb73dfaa14162159fb6529ef5/mido/backends/pygame.py#L71-L99",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F137"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=pygame%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F122"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import pygame.midi\npygame.midi.init()\npygame.midi.get_count()\npygame.midi.quit()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://www.pygame.org/docs/ref/midi.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "midi.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F127"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "mido",
          "name": [
            {
              "t": "fact",
              "fact": "F140"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/mido/mido"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/mido"
            },
            {
              "label": "Docs",
              "href": "https://github.com/mido/mido/blob/main/README.rst"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F11"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://github.com/mido/mido/blob/main/README.rst",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F140"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F12"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F19"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F153"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F154"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/magenta/magenta",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F153"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def run(self):\n  \"\"\"Sends message on the qpm interval until stop signal received.\"\"\"\n  sleeper = concurrency.Sleeper()\n  while True:\n    now = time.time()\n    tick_number = max(0, int((now - self._start_time) // self._period) + 1)\n    tick_time = tick_number * self._period + self._start_time\n\n    if self._stop_time is not None and self._stop_time < tick_time:\n      break\n\n    sleeper.sleep_until(tick_time)\n\n    metric_position = tick_number % len(self._messages)\n    tick_message = self._messages[metric_position]\n\n    if tick_message is None:\n      continue\n\n    tick_message.channel = self._channel\n    self._outport.send(tick_message)\n\n    if tick_message.type == 'note_on':\n      sleeper.sleep(self._duration)\n      end_tick_message = mido.Message(\n          'note_off', note=tick_message.note, channel=self._channel)\n      self._outport.send(end_tick_message)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/magenta/magenta/blob/c15687ebd1c1cc12658cd468c737d3c24c02b918/magenta/interfaces/midi/midi_hub.py#L239-L265",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F152"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20mido%20for%20live%20metronome%20scheduling%2C%20pitch-bend%20note%20conversion%20and%20generated%20music-file%20writing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F140"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import mido\nmsg = mido.Message('note_on', note=60)\nmsg.bytes()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/mido/mido/blob/main/README.rst",
                  "label": [
                    {
                      "t": "text",
                      "text": "create_midi_file.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F145"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "musictwoone",
          "name": [
            {
              "t": "fact",
              "fact": "F155"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/cuthbertLab/music21"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/music21"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/pypi/music21/10.5.2/json"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F162"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F156"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F164"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F157"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/pypi/music21/10.5.2/json",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F155"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F171"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/MusicLang/musiclang",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F170"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def _m21Parse(f, fmt=None, remove_perc=True):\n    \"\"\"\n\n    Parameters\n    ----------\n    f :\n\n    fmt :\n         (Default value = None)\n\n    Returns\n    -------\n\n    \"\"\"\n    import music21\n    s = music21.converter.parse(f, format=fmt, forceSource=True)\n    if remove_perc:\n\n        for el in s.recurse():\n            if set(el.classes).intersection(['PercussionChord', 'Unpitched']):  # or 'Piano'\n                # el.activeSite.replace(el, instrument.Violin())\n                el.activeSite.remove(el)\n\n        # perc = [\n        #     p\n        #     for p in s.parts\n        #     if list(p.recurse().getElementsByClass([\"PercussionClef\", \"PercussionChord\"]))\n        # ]\n        # s.remove(perc, recurse=True)\n    return s\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/MusicLang/musiclang/blob/6d1f4afc88cdbc7be3635862cafd980e41e77f67/musiclang/analyze/parser.py#L640-L669",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F169"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=music21%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F155"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from music21 import converter\nscore = converter.parse('example.mid', format='midi')\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://www.music21.org/music21docs/moduleReference/moduleConverter.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "moduleConverter.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F160"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "pretty-midi",
          "name": [
            {
              "t": "fact",
              "fact": "F172"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/craffel/pretty-midi"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/pretty_midi"
            },
            {
              "label": "Docs",
              "href": "https://craffel.github.io/pretty-midi/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F35"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F179"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F174"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://craffel.github.io/pretty-midi/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F172"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F36"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F37"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F38"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F42"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F43"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F186"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/spotify/basic-pitch",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F185"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def note_events_to_midi(\n    note_events_with_pitch_bends: List[Tuple[float, float, int, float, Optional[List[int]]]],\n    multiple_pitch_bends: bool = False,\n    midi_tempo: float = 120,\n) -> pretty_midi.PrettyMIDI:\n    \"\"\"Create a pretty_midi object from note events\n\n    Args:\n        note_events : list of tuples [(start_time_seconds, end_time_seconds, pitch_midi, amplitude)]\n            where amplitude is a number between 0 and 1\n        multiple_pitch_bends : If True, allow overlapping notes to have pitch bends\n            Note: this will assign each pitch to its own midi instrument, as midi does not yet\n            support per-note pitch bends\n\n    Returns:\n        pretty_midi.PrettyMIDI() object\n\n    \"\"\"\n    mid = pretty_midi.PrettyMIDI(initial_tempo=midi_tempo)\n    if not multiple_pitch_bends:\n        note_events_with_pitch_bends = drop_overlapping_pitch_bends(note_events_with_pitch_bends)\n\n    piano_program = pretty_midi.instrument_name_to_program(\"Electric Piano 1\")\n    instruments: DefaultDict[int, pretty_midi.Instrument] = defaultdict(\n        lambda: pretty_midi.Instrument(program=piano_program)\n    )\n    for start_time, end_time, note_number, amplitude, pitch_bend in note_events_with_pitch_bends:\n        instrument = instruments[note_number] if multiple_pitch_bends else instruments[0]\n        note = pretty_midi.Note(\n            velocity=int(np.round(MIDI_VELOCITY_SCALE * amplitude)),\n            pitch=note_number,\n            start=start_time,\n            end=end_time,\n        )\n        instrument.notes.append(note)\n        if not pitch_bend:\n            continue\n        pitch_bend_times = np.linspace(start_time, end_time, len(pitch_bend))\n        pitch_bend_midi_ticks = np.round(np.array(pitch_bend) * PITCH_BEND_SCALE / CONTOURS_BINS_PER_SEMITONE).astype(\n            int\n        )\n        # This supports pitch bends up to 2 semitones\n        # If we estimate pitch bends above/below 2 semitones, crop them here when adding them to the midi file\n        pitch_bend_midi_ticks[pitch_bend_midi_ticks > N_PITCH_BEND_TICKS - 1] = N_PITCH_BEND_TICKS - 1\n        pitch_bend_midi_ticks[pitch_bend_midi_ticks < -N_PITCH_BEND_TICKS] = -N_PITCH_BEND_TICKS\n        for pb_time, pb_midi in zip(pitch_bend_times, pitch_bend_midi_ticks):\n            instrument.pitch_bends.append(pretty_midi.PitchBend(pb_midi, pb_time))\n    mid.instruments.extend(instruments.values())\n\n    return mid\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/spotify/basic-pitch/blob/fa5997af0a8210982619003269994a1be25eddf3/basic_pitch/note_creation.py#L222-L271",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F184"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20pretty_midi%20for%20live%20metronome%20scheduling%2C%20pitch-bend%20note%20conversion%20and%20generated%20music-file%20writing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F172"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import pretty_midi\nmidi_data = pretty_midi.PrettyMIDI('example.mid')\nprint(midi_data.estimate_tempo())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://craffel.github.io/pretty-midi/",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F177"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "symusic",
          "name": [
            {
              "t": "fact",
              "fact": "F187"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/Yikai-Liao/symusic"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/symusic"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/Yikai-Liao/symusic/contents/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F194"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F188"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F190"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F189"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/Yikai-Liao/symusic/contents/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F187"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F203"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/Natooz/MidiTok",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F202"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def _augment_dataset_inner(\n    file_path: Path,\n    data_path: Path,\n    pitch_offsets: list[int] | None = None,\n    velocity_offsets: list[int] | None = None,\n    duration_offsets: list[int] | None = None,\n    all_offset_combinations: bool = False,\n    restrict_on_program_tessitura: bool = True,\n    velocity_range: tuple[int, int] = (1, 127),\n    duration_in_ticks: bool = False,\n    min_duration: float = 0.03125,\n    out_path: Path | str | None = None,\n    copy_original_in_new_location: bool = True,\n) -> tuple[int, int] | tuple[0, 0]:\n\n    num_augmentations, num_tracks_augmented = 0, 0\n    try:\n        score = Score(file_path)\n    except SCORE_LOADING_EXCEPTION:\n        return num_augmentations, num_tracks_augmented\n\n    augmented_scores = augment_score_multiple_offsets(\n        score,\n        pitch_offsets,\n        velocity_offsets,\n        duration_offsets,\n        all_offset_combinations,\n        restrict_on_program_tessitura,\n        velocity_range,\n        duration_in_ticks,\n        min_duration,\n    )\n    for aug_offsets, score_aug in augmented_scores:\n        if len(score_aug.tracks) == 0:\n            continue\n        suffix = \"#\" + \"_\".join(\n            [\n                f\"{t}{offset}\"\n                for t, offset in zip([\"p\", \"v\", \"d\"], aug_offsets, strict=False)\n                if offset != 0\n            ]\n        )\n        saving_path = out_path / file_path.parent.relative_to(data_path)\n        saving_path.mkdir(parents=True, exist_ok=True)\n        saving_path /= f\"{file_path.stem}{suffix}{file_path.suffix}\"\n        if file_path.suffix in MIDI_FILES_EXTENSIONS:\n            score_aug.dump_midi(saving_path)\n        else:\n            score_aug.dump_abc(saving_path)\n        num_augmentations += 1\n        num_tracks_augmented += len(score_aug.tracks)\n\n    if copy_original_in_new_location and out_path != data_path:\n        saving_path = out_path / file_path.relative_to(data_path)\n        saving_path.parent.mkdir(parents=True, exist_ok=True)\n        copy2(file_path, saving_path)\n\n    return num_augmentations, num_tracks_augmented\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/Natooz/MidiTok/blob/680b5a4ec1b2ebd2e55f229ffcfce7f4770a2411/src/miditok/data_augmentation/data_augmentation.py#L186-L243",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F201"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=symusic%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F187"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from symusic import Score\nscore = Score(\"example.mid\")         # format auto-detected\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://symusic.readthedocs.io/en/stable/quickstart.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "quickstart.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F192"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "python-rtmidi",
          "name": [
            {
              "t": "fact",
              "fact": "F204"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/SpotlightKid/python-rtmidi"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/python-rtmidi"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/SpotlightKid/python-rtmidi/contents/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F211"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F205"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F213"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F206"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/SpotlightKid/python-rtmidi/contents/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F204"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F220"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F221"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/mido/mido",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F220"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def get_devices(api=None, **kwargs):\n    devices = {}\n\n    rtapi = _get_api_id(api)\n\n    mi = rtmidi.MidiIn(rtapi=rtapi)\n    mo = rtmidi.MidiOut(rtapi=rtapi)\n    input_names = mi.get_ports()\n    output_names = mo.get_ports()\n\n    for name in input_names + output_names:\n        if name not in devices:\n            devices[name] = {\n                'name': name,\n                'is_input': name in input_names,\n                'is_output': name in output_names,\n            }\n\n    mi.delete()\n    mo.delete()\n    return list(devices.values())",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/mido/mido/blob/d261ee41db32717fb73dfaa14162159fb6529ef5/mido/backends/rtmidi.py#L51-L71",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F219"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=python-rtmidi%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F204"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import time\nimport rtmidi\nmidiout = rtmidi.MidiOut()\navailable_ports = midiout.get_ports()\nif available_ports:\n    midiout.open_port(0)\nelse:\n    midiout.open_virtual_port(\"My virtual output\")\nwith midiout:\n    note_on = [0x90, 60, 112] # channel 1, middle C, velocity 112\n    note_off = [0x80, 60, 0]\n    midiout.send_message(note_on)\n    time.sleep(0.5)\n    midiout.send_message(note_off)\n    time.sleep(0.1)\ndel midiout\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/SpotlightKid/python-rtmidi/contents/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F209"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "midiutil",
          "name": [
            {
              "t": "fact",
              "fact": "F222"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/MarkCWirt/MIDIUtil"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/MIDIUtil"
            },
            {
              "label": "Docs",
              "href": "https://midiutil.readthedocs.io/en/1.2.1/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F59"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F223"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F225"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://midiutil.readthedocs.io/en/1.2.1/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F222"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F60"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F61"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F62"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F63"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F66"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F67"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F235"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/tiagoft/audio_to_midi",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F235"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def pianoroll_to_midi(bpm: float, pianoroll: list) -> midiutil.MIDIFile():\n    \"\"\"\n    Converts an internal piano roll notation to a MIDI file\n\n    Parameters\n    ----------\n    bpm: float\n        Beats per minute for the MIDI file. If necessary, use\n        bpm = librosa.beat.tempo(y)[0] to estimate bpm.\n\n    pianoroll : list\n        A pianoroll list as estimated by states_to_pianoroll().\n\n    Returns\n    -------\n    None.\n\n    \"\"\"\n    quarter_note = 60 / bpm\n\n    onsets = np.array([p[0] for p in pianoroll])\n    offsets = np.array([p[1] for p in pianoroll])\n\n    onsets = onsets / quarter_note\n    offsets = offsets / quarter_note\n    durations = offsets - onsets\n\n    midi = midiutil.MIDIFile(1)\n    midi.addTempo(0, 0, bpm)\n\n    for i, _ in enumerate(onsets):\n        midi.addNote(\n            0, 0, int(pianoroll[i][2]), onsets[i], durations[i], 100)\n\n    return midi\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/tiagoft/audio_to_midi/blob/cc197d26ab4aea7e934fe53a80022bab535379a8/sound_to_midi/monophonic.py#L232-L266",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F234"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20MIDIUtil%20for%20live%20metronome%20scheduling%2C%20pitch-bend%20note%20conversion%20and%20generated%20music-file%20writing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F222"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from midiutil import MIDIFile\ndegrees  = [60, 62, 64, 65, 67, 69, 71, 72]  # MIDI note number\ntrack    = 0\nchannel  = 0\ntime     = 0    # In beats\nduration = 1    # In beats\ntempo    = 60   # In BPM\nvolume   = 100  # 0-127, as per the MIDI standard\nMyMIDI = MIDIFile(1)  # One track\nMyMIDI.addTempo(track, time, tempo)\nfor i, pitch in enumerate(degrees):\n    MyMIDI.addNote(track, channel, pitch, time + i, duration, volume)\nwith open(\"major-scale.mid\", \"wb\") as output_file:\n    MyMIDI.writeFile(output_file)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://github.com/MarkCWirt/MIDIUtil/blob/develop/examples/c-major-scale.py",
                  "label": [
                    {
                      "t": "text",
                      "text": "c-major-scale.py"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F227"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "miditoolkit",
          "name": [
            {
              "t": "fact",
              "fact": "F237"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/YatingMusic/miditoolkit"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/miditoolkit"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/YatingMusic/miditoolkit/contents/README.md"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F79"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F238"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F244"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F240"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F239"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/YatingMusic/miditoolkit/contents/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F237"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F80"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F81"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F82"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F83"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F84"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F85"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F250"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F251"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/YatingMusic/remi",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F250"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def write_midi(words, word2event, output_path, prompt_path=None):\n    events = word_to_event(words, word2event)\n    # get downbeat and note (no time)\n    temp_notes = []\n    temp_chords = []\n    temp_tempos = []\n    for i in range(len(events)-3):\n        if events[i].name == 'Bar' and i > 0:\n            temp_notes.append('Bar')\n            temp_chords.append('Bar')\n            temp_tempos.append('Bar')\n        elif events[i].name == 'Position' and \\\n            events[i+1].name == 'Note Velocity' and \\\n            events[i+2].name == 'Note On' and \\\n            events[i+3].name == 'Note Duration':\n            # start time and end time from position\n            position = int(events[i].value.split('/')[0]) - 1\n            # velocity\n            index = int(events[i+1].value)\n            velocity = int(DEFAULT_VELOCITY_BINS[index])\n            # pitch\n            pitch = int(events[i+2].value)\n            # duration\n            index = int(events[i+3].value)\n            duration = DEFAULT_DURATION_BINS[index]\n            # adding\n            temp_notes.append([position, velocity, pitch, duration])\n        elif events[i].name == 'Position' and events[i+1].name == 'Chord':\n            position = int(events[i].value.split('/')[0]) - 1\n            temp_chords.append([position, events[i+1].value])\n        elif events[i].name == 'Position' and \\\n            events[i+1].name == 'Tempo Class' and \\\n            events[i+2].name == 'Tempo Value':\n            position = int(events[i].value.split('/')[0]) - 1\n            if events[i+1].value == 'slow':\n                tempo = DEFAULT_TEMPO_INTERVALS[0].start + int(events[i+2].value)\n            elif events[i+1].value == 'mid':\n                tempo = DEFAULT_TEMPO_INTERVALS[1].start + int(events[i+2].value)\n            elif events[i+1].value == 'fast':\n                tempo = DEFAULT_TEMPO_INTERVALS[2].start + int(events[i+2].value)\n            temp_tempos.append([position, tempo])\n    # get specific time for notes\n    ticks_per_beat = DEFAULT_RESOLUTION\n    ticks_per_bar = DEFAULT_RESOLUTION * 4 # assume 4/4\n    notes = []\n    current_bar = 0\n    for note in temp_notes:\n        if note == 'Bar':\n            current_bar += 1\n        else:\n            position, velocity, pitch, duration = note\n            # position (start time)\n            current_bar_st = current_bar * ticks_per_bar\n            current_bar_et = (current_bar + 1) * ticks_per_bar\n            flags = np.linspace(current_bar_st, current_bar_et, DEFAULT_FRACTION, endpoint=False, dtype=int)\n            st = flags[position]\n            # duration (end time)\n            et = st + duration\n            notes.append(miditoolkit.Note(velocity, pitch, st, et))\n    # get specific time for chords\n    if len(temp_chords) > 0:\n        chords = []\n        current_bar = 0\n        for chord in temp_chords:\n            if chord == 'Bar':\n                current_bar += 1\n            else:\n                position, value = chord\n                # position (start time)\n                current_bar_st = current_bar * ticks_per_bar\n                current_bar_et = (current_bar + 1) * ticks_per_bar\n                flags = np.linspace(current_bar_st, current_bar_et, DEFAULT_FRACTION, endpoint=False, dtype=int)\n                st = flags[position]\n                chords.append([st, value])\n    # get specific time for tempos\n    tempos = []\n    current_bar = 0\n    for tempo in temp_tempos:\n        if tempo == 'Bar':\n            current_bar += 1\n        else:\n            position, value = tempo\n            # position (start time)\n            current_bar_st = current_bar * ticks_per_bar\n            current_bar_et = (current_bar + 1) * ticks_per_bar\n            flags = np.linspace(current_bar_st, current_bar_et, DEFAULT_FRACTION, endpoint=False, dtype=int)\n            st = flags[position]\n            tempos.append([int(st), value])\n    # write\n    if prompt_path:\n        midi = miditoolkit.midi.parser.MidiFile(prompt_path)\n        #\n        last_time = DEFAULT_RESOLUTION * 4 * 4\n        # note shift\n        for note in notes:\n            note.start += last_time\n            note.end += last_time\n        midi.instruments[0].notes.extend(notes)\n        # tempo changes\n        temp_tempos = []\n        for tempo in midi.tempo_changes:\n            if tempo.time < DEFAULT_RESOLUTION*4*4:\n                temp_tempos.append(tempo)\n            else:\n                break\n        for st, bpm in tempos:\n            st += last_time\n            temp_tempos.append(miditoolkit.midi.containers.TempoChange(bpm, st))\n        midi.tempo_changes = temp_tempos\n        # write chord into marker\n        if len(temp_chords) > 0:\n            for c in chords:\n                midi.markers.append(\n                    miditoolkit.midi.containers.Marker(text=c[1], time=c[0]+last_time))\n    else:\n        midi = miditoolkit.midi.parser.MidiFile()\n        midi.ticks_per_beat = DEFAULT_RESOLUTION\n        # write instrument\n        inst = miditoolkit.midi.containers.Instrument(0, is_drum=False)\n        inst.notes = notes\n        midi.instruments.append(inst)\n        # write tempo\n        tempo_changes = []\n        for st, bpm in tempos:\n            tempo_changes.append(miditoolkit.midi.containers.TempoChange(bpm, st))\n        midi.tempo_changes = tempo_changes\n        # write chord into marker\n        if len(temp_chords) > 0:\n            for c in chords:\n                midi.markers.append(\n                    miditoolkit.midi.containers.Marker(text=c[1], time=c[0]))\n    # write\n    midi.dump(output_path)\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/YatingMusic/remi/blob/6d407258fa5828600a5474354862353ef4e4e8ae/utils.py#L216-L348",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F249"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20miditoolkit%20for%20live%20metronome%20scheduling%2C%20pitch-bend%20note%20conversion%20and%20generated%20music-file%20writing&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F237"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from miditoolkit import MidiFile\nfrom miditoolkit.midi.utils import example_midi_file\npath_midi = example_midi_file()\nmidi_obj = MidiFile(path_midi)\nprint(midi_obj)\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/YatingMusic/miditoolkit/contents/README.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F242"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python MIDI library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#mido",
          "label": [
            {
              "t": "text",
              "text": "Mido"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits most work with MIDI messages, files, and device ports. "
        },
        {
          "t": "link",
          "href": "#pretty-midi",
          "label": [
            {
              "t": "text",
              "text": "pretty_midi"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits analysis of notes and instruments with times in seconds. "
        },
        {
          "t": "link",
          "href": "#musictwoone",
          "label": [
            {
              "t": "fact",
              "fact": "F155"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits music analysis that treats MIDI as a score."
        }
      ]
    },
    {
      "q": "What is Mido?",
      "a": [
        {
          "t": "link",
          "href": "#mido",
          "label": [
            {
              "t": "text",
              "text": "Mido"
            }
          ]
        },
        {
          "t": "text",
          "text": " works with MIDI messages, MIDI files, and real-time ports through selectable backends."
        }
      ]
    },
    {
      "q": "How do I read a MIDI file in Python?",
      "a": [
        {
          "t": "link",
          "href": "#mido",
          "label": [
            {
              "t": "text",
              "text": "Mido"
            }
          ]
        },
        {
          "t": "text",
          "text": " reads a MIDI file as tracks of messages with timing in ticks. "
        },
        {
          "t": "link",
          "href": "#pretty-midi",
          "label": [
            {
              "t": "text",
              "text": "pretty_midi"
            }
          ]
        },
        {
          "t": "text",
          "text": " reads the same file as instruments and notes with times in seconds."
        }
      ]
    },
    {
      "q": "How do I create a MIDI file in Python?",
      "a": [
        {
          "t": "link",
          "href": "#midiutil",
          "label": [
            {
              "t": "text",
              "text": "MIDIUtil"
            }
          ]
        },
        {
          "t": "text",
          "text": " creates multi-track MIDI files from note and tempo events in pure Python. It writes files only and does not read them or connect to live ports."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, mido",
      "display": "Mido",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, mido",
      "display": "1.4M",
      "asOf": "2026-11-16"
    },
    "F3": {
      "label": "License, mido",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, mido",
      "display": "1.3.3, Oct 2024",
      "asOf": "2024-10-25"
    },
    "F5": {
      "label": "Package release date, mido",
      "display": "Oct 2024",
      "asOf": "2024-10-25"
    },
    "F6": {
      "label": "Repository stars, mido",
      "display": "1.7K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Reads MIDI files, mido",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Writes MIDI files, mido",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Edits tempo maps, mido",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Install, mido",
      "display": "python3 -m pip install mido",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "What it does, mido",
      "display": "Reads and writes MIDI messages and files, with a shared interface for live ports and backends.",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "strengths lead, mido",
      "display": "Exposes individual MIDI messages",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths, mido",
      "display": "Reads, edits, and writes messages, including common meta events.",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths lead, mido",
      "display": "Connects live MIDI ports",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths, mido",
      "display": "Choose a backend to send and receive real-time MIDI messages.",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "limitations lead, mido",
      "display": "Timing depends on the context",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations, mido",
      "display": "File tracks use tick deltas; file iteration returns elapsed seconds.",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations lead, mido",
      "display": "Independent tracks lack shared length",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "limitations, mido",
      "display": "Asynchronous files cannot use the total playback-length property.",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "Quickstart, mido",
      "display": "#!/usr/bin/env python3\n\n# SPDX-FileCopyrightText: 2013 Ole Martin Bjorndalen <ombdalen@gmail.com>\n#\n# SPDX-License-Identifier: MIT\n\n\"\"\"\nCreate a new MIDI file with some random notes.\n\nThe file is saved to test.mid.\n\"\"\"\nimport random\nimport sys\n\nfrom mido import MAX_PITCHWHEEL, Message, MidiFile, MidiTrack\n\nnotes = [64, 64 + 7, 64 + 12]\n\noutfile = MidiFile()\n\ntrack = MidiTrack()\noutfile.tracks.append(track)\n\ntrack.append(Message('program_change', program=12))\n\ndelta = 300\nticks_per_expr = int(sys.argv[1]) if len(sys.argv) > 1 else 20\nfor i in range(4):\n    note = random.choice(notes)\n    track.append(Message('note_on', note=note, velocity=100, time=delta))\n    for j in range(delta // ticks_per_expr):\n        pitch = MAX_PITCHWHEEL * j * ticks_per_expr // delta\n        track.append(Message('pitchwheel', pitch=pitch, time=ticks_per_expr))\n    track.append(Message('note_off', note=note, velocity=100, time=0))\n\noutfile.save('test.mid')\n",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Project function, mido",
      "display": "def run(self):\n  # ...\n  sleeper = concurrency.Sleeper()\n  while True:\n    now = time.time()\n    tick_number = max(0, int((now - self._start_time) // self._period) + 1)\n    tick_time = tick_number * self._period + self._start_time\n\n    if self._stop_time is not None and self._stop_time < tick_time:\n      break\n\n    sleeper.sleep_until(tick_time)\n\n    metric_position = tick_number % len(self._messages)\n    tick_message = self._messages[metric_position]\n\n    if tick_message is None:\n      continue\n\n    tick_message.channel = self._channel\n    self._outport.send(tick_message)\n\n    if tick_message.type == 'note_on':\n      sleeper.sleep(self._duration)\n      end_tick_message = mido.Message(\n          'note_off', note=tick_message.note, channel=self._channel)\n      self._outport.send(end_tick_message)\n",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project function reference, mido",
      "display": "midi_hub.py · run()",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project repository, mido",
      "display": "magenta/magenta",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Project stars, magenta/magenta",
      "display": "19.8K",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Project push date, magenta/magenta",
      "display": "Jan 2026",
      "asOf": "2026-01-06"
    },
    "F26": {
      "label": "Library name, pretty_midi",
      "display": "pretty_midi",
      "asOf": "2026-11-17"
    },
    "F27": {
      "label": "Monthly downloads, pretty_midi",
      "display": "694.9K",
      "asOf": "2026-11-16"
    },
    "F28": {
      "label": "License, pretty_midi",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F29": {
      "label": "Package release, pretty_midi",
      "display": "0.2.11.post0, Jul 2026",
      "asOf": "2026-07-28"
    },
    "F30": {
      "label": "Package release date, pretty_midi",
      "display": "Jul 2026",
      "asOf": "2026-07-28"
    },
    "F31": {
      "label": "Repository stars, pretty_midi",
      "display": "1.1K",
      "asOf": "2026-11-17"
    },
    "F32": {
      "label": "Reads MIDI files, pretty_midi",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Writes MIDI files, pretty_midi",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "Install, pretty_midi",
      "display": "pip install pretty_midi",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "What it does, pretty_midi",
      "display": "Represents MIDI notes and instruments with second-based timing for analysis, editing, and synthesis.",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "strengths lead, pretty_midi",
      "display": "Uses seconds for note timing",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "strengths, pretty_midi",
      "display": "Edit note start and end times directly in seconds.",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "strengths lead, pretty_midi",
      "display": "Synthesizes sine-wave previews",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "strengths, pretty_midi",
      "display": "Generate a sine-wave audio array with synthesize.",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "limitations lead, pretty_midi",
      "display": "Instrument synthesis needs external packages",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "limitations, pretty_midi",
      "display": "Install FluidSynth and pyfluidsynth for instrument-based synthesis.",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "limitations lead, pretty_midi",
      "display": "Sine synthesis skips drum sounds",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "limitations, pretty_midi",
      "display": "Instrument.synthesize returns silence for drum instruments.",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "Quickstart, pretty_midi",
      "display": "import pretty_midi\n# Create a PrettyMIDI object\ncello_c_chord = pretty_midi.PrettyMIDI()\n# Create an Instrument instance for a cello instrument\ncello_program = pretty_midi.instrument_name_to_program('Cello')\ncello = pretty_midi.Instrument(program=cello_program)\n# Iterate over note names, which will be converted to note number later\nfor note_name in ['C5', 'E5', 'G5']:\n    # Retrieve the MIDI note number for this note name\n    note_number = pretty_midi.note_name_to_number(note_name)\n    # Create a Note instance for this note, starting at 0s and ending at .5s\n    note = pretty_midi.Note(velocity=100, pitch=note_number, start=0, end=.5)\n    # Add it to our cello instrument\n    cello.notes.append(note)\n# Add the cello instrument to the PrettyMIDI object\ncello_c_chord.instruments.append(cello)\n# Write out the MIDI data\ncello_c_chord.write('cello-C-chord.mid')\n",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "Project function, pretty_midi",
      "display": "def note_events_to_midi(\n    note_events_with_pitch_bends: List[Tuple[float, float, int, float, Optional[List[int]]]],\n    multiple_pitch_bends: bool = False,\n    midi_tempo: float = 120,\n) -> pretty_midi.PrettyMIDI:\n    # ...\n    mid = pretty_midi.PrettyMIDI(initial_tempo=midi_tempo)\n    if not multiple_pitch_bends:\n        note_events_with_pitch_bends = drop_overlapping_pitch_bends(note_events_with_pitch_bends)\n\n    piano_program = pretty_midi.instrument_name_to_program(\"Electric Piano 1\")\n    instruments: DefaultDict[int, pretty_midi.Instrument] = defaultdict(\n        lambda: pretty_midi.Instrument(program=piano_program)\n    )\n    for start_time, end_time, note_number, amplitude, pitch_bend in note_events_with_pitch_bends:\n        instrument = instruments[note_number] if multiple_pitch_bends else instruments[0]\n        note = pretty_midi.Note(\n            velocity=int(np.round(MIDI_VELOCITY_SCALE * amplitude)),\n            pitch=note_number,\n            start=start_time,\n            end=end_time,\n        )\n        instrument.notes.append(note)\n        if not pitch_bend:\n            continue\n        pitch_bend_times = np.linspace(start_time, end_time, len(pitch_bend))\n        pitch_bend_midi_ticks = np.round(np.array(pitch_bend) * PITCH_BEND_SCALE / CONTOURS_BINS_PER_SEMITONE).astype(\n            int\n        )\n        # This supports pitch bends up to 2 semitones\n        # If we estimate pitch bends above/below 2 semitones, crop them here when adding them to the midi file\n        pitch_bend_midi_ticks[pitch_bend_midi_ticks > N_PITCH_BEND_TICKS - 1] = N_PITCH_BEND_TICKS - 1\n        pitch_bend_midi_ticks[pitch_bend_midi_ticks < -N_PITCH_BEND_TICKS] = -N_PITCH_BEND_TICKS\n        for pb_time, pb_midi in zip(pitch_bend_times, pitch_bend_midi_ticks):\n            instrument.pitch_bends.append(pretty_midi.PitchBend(pb_midi, pb_time))\n    mid.instruments.extend(instruments.values())\n\n    return mid\n",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "Project function reference, pretty_midi",
      "display": "note_creation.py · note_events_to_midi()",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Project repository, pretty_midi",
      "display": "spotify/basic-pitch",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Project stars, spotify/basic-pitch",
      "display": "6.1K",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Project push date, spotify/basic-pitch",
      "display": "Nov 2025",
      "asOf": "2025-11-13"
    },
    "F50": {
      "label": "Library name, MIDIUtil",
      "display": "MIDIUtil",
      "asOf": "2026-11-17"
    },
    "F51": {
      "label": "Monthly downloads, MIDIUtil",
      "display": "40.1K",
      "asOf": "2026-11-16"
    },
    "F52": {
      "label": "License, MIDIUtil",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F53": {
      "label": "Package release, MIDIUtil",
      "display": "1.2.1, Mar 2018",
      "asOf": "2018-03-04"
    },
    "F54": {
      "label": "Package release date, MIDIUtil",
      "display": "Mar 2018",
      "asOf": "2018-03-04"
    },
    "F55": {
      "label": "Repository stars, MIDIUtil",
      "display": "273",
      "asOf": "2026-11-17"
    },
    "F56": {
      "label": "Writes MIDI files, MIDIUtil",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F57": {
      "label": "Edits tempo maps, MIDIUtil",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "Install, MIDIUtil",
      "display": "pip install MIDIUtil",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "What it does, MIDIUtil",
      "display": "Creates multitrack MIDI files from note, tempo, controller, and other event definitions.",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "strengths lead, MIDIUtil",
      "display": "Writes multitrack MIDI files directly",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "strengths, MIDIUtil",
      "display": "Build tracks by adding note and tempo events before writing the file.",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "strengths lead, MIDIUtil",
      "display": "Adds controller and system events",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "strengths, MIDIUtil",
      "display": "Write controller, SysEx, and registered-parameter events alongside notes.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "limitations lead, MIDIUtil",
      "display": "Ticks require an explicit mode",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "limitations, MIDIUtil",
      "display": "Set eventtime_is_ticks when passing native MIDI tick values.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "limitations lead, MIDIUtil",
      "display": "Tempo uses the dedicated track",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "limitations, MIDIUtil",
      "display": "Format-one files ignore the requested track for tempo events.",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "Quickstart, MIDIUtil",
      "display": "#!/usr/bin/env python\n\nfrom midiutil import MIDIFile\n\ndegrees  = [60, 62, 64, 65, 67, 69, 71, 72]  # MIDI note number\ntrack    = 0\nchannel  = 0\ntime     = 0    # In beats\nduration = 1    # In beats\ntempo    = 60   # In BPM\nvolume   = 100  # 0-127, as per the MIDI standard\n\nMyMIDI = MIDIFile(1)  # One track\nMyMIDI.addTempo(track, time, tempo)\n\nfor i, pitch in enumerate(degrees):\n    MyMIDI.addNote(track, channel, pitch, time + i, duration, volume)\n\nwith open(\"major-scale.mid\", \"wb\") as output_file:\n    MyMIDI.writeFile(output_file)\n",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "Library name, miditoolkit",
      "display": "Miditoolkit",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "Monthly downloads, miditoolkit",
      "display": "23.0K",
      "asOf": "2026-11-16"
    },
    "F71": {
      "label": "License, miditoolkit",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Package release, miditoolkit",
      "display": "1.0.1, Nov 2023",
      "asOf": "2023-11-23"
    },
    "F73": {
      "label": "Package release date, miditoolkit",
      "display": "Nov 2023",
      "asOf": "2023-11-23"
    },
    "F74": {
      "label": "Repository stars, miditoolkit",
      "display": "285",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Reads MIDI files, miditoolkit",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F76": {
      "label": "Writes MIDI files, miditoolkit",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F77": {
      "label": "Edits tempo maps, miditoolkit",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F78": {
      "label": "Install, miditoolkit",
      "display": "pip install miditoolkit",
      "asOf": "2026-11-17"
    },
    "F79": {
      "label": "What it does, miditoolkit",
      "display": "Edits MIDI instruments and events in native ticks and converts notes to piano-roll grids.",
      "asOf": "2026-11-17"
    },
    "F80": {
      "label": "strengths lead, miditoolkit",
      "display": "Edits notes in native ticks",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "strengths, miditoolkit",
      "display": "Work with integer MIDI timing instead of second-based note positions.",
      "asOf": "2026-11-17"
    },
    "F82": {
      "label": "strengths lead, miditoolkit",
      "display": "Produces piano-roll note grids",
      "asOf": "2026-11-17"
    },
    "F83": {
      "label": "strengths, miditoolkit",
      "display": "Convert notes to time-and-pitch grids for analysis or visualization.",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "limitations lead, miditoolkit",
      "display": "Note timing stays in ticks",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "limitations, miditoolkit",
      "display": "Convert ticks before comparing note positions with audio timestamps.",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "Quickstart, miditoolkit",
      "display": "from miditoolkit import MidiFile\nfrom miditoolkit.midi.utils import example_midi_file\n\npath_midi = example_midi_file()\nmidi_obj = MidiFile(path_midi)\n\nprint(midi_obj)\n",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "Project function, miditoolkit",
      "display": "def write_midi(words, word2event, output_path, prompt_path=None):\n    events = word_to_event(words, word2event)\n    # get downbeat and note (no time)\n    temp_notes = []\n    temp_chords = []\n    temp_tempos = []\n    for i in range(len(events)-3):\n        if events[i].name == 'Bar' and i > 0:\n            temp_notes.append('Bar')\n            temp_chords.append('Bar')\n            temp_tempos.append('Bar')\n        elif events[i].name == 'Position' and \\\n            events[i+1].name == 'Note Velocity' and \\\n            events[i+2].name == 'Note On' and \\\n            events[i+3].name == 'Note Duration':\n            # start time and end time from position\n            position = int(events[i].value.split('/')[0]) - 1\n            # velocity\n            index = int(events[i+1].value)\n            velocity = int(DEFAULT_VELOCITY_BINS[index])\n            # pitch\n            pitch = int(events[i+2].value)\n            # duration\n            index = int(events[i+3].value)\n            duration = DEFAULT_DURATION_BINS[index]\n            # adding\n            temp_notes.append([position, velocity, pitch, duration])\n        elif events[i].name == 'Position' and events[i+1].name == 'Chord':\n            position = int(events[i].value.split('/')[0]) - 1\n            temp_chords.append([position, events[i+1].value])\n        elif events[i].name == 'Position' and \\\n            events[i+1].name == 'Tempo Class' and \\\n            events[i+2].name == 'Tempo Value':\n            position = int(events[i].value.split('/')[0]) - 1\n            if events[i+1].value == 'slow':\n                tempo = DEFAULT_TEMPO_INTERVALS[0].start + int(events[i+2].value)\n            elif events[i+1].value == 'mid':\n                tempo = DEFAULT_TEMPO_INTERVALS[1].start + int(events[i+2].value)\n            elif events[i+1].value == 'fast':\n                tempo = DEFAULT_TEMPO_INTERVALS[2].start + int(events[i+2].value)\n            temp_tempos.append([position, tempo])\n    # get specific time for notes\n    ticks_per_beat = DEFAULT_RESOLUTION\n    ticks_per_bar = DEFAULT_RESOLUTION * 4 # assume 4/4\n    notes = []\n    current_bar = 0\n    for note in temp_notes:\n        if note == 'Bar':\n            current_bar += 1\n        else:\n            position, velocity, pitch, duration = note\n            # position (start time)\n            current_bar_st = current_bar * ticks_per_bar\n            current_bar_et = (current_bar + 1) * ticks_per_bar\n            flags = np.linspace(current_bar_st, current_bar_et, DEFAULT_FRACTION, endpoint=False, dtype=int)\n            st = flags[position]\n            # duration (end time)\n            et = st + duration\n            notes.append(miditoolkit.Note(velocity, pitch, st, et))\n    # get specific time for chords\n    if len(temp_chords) > 0:\n        chords = []\n        current_bar = 0\n        for chord in temp_chords:\n            if chord == 'Bar':\n                current_bar += 1\n            else:\n                position, value = chord\n                # position (start time)\n                current_bar_st = current_bar * ticks_per_bar\n                current_bar_et = (current_bar + 1) * ticks_per_bar\n                flags = np.linspace(current_bar_st, current_bar_et, DEFAULT_FRACTION, endpoint=False, dtype=int)\n                st = flags[position]\n                chords.append([st, value])\n    # get specific time for tempos\n    tempos = []\n    current_bar = 0\n    for tempo in temp_tempos:\n        if tempo == 'Bar':\n            current_bar += 1\n        else:\n            position, value = tempo\n            # position (start time)\n            current_bar_st = current_bar * ticks_per_bar\n            current_bar_et = (current_bar + 1) * ticks_per_bar\n            flags = np.linspace(current_bar_st, current_bar_et, DEFAULT_FRACTION, endpoint=False, dtype=int)\n            st = flags[position]\n            tempos.append([int(st), value])\n    # write\n    if prompt_path:\n        midi = miditoolkit.midi.parser.MidiFile(prompt_path)\n        #\n        last_time = DEFAULT_RESOLUTION * 4 * 4\n        # note shift\n        for note in notes:\n            note.start += last_time\n            note.end += last_time\n        midi.instruments[0].notes.extend(notes)\n        # tempo changes\n        temp_tempos = []\n        for tempo in midi.tempo_changes:\n            if tempo.time < DEFAULT_RESOLUTION*4*4:\n                temp_tempos.append(tempo)\n            else:\n                break\n        for st, bpm in tempos:\n            st += last_time\n            temp_tempos.append(miditoolkit.midi.containers.TempoChange(bpm, st))\n        midi.tempo_changes = temp_tempos\n        # write chord into marker\n        if len(temp_chords) > 0:\n            for c in chords:\n                midi.markers.append(\n                    miditoolkit.midi.containers.Marker(text=c[1], time=c[0]+last_time))\n    else:\n        midi = miditoolkit.midi.parser.MidiFile()\n        midi.ticks_per_beat = DEFAULT_RESOLUTION\n        # write instrument\n        inst = miditoolkit.midi.containers.Instrument(0, is_drum=False)\n        inst.notes = notes\n        midi.instruments.append(inst)\n        # write tempo\n        tempo_changes = []\n        for st, bpm in tempos:\n            tempo_changes.append(miditoolkit.midi.containers.TempoChange(bpm, st))\n        midi.tempo_changes = tempo_changes\n        # write chord into marker\n        if len(temp_chords) > 0:\n            for c in chords:\n                midi.markers.append(\n                    miditoolkit.midi.containers.Marker(text=c[1], time=c[0]))\n    # write\n    midi.dump(output_path)\n",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "Project function reference, miditoolkit",
      "display": "utils.py · write_midi()",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "Project repository, miditoolkit",
      "display": "YatingMusic/remi",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "Project stars, YatingMusic/remi",
      "display": "606",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "Project push date, YatingMusic/remi",
      "display": "Nov 2022",
      "asOf": "2022-11-15"
    },
    "F92": {
      "label": "Developer need",
      "display": "Live MIDI message routing",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "Why choose mido",
      "display": "pluggable device-port backends",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "Developer need in introduction",
      "display": "live MIDI message routing",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "Developer need",
      "display": "Aligning notes with audio",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "Why choose pretty_midi",
      "display": "second-based note start and end times",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Developer need in introduction",
      "display": "aligning notes with audio",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "When to consider miditoolkit",
      "display": "integer tick timing should stay native",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "Developer need",
      "display": "Editing symbolic music in ticks",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Why choose miditoolkit",
      "display": "native integer tick timing",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Developer need in introduction",
      "display": "editing symbolic music in ticks",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "When to consider mido",
      "display": "real-time device messaging is the main task",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "Developer need",
      "display": "Writing event-based MIDI tracks",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Why choose MIDIUtil",
      "display": "direct multitrack file construction",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Developer need in introduction",
      "display": "writing event-based MIDI tracks",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "When to consider pretty_midi",
      "display": "note editing should use absolute second-based timing",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "Page introduction",
      "display": "Python MIDI libraries let music-software developers process MIDI messages and files.",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "FAQ: Which Python MIDI library should I choose?",
      "display": "Mido provides message objects and pluggable live ports.",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "FAQ: Which Python MIDI library should I choose?",
      "display": "pretty_midi represents note start times in absolute seconds.",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "FAQ: Which Python MIDI library should I choose?",
      "display": "Miditoolkit uses native MIDI ticks.",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "FAQ: Which Python MIDI library should I choose?",
      "display": "MIDIUtil writes multitrack MIDI files.",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "FAQ: Are MIDI files the same as synthesized audio?",
      "display": "pretty_midi can synthesize loaded notes into a sine-wave audio array.",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "FAQ: Are MIDI files the same as synthesized audio?",
      "display": "Instrument-based synthesis additionally needs FluidSynth and pyfluidsynth.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: Why do Mido track times differ from file-iteration times?",
      "display": "Track messages store delta times in ticks.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: Why do Mido track times differ from file-iteration times?",
      "display": "Iterating the file yields elapsed seconds between messages.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: When should I use seconds instead of ticks for MIDI notes?",
      "display": "pretty_midi uses second-based note positions.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: When should I use seconds instead of ticks for MIDI notes?",
      "display": "Miditoolkit uses ticks and recommends pretty_midi for second-based work such as transcription.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Why does Mido reject the length of an asynchronous file?",
      "display": "Independent tracks do not have a single playback length, so accessing length raises ValueError.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Why does pretty_midi sine synthesis produce silent drums?",
      "display": "Instrument.synthesize returns zeros for drum instruments.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: How do I pass MIDI ticks to MIDIUtil?",
      "display": "Enable eventtime_is_ticks on MIDIFile; note timing defaults to quarter notes.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "FAQ: Why does MIDIUtil ignore the chosen track for a tempo change?",
      "display": "In synchronous multitrack files, tempo events are written to the dedicated tempo track.",
      "asOf": "2026-11-17"
    },
    "F122": {
      "label": "Library name, pygame",
      "display": "pygame",
      "asOf": "2026-11-20"
    },
    "F123": {
      "label": "Monthly downloads, pygame",
      "display": "2.7M",
      "asOf": "2026-11-20"
    },
    "F124": {
      "label": "License, pygame",
      "display": "GNU Library or Lesser General Public License (LGPL)",
      "asOf": "2026-11-20"
    },
    "F125": {
      "label": "Package release, pygame",
      "display": "2.6.1",
      "asOf": "2026-11-20"
    },
    "F126": {
      "label": "Package release date, pygame",
      "display": "Sep 2024",
      "asOf": "2026-11-20"
    },
    "F127": {
      "label": "Install, pygame",
      "display": "python3 -m pip install pygame",
      "asOf": "2026-11-20"
    },
    "F128": {
      "label": "Quickstart, pygame",
      "display": "import pygame.midi\npygame.midi.init()\npygame.midi.get_count()\npygame.midi.quit()\n",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "Official description, pygame",
      "display": "Supports game development in Python.",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "Quickstart source file, pygame",
      "display": "midi.html",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Repository stars, pygame",
      "display": "9.0K",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Parses MIDI files, pygame",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Opens MIDI ports, pygame",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "MIDI task and representation, pygame",
      "display": "A Pygame/PortMidi integration for real and virtual MIDI devices, including conversion into the Pygame event loop; not a MIDI-file parser in this submodule.",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Download scope, pygame",
      "display": "Entire pygame package, not MIDI-submodule installs or users.",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Project function, pygame",
      "display": "def _open(self, **kwargs):\n    if kwargs.get('virtual'):\n        raise ValueError('virtual ports are not supported'\n                         ' by the Pygame backend')\n    elif kwargs.get('callback'):\n        raise ValueError('callbacks are not supported'\n                         ' by the Pygame backend')\n\n    midi.init()\n\n    if self.name is None:\n        device = _get_default_device(self.is_input)\n        self.name = device['name']\n    else:\n        device = _get_named_device(self.name, self.is_input)\n\n    if device['opened']:\n        if self.is_input:\n            devtype = 'input'\n        else:\n            devtype = 'output'\n        raise OSError('{} port {!r} is already open'.format(devtype,\n                                                            self.name))\n    if self.is_input:\n        self._port = midi.Input(device['id'])\n    else:\n        self._port = midi.Output(device['id'])\n\n    self._device_type = 'Pygame/{}'.format(device['interface'])\n",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Project source file, pygame",
      "display": "mido/backends/pygame.py",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Project full_name, pygame",
      "display": "mido/mido",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Project stargazers_count, pygame",
      "display": "1.7K",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Library name, mido",
      "display": "Mido",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Monthly downloads, mido",
      "display": "1.4M",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "License, mido",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Package release, mido",
      "display": "1.3.3",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Package release date, mido",
      "display": "Oct 2024",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Install, mido",
      "display": "python3 -m pip install mido",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "Quickstart, mido",
      "display": "import mido\nmsg = mido.Message('note_on', note=60)\nmsg.bytes()\n",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Repository stars, mido",
      "display": "1.7K",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Parses MIDI files, mido",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Opens MIDI ports, mido",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "MIDI task and representation, mido",
      "display": "Message-level MIDI file and realtime port APIs with selectable backends; useful when messages/meta events and device I/O both matter.",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Project function, mido",
      "display": "def run(self):\n  \"\"\"Sends message on the qpm interval until stop signal received.\"\"\"\n  sleeper = concurrency.Sleeper()\n  while True:\n    now = time.time()\n    tick_number = max(0, int((now - self._start_time) // self._period) + 1)\n    tick_time = tick_number * self._period + self._start_time\n\n    if self._stop_time is not None and self._stop_time < tick_time:\n      break\n\n    sleeper.sleep_until(tick_time)\n\n    metric_position = tick_number % len(self._messages)\n    tick_message = self._messages[metric_position]\n\n    if tick_message is None:\n      continue\n\n    tick_message.channel = self._channel\n    self._outport.send(tick_message)\n\n    if tick_message.type == 'note_on':\n      sleeper.sleep(self._duration)\n      end_tick_message = mido.Message(\n          'note_off', note=tick_message.note, channel=self._channel)\n      self._outport.send(end_tick_message)\n",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Project source file, mido",
      "display": "magenta/interfaces/midi/midi_hub.py",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "Project full_name, mido",
      "display": "magenta/magenta",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Project stargazers_count, mido",
      "display": "19.8K",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Library name, music21",
      "display": "music21",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Monthly downloads, music21",
      "display": "950.0K",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "License, music21",
      "display": "BSD",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Package release, music21",
      "display": "10.5.2",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Package release date, music21",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Install, music21",
      "display": "python3 -m pip install music21",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Quickstart, music21",
      "display": "from music21 import converter\nscore = converter.parse('example.mid', format='midi')\n",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Official description, music21",
      "display": "Analyzes music with tools for computational musicology.",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Quickstart source file, music21",
      "display": "moduleConverter.html",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Repository stars, music21",
      "display": "2.6K",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "Parses MIDI files, music21",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Opens MIDI ports, music21",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "MIDI task and representation, music21",
      "display": "Symbolic music/score analysis with MIDI parsing into Streams and structured nested musical objects, beyond MIDI transport.",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "Project function, music21",
      "display": "def _m21Parse(f, fmt=None, remove_perc=True):\n    \"\"\"\n\n    Parameters\n    ----------\n    f :\n\n    fmt :\n         (Default value = None)\n\n    Returns\n    -------\n\n    \"\"\"\n    import music21\n    s = music21.converter.parse(f, format=fmt, forceSource=True)\n    if remove_perc:\n\n        for el in s.recurse():\n            if set(el.classes).intersection(['PercussionChord', 'Unpitched']):  # or 'Piano'\n                # el.activeSite.replace(el, instrument.Violin())\n                el.activeSite.remove(el)\n\n        # perc = [\n        #     p\n        #     for p in s.parts\n        #     if list(p.recurse().getElementsByClass([\"PercussionClef\", \"PercussionChord\"]))\n        # ]\n        # s.remove(perc, recurse=True)\n    return s\n",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Project source file, music21",
      "display": "musiclang/analyze/parser.py",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Project full_name, music21",
      "display": "MusicLang/musiclang",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Project stargazers_count, music21",
      "display": "207",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Library name, pretty_midi",
      "display": "pretty_midi",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Monthly downloads, pretty_midi",
      "display": "692.7K",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "License, pretty_midi",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Package release, pretty_midi",
      "display": "0.2.11.post0",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "Package release date, pretty_midi",
      "display": "Jul 2026",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Install, pretty_midi",
      "display": "python3 -m pip install pretty_midi",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Quickstart, pretty_midi",
      "display": "import pretty_midi\nmidi_data = pretty_midi.PrettyMIDI('example.mid')\nprint(midi_data.estimate_tempo())\n",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Repository stars, pretty_midi",
      "display": "1.0K",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Parses MIDI files, pretty_midi",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Opens MIDI ports, pretty_midi",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "MIDI task and representation, pretty_midi",
      "display": "High-level MIDI note/instrument/pitch-bend objects and analysis helpers with time represented in seconds.",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Project function, pretty_midi",
      "display": "def note_events_to_midi(\n    note_events_with_pitch_bends: List[Tuple[float, float, int, float, Optional[List[int]]]],\n    multiple_pitch_bends: bool = False,\n    midi_tempo: float = 120,\n) -> pretty_midi.PrettyMIDI:\n    \"\"\"Create a pretty_midi object from note events\n\n    Args:\n        note_events : list of tuples [(start_time_seconds, end_time_seconds, pitch_midi, amplitude)]\n            where amplitude is a number between 0 and 1\n        multiple_pitch_bends : If True, allow overlapping notes to have pitch bends\n            Note: this will assign each pitch to its own midi instrument, as midi does not yet\n            support per-note pitch bends\n\n    Returns:\n        pretty_midi.PrettyMIDI() object\n\n    \"\"\"\n    mid = pretty_midi.PrettyMIDI(initial_tempo=midi_tempo)\n    if not multiple_pitch_bends:\n        note_events_with_pitch_bends = drop_overlapping_pitch_bends(note_events_with_pitch_bends)\n\n    piano_program = pretty_midi.instrument_name_to_program(\"Electric Piano 1\")\n    instruments: DefaultDict[int, pretty_midi.Instrument] = defaultdict(\n        lambda: pretty_midi.Instrument(program=piano_program)\n    )\n    for start_time, end_time, note_number, amplitude, pitch_bend in note_events_with_pitch_bends:\n        instrument = instruments[note_number] if multiple_pitch_bends else instruments[0]\n        note = pretty_midi.Note(\n            velocity=int(np.round(MIDI_VELOCITY_SCALE * amplitude)),\n            pitch=note_number,\n            start=start_time,\n            end=end_time,\n        )\n        instrument.notes.append(note)\n        if not pitch_bend:\n            continue\n        pitch_bend_times = np.linspace(start_time, end_time, len(pitch_bend))\n        pitch_bend_midi_ticks = np.round(np.array(pitch_bend) * PITCH_BEND_SCALE / CONTOURS_BINS_PER_SEMITONE).astype(\n            int\n        )\n        # This supports pitch bends up to 2 semitones\n        # If we estimate pitch bends above/below 2 semitones, crop them here when adding them to the midi file\n        pitch_bend_midi_ticks[pitch_bend_midi_ticks > N_PITCH_BEND_TICKS - 1] = N_PITCH_BEND_TICKS - 1\n        pitch_bend_midi_ticks[pitch_bend_midi_ticks < -N_PITCH_BEND_TICKS] = -N_PITCH_BEND_TICKS\n        for pb_time, pb_midi in zip(pitch_bend_times, pitch_bend_midi_ticks):\n            instrument.pitch_bends.append(pretty_midi.PitchBend(pb_midi, pb_time))\n    mid.instruments.extend(instruments.values())\n\n    return mid\n",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Project source file, pretty_midi",
      "display": "basic_pitch/note_creation.py",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "Project full_name, pretty_midi",
      "display": "spotify/basic-pitch",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Project stargazers_count, pretty_midi",
      "display": "6.1K",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Library name, symusic",
      "display": "Symusic",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Monthly downloads, symusic",
      "display": "461.4K",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "License, symusic",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Package release, symusic",
      "display": "0.6.0",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Package release date, symusic",
      "display": "Apr 2026",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Install, symusic",
      "display": "python3 -m pip install symusic",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Quickstart, symusic",
      "display": "from symusic import Score\nscore = Score(\"example.mid\")         # format auto-detected\n",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Official description, symusic",
      "display": "Parses MIDI files through a high-performance interface.",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Quickstart source file, symusic",
      "display": "quickstart.html",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Repository stars, symusic",
      "display": "190",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Parses MIDI files, symusic",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Opens MIDI ports, symusic",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "MIDI task and representation, symusic",
      "display": "C++20-backed note-level symbolic score toolkit with Python bindings, MIDI/ABC file I/O, and tick/quarter/second transformations; no measured performance ratio repeated.",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Project function, symusic",
      "display": "def _augment_dataset_inner(\n    file_path: Path,\n    data_path: Path,\n    pitch_offsets: list[int] | None = None,\n    velocity_offsets: list[int] | None = None,\n    duration_offsets: list[int] | None = None,\n    all_offset_combinations: bool = False,\n    restrict_on_program_tessitura: bool = True,\n    velocity_range: tuple[int, int] = (1, 127),\n    duration_in_ticks: bool = False,\n    min_duration: float = 0.03125,\n    out_path: Path | str | None = None,\n    copy_original_in_new_location: bool = True,\n) -> tuple[int, int] | tuple[0, 0]:\n\n    num_augmentations, num_tracks_augmented = 0, 0\n    try:\n        score = Score(file_path)\n    except SCORE_LOADING_EXCEPTION:\n        return num_augmentations, num_tracks_augmented\n\n    augmented_scores = augment_score_multiple_offsets(\n        score,\n        pitch_offsets,\n        velocity_offsets,\n        duration_offsets,\n        all_offset_combinations,\n        restrict_on_program_tessitura,\n        velocity_range,\n        duration_in_ticks,\n        min_duration,\n    )\n    for aug_offsets, score_aug in augmented_scores:\n        if len(score_aug.tracks) == 0:\n            continue\n        suffix = \"#\" + \"_\".join(\n            [\n                f\"{t}{offset}\"\n                for t, offset in zip([\"p\", \"v\", \"d\"], aug_offsets, strict=False)\n                if offset != 0\n            ]\n        )\n        saving_path = out_path / file_path.parent.relative_to(data_path)\n        saving_path.mkdir(parents=True, exist_ok=True)\n        saving_path /= f\"{file_path.stem}{suffix}{file_path.suffix}\"\n        if file_path.suffix in MIDI_FILES_EXTENSIONS:\n            score_aug.dump_midi(saving_path)\n        else:\n            score_aug.dump_abc(saving_path)\n        num_augmentations += 1\n        num_tracks_augmented += len(score_aug.tracks)\n\n    if copy_original_in_new_location and out_path != data_path:\n        saving_path = out_path / file_path.relative_to(data_path)\n        saving_path.parent.mkdir(parents=True, exist_ok=True)\n        copy2(file_path, saving_path)\n\n    return num_augmentations, num_tracks_augmented\n",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Project source file, symusic",
      "display": "src/miditok/data_augmentation/data_augmentation.py",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "Project full_name, symusic",
      "display": "Natooz/MidiTok",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Project stargazers_count, symusic",
      "display": "908",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Library name, python-rtmidi",
      "display": "python-rtmidi",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Monthly downloads, python-rtmidi",
      "display": "203.0K",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "License, python-rtmidi",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Package release, python-rtmidi",
      "display": "1.5.8",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Package release date, python-rtmidi",
      "display": "Nov 2023",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Install, python-rtmidi",
      "display": "python3 -m pip install python-rtmidi",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Quickstart, python-rtmidi",
      "display": "import time\nimport rtmidi\nmidiout = rtmidi.MidiOut()\navailable_ports = midiout.get_ports()\nif available_ports:\n    midiout.open_port(0)\nelse:\n    midiout.open_virtual_port(\"My virtual output\")\nwith midiout:\n    note_on = [0x90, 60, 112] # channel 1, middle C, velocity 112\n    note_off = [0x80, 60, 0]\n    midiout.send_message(note_on)\n    time.sleep(0.5)\n    midiout.send_message(note_off)\n    time.sleep(0.1)\ndel midiout\n",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Official description, python-rtmidi",
      "display": "Binds the RtMidi C++ library to Python with Cython.",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Quickstart source file, python-rtmidi",
      "display": "README.md",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Repository stars, python-rtmidi",
      "display": "417",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Parses MIDI files, python-rtmidi",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Opens MIDI ports, python-rtmidi",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "MIDI task and representation, python-rtmidi",
      "display": "Thin Cython binding to RtMidi for real-time device ports, callbacks, and raw MIDI messages; file parsing belongs to another layer.",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Backend platform scope, python-rtmidi",
      "display": "RtMidi platform API availability differs; virtual ports are not supported by the Windows MultiMedia backend.",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Project function, python-rtmidi",
      "display": "def get_devices(api=None, **kwargs):\n    devices = {}\n\n    rtapi = _get_api_id(api)\n\n    mi = rtmidi.MidiIn(rtapi=rtapi)\n    mo = rtmidi.MidiOut(rtapi=rtapi)\n    input_names = mi.get_ports()\n    output_names = mo.get_ports()\n\n    for name in input_names + output_names:\n        if name not in devices:\n            devices[name] = {\n                'name': name,\n                'is_input': name in input_names,\n                'is_output': name in output_names,\n            }\n\n    mi.delete()\n    mo.delete()\n    return list(devices.values())",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Project source file, python-rtmidi",
      "display": "mido/backends/rtmidi.py",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Project full_name, python-rtmidi",
      "display": "mido/mido",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Project stargazers_count, python-rtmidi",
      "display": "1.7K",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Library name, MIDIUtil",
      "display": "MIDIUtil",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Monthly downloads, MIDIUtil",
      "display": "41.3K",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "License, MIDIUtil",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Package release, MIDIUtil",
      "display": "1.2.1",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Package release date, MIDIUtil",
      "display": "Mar 2018",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "Install, MIDIUtil",
      "display": "python3 -m pip install MIDIUtil",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Quickstart, MIDIUtil",
      "display": "from midiutil import MIDIFile\ndegrees  = [60, 62, 64, 65, 67, 69, 71, 72]  # MIDI note number\ntrack    = 0\nchannel  = 0\ntime     = 0    # In beats\nduration = 1    # In beats\ntempo    = 60   # In BPM\nvolume   = 100  # 0-127, as per the MIDI standard\nMyMIDI = MIDIFile(1)  # One track\nMyMIDI.addTempo(track, time, tempo)\nfor i, pitch in enumerate(degrees):\n    MyMIDI.addNote(track, channel, pitch, time + i, duration, volume)\nwith open(\"major-scale.mid\", \"wb\") as output_file:\n    MyMIDI.writeFile(output_file)\n",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "Repository stars, MIDIUtil",
      "display": "273",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Parses MIDI files, MIDIUtil",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Opens MIDI ports, MIDIUtil",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "MIDI task and representation, MIDIUtil",
      "display": "Pure-Python multi-track MIDI file creation from note/tempo events, with beat-based time by default; not a file reader or live-port API.",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Project function, MIDIUtil",
      "display": "def pianoroll_to_midi(bpm: float, pianoroll: list) -> midiutil.MIDIFile():\n    \"\"\"\n    Converts an internal piano roll notation to a MIDI file\n\n    Parameters\n    ----------\n    bpm: float\n        Beats per minute for the MIDI file. If necessary, use\n        bpm = librosa.beat.tempo(y)[0] to estimate bpm.\n\n    pianoroll : list\n        A pianoroll list as estimated by states_to_pianoroll().\n\n    Returns\n    -------\n    None.\n\n    \"\"\"\n    quarter_note = 60 / bpm\n\n    onsets = np.array([p[0] for p in pianoroll])\n    offsets = np.array([p[1] for p in pianoroll])\n\n    onsets = onsets / quarter_note\n    offsets = offsets / quarter_note\n    durations = offsets - onsets\n\n    midi = midiutil.MIDIFile(1)\n    midi.addTempo(0, 0, bpm)\n\n    for i, _ in enumerate(onsets):\n        midi.addNote(\n            0, 0, int(pianoroll[i][2]), onsets[i], durations[i], 100)\n\n    return midi\n",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Project source file, MIDIUtil",
      "display": "sound_to_midi/monophonic.py",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "Project full_name, MIDIUtil",
      "display": "tiagoft/audio_to_midi",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Project stargazers_count, MIDIUtil",
      "display": "113",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Library name, miditoolkit",
      "display": "Miditoolkit",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Monthly downloads, miditoolkit",
      "display": "23.6K",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "License, miditoolkit",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "Package release, miditoolkit",
      "display": "1.0.1",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Package release date, miditoolkit",
      "display": "Nov 2023",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Install, miditoolkit",
      "display": "python3 -m pip install miditoolkit",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Quickstart, miditoolkit",
      "display": "from miditoolkit import MidiFile\nfrom miditoolkit.midi.utils import example_midi_file\npath_midi = example_midi_file()\nmidi_obj = MidiFile(path_midi)\nprint(midi_obj)\n",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Repository stars, miditoolkit",
      "display": "285",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "Parses MIDI files, miditoolkit",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "Opens MIDI ports, miditoolkit",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F247": {
      "label": "MIDI task and representation, miditoolkit",
      "display": "Mido-backed MIDI file processing with note/instrument/tempo/marker objects whose timing is ticks.",
      "asOf": "2026-11-20"
    },
    "F248": {
      "label": "Project function, miditoolkit",
      "display": "def write_midi(words, word2event, output_path, prompt_path=None):\n    events = word_to_event(words, word2event)\n    # get downbeat and note (no time)\n    temp_notes = []\n    temp_chords = []\n    temp_tempos = []\n    for i in range(len(events)-3):\n        if events[i].name == 'Bar' and i > 0:\n            temp_notes.append('Bar')\n            temp_chords.append('Bar')\n            temp_tempos.append('Bar')\n        elif events[i].name == 'Position' and \\\n            events[i+1].name == 'Note Velocity' and \\\n            events[i+2].name == 'Note On' and \\\n            events[i+3].name == 'Note Duration':\n            # start time and end time from position\n            position = int(events[i].value.split('/')[0]) - 1\n            # velocity\n            index = int(events[i+1].value)\n            velocity = int(DEFAULT_VELOCITY_BINS[index])\n            # pitch\n            pitch = int(events[i+2].value)\n            # duration\n            index = int(events[i+3].value)\n            duration = DEFAULT_DURATION_BINS[index]\n            # adding\n            temp_notes.append([position, velocity, pitch, duration])\n        elif events[i].name == 'Position' and events[i+1].name == 'Chord':\n            position = int(events[i].value.split('/')[0]) - 1\n            temp_chords.append([position, events[i+1].value])\n        elif events[i].name == 'Position' and \\\n            events[i+1].name == 'Tempo Class' and \\\n            events[i+2].name == 'Tempo Value':\n            position = int(events[i].value.split('/')[0]) - 1\n            if events[i+1].value == 'slow':\n                tempo = DEFAULT_TEMPO_INTERVALS[0].start + int(events[i+2].value)\n            elif events[i+1].value == 'mid':\n                tempo = DEFAULT_TEMPO_INTERVALS[1].start + int(events[i+2].value)\n            elif events[i+1].value == 'fast':\n                tempo = DEFAULT_TEMPO_INTERVALS[2].start + int(events[i+2].value)\n            temp_tempos.append([position, tempo])\n    # get specific time for notes\n    ticks_per_beat = DEFAULT_RESOLUTION\n    ticks_per_bar = DEFAULT_RESOLUTION * 4 # assume 4/4\n    notes = []\n    current_bar = 0\n    for note in temp_notes:\n        if note == 'Bar':\n            current_bar += 1\n        else:\n            position, velocity, pitch, duration = note\n            # position (start time)\n            current_bar_st = current_bar * ticks_per_bar\n            current_bar_et = (current_bar + 1) * ticks_per_bar\n            flags = np.linspace(current_bar_st, current_bar_et, DEFAULT_FRACTION, endpoint=False, dtype=int)\n            st = flags[position]\n            # duration (end time)\n            et = st + duration\n            notes.append(miditoolkit.Note(velocity, pitch, st, et))\n    # get specific time for chords\n    if len(temp_chords) > 0:\n        chords = []\n        current_bar = 0\n        for chord in temp_chords:\n            if chord == 'Bar':\n                current_bar += 1\n            else:\n                position, value = chord\n                # position (start time)\n                current_bar_st = current_bar * ticks_per_bar\n                current_bar_et = (current_bar + 1) * ticks_per_bar\n                flags = np.linspace(current_bar_st, current_bar_et, DEFAULT_FRACTION, endpoint=False, dtype=int)\n                st = flags[position]\n                chords.append([st, value])\n    # get specific time for tempos\n    tempos = []\n    current_bar = 0\n    for tempo in temp_tempos:\n        if tempo == 'Bar':\n            current_bar += 1\n        else:\n            position, value = tempo\n            # position (start time)\n            current_bar_st = current_bar * ticks_per_bar\n            current_bar_et = (current_bar + 1) * ticks_per_bar\n            flags = np.linspace(current_bar_st, current_bar_et, DEFAULT_FRACTION, endpoint=False, dtype=int)\n            st = flags[position]\n            tempos.append([int(st), value])\n    # write\n    if prompt_path:\n        midi = miditoolkit.midi.parser.MidiFile(prompt_path)\n        #\n        last_time = DEFAULT_RESOLUTION * 4 * 4\n        # note shift\n        for note in notes:\n            note.start += last_time\n            note.end += last_time\n        midi.instruments[0].notes.extend(notes)\n        # tempo changes\n        temp_tempos = []\n        for tempo in midi.tempo_changes:\n            if tempo.time < DEFAULT_RESOLUTION*4*4:\n                temp_tempos.append(tempo)\n            else:\n                break\n        for st, bpm in tempos:\n            st += last_time\n            temp_tempos.append(miditoolkit.midi.containers.TempoChange(bpm, st))\n        midi.tempo_changes = temp_tempos\n        # write chord into marker\n        if len(temp_chords) > 0:\n            for c in chords:\n                midi.markers.append(\n                    miditoolkit.midi.containers.Marker(text=c[1], time=c[0]+last_time))\n    else:\n        midi = miditoolkit.midi.parser.MidiFile()\n        midi.ticks_per_beat = DEFAULT_RESOLUTION\n        # write instrument\n        inst = miditoolkit.midi.containers.Instrument(0, is_drum=False)\n        inst.notes = notes\n        midi.instruments.append(inst)\n        # write tempo\n        tempo_changes = []\n        for st, bpm in tempos:\n            tempo_changes.append(miditoolkit.midi.containers.TempoChange(bpm, st))\n        midi.tempo_changes = tempo_changes\n        # write chord into marker\n        if len(temp_chords) > 0:\n            for c in chords:\n                midi.markers.append(\n                    miditoolkit.midi.containers.Marker(text=c[1], time=c[0]))\n    # write\n    midi.dump(output_path)\n",
      "asOf": "2026-11-20"
    },
    "F249": {
      "label": "Project source file, miditoolkit",
      "display": "utils.py",
      "asOf": "2026-11-20"
    },
    "F250": {
      "label": "Project full_name, miditoolkit",
      "display": "YatingMusic/remi",
      "asOf": "2026-11-20"
    },
    "F251": {
      "label": "Project stargazers_count, miditoolkit",
      "display": "606",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python MIDI libraries Mido pretty_midi Miditoolkit MIDIUtil code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
