How to convert playing MIDI files to MP3 or WAV format and provide download functionality? #93
Replies: 1 comment
-
|
Thanks for the question! I'm afraid there is no such built-in functionality, but there might be a way to make it work.
What I found to work is to route // Start recording and playback
const recorder = new Tone.Recorder();
Tone.Destination.connect(recorder); // or: Tone.Master.connect(recorder);
recorder.start();
player.start();
// Wait for the playback to stop
player.addEventListener("stop", () => {
// Stop the recorder
recorder.stop().then((recording) => {
// Get the recorded audio as a blob URL
const url = URL.createObjectURL(recording);
// Trigger download
const link = document.createElement("a");
link.download = "recording.webm";
link.href = url;
link.click();
});
})You could mute the playback while waiting for the recording to complete, but the user would still have to wait. If you don't want to wait for the file to be played back, you would need to use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I'm developing a music-related web application using html-midi-player, and I really appreciate the excellent MIDI playback functionality provided by this library.
I currently have a requirement: I want to be able to convert the MIDI files being played to audio formats like MP3 or WAV, and allow users to download the converted files. However, I couldn't find relevant APIs or usage examples in the documentation.
I'd like to ask:
Thank you very much for your time and help!
Beta Was this translation helpful? Give feedback.
All reactions