@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
22import { useBeforeunload } from "react-beforeunload" ;
33import "./App.css" ;
44import MudClient from "./client" ;
5+ import { virtualMidiService } from "./VirtualMidiService" ;
56import CommandInput from "./components/input" ;
67import OutputWindow from "./components/output" ;
78import PreferencesDialog , {
@@ -28,6 +29,7 @@ import {
2829 GMCPClientHtml ,
2930 GMCPClientKeystrokes ,
3031 GMCPClientMedia ,
32+ GMCPClientMidi ,
3133 GMCPClientSpeech ,
3234 GMCPCommChannel ,
3335 GMCPCommLiveKit ,
@@ -86,6 +88,7 @@ function App() {
8688 const newClient = new MudClient ( "mongoose.moo.mud.org" , 8765 ) ;
8789 newClient . registerGMCPPackage ( GMCPCore ) ;
8890 newClient . registerGMCPPackage ( GMCPClientMedia ) ;
91+ newClient . registerGMCPPackage ( GMCPClientMidi ) ;
8992 newClient . registerGMCPPackage ( GMCPClientSpeech ) ;
9093 newClient . registerGMCPPackage ( GMCPClientKeystrokes ) ;
9194 newClient . registerGMCPPackage ( GMCPCoreSupports ) ;
@@ -121,6 +124,17 @@ function App() {
121124 setShowSidebar ( ! isMobile ) ;
122125 window . mudClient = newClient ;
123126 clientInitialized . current = true ;
127+
128+ // Initialize virtual MIDI synthesizer
129+ virtualMidiService . initialize ( ) . then ( ( success ) => {
130+ if ( success ) {
131+ console . log ( "Virtual MIDI synthesizer initialized" ) ;
132+ } else {
133+ console . log ( "Failed to initialize virtual MIDI synthesizer" ) ;
134+ }
135+ } ) . catch ( ( error ) => {
136+ console . error ( "Error initializing virtual MIDI synthesizer:" , error ) ;
137+ } ) ;
124138
125139 // Listen to 'keydown' event
126140 const handleKeyDown = ( event : KeyboardEvent ) => {
@@ -131,6 +145,11 @@ function App() {
131145 }
132146 if ( event . key === "Escape" ) {
133147 newClient . stopAllSounds ( ) ;
148+ // Also send MIDI all notes off if MIDI is enabled
149+ const midiPackage = newClient . gmcpHandlers [ "Client.Midi" ] ;
150+ if ( midiPackage ) {
151+ ( midiPackage as any ) . sendAllNotesOff ( ) ;
152+ }
134153 }
135154 } ;
136155
0 commit comments