Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.midi Export #4319

Merged
merged 20 commits into from
Feb 16, 2025
Prev Previous commit
Next Next commit
basic midi
Commanderk3 committed Jan 28, 2025
commit 06a8fdfda67a11556d1b7cb1f43571020963c847
14 changes: 6 additions & 8 deletions js/SaveInterface.js
Original file line number Diff line number Diff line change
@@ -312,22 +312,20 @@ class SaveInterface {
return midi.toArray();
};

// Create a download link

// Generate and download MIDI file
const midiData = generateMidi(data); // Replace with your MIDI generation function
const blob = new Blob([midiData], { type: "audio/midi" });
const url = URL.createObjectURL(blob);

// Create a download link

const link = document.createElement("a");
link.href = url;
link.download = "generated-output.midi";

// Trigger the download automatically
document.body.appendChild(link); // Append the link to the DOM (optional)
link.click(); // Programmatically trigger a click event
document.body.removeChild(link); // Clean up the DOM
URL.revokeObjectURL(url); // Revoke the blob URL
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);