0

I am trying to play this midi song.

But the tempo is all wrong.

I am simply doing:


        MIDI.loadPlugin({
            soundFontUrl: "./soundfont/",
            onsuccess: function(){
                console.log('loaded');
                MIDI.Player.loadFile("data:audio/midi;base64,"+song, function(){
                    console.log('here');
                    MIDI.Player.start();
                }
                );
            },
        });

I posted the song variable I used here (it was too large for StackOverflow).

Any ideas?

João Abrantes
  • 4,772
  • 4
  • 35
  • 71
  • If something's too large for Stackoverflow, the solution is not to put the entire thing up somewhere, it's time to start ripping as much out as possible until you have a [mcve] that _can_ be made part of your post. A MIDI file with tempo code is [a touch over 40 bytes long](http://www.music.mcgill.ca/~ich/classes/mumt306/StandardMIDIfileformat.html), so you can quite easily put that in your post as annotated HEX. – Mike 'Pomax' Kamermans Jan 21 '22 at 17:31

1 Answers1

0

Just need to do MIDI.Player.BPM = null;

Before loading the music, otherwise the default BPM will override the one specified on the .mid.

João Abrantes
  • 4,772
  • 4
  • 35
  • 71
  • By the way, did you get several musical instruments to play correctly? I use SoundFonts from [here](https://github.com/gleitz/midi-js-soundfonts) and [the latest official branch "abcjs" of MIDI.js](https://github.com/mudcube/MIDI.js/tree/abcjs), it plays several musical instruments nicely (unlike the "master" branch), but there's a small problem during the first notes: https://github.com/mudcube/MIDI.js/issues/268#issuecomment-1366320897 – root Dec 28 '22 at 03:14