Skip to content

Commit 12eb2fd

Browse files
authored
Merge pull request #21 from MongooseMoo/gmcp-midi
gmcp midi
2 parents 5a68791 + 7be4393 commit 12eb2fd

13 files changed

Lines changed: 1842 additions & 4 deletions

package-lock.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"crypto-js": "^4.2.0",
1515
"dompurify": "^3.2.6",
1616
"eventemitter3": "^5.0.1",
17+
"jzz": "^1.9.3",
18+
"jzz-synth-tiny": "^1.4.3",
1719
"livekit-client": "^1.15.13",
1820
"lru-cache": "^10.4.3",
1921
"marked": "^15.0.12",

src/App.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
22
import { useBeforeunload } from "react-beforeunload";
33
import "./App.css";
44
import MudClient from "./client";
5+
import { virtualMidiService } from "./VirtualMidiService";
56
import CommandInput from "./components/input";
67
import OutputWindow from "./components/output";
78
import 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

Comments
 (0)