CoolFace
Apppublic

adricl/Gradio_MIDIBridge

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes
App README

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

🎹 Gradio MIDIBridge

A Gradio custom component that captures live MIDI from the browser (Web MIDI API), sends it to a Python backend for processing, and plays the result back — either on a hardware MIDI output device or through your computer speakers.

Output to speakers

Next to the MIDI Output selector there is an "Output to speakers" checkbox (off by default). When it is checked, the processed MIDI is rendered to a .wav on the backend with FluidSynth and auto-played in an audio player under the router — each new result replaces the previous one. When unchecked, the output is sent to the selected hardware MIDI device as usual.

python
from gradio_midibridge import MIDIBridge

midi = MIDIBridge(
    label="MIDI Bridge",
    bpm=120,
    soundfont="/path/to/your.sf2",  # used to render audio for speaker output
)
audio = gr.Audio(type="filepath", autoplay=True)

# Render processed MIDI to audio (called by the component when the checkbox is on)
midi.change(fn=midi.midi_to_wav, inputs=midi, outputs=audio, api_name="midi_to_wav")

Requirements

  • —FluidSynth CLI — a system package used for MIDI→audio rendering. It is not pip-installable; on the Space it is declared in `packages.txt` (fluidsynth), or install it locally with apt-get install fluidsynth.
  • —A SoundFont (`.sf2`) — supplied via MIDIBridge(soundfont=...). The demo uses SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2; any General MIDI soundfont works.
  • —Python deps are listed in `requirements.txt` (mido, plus the component wheel).