question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Playing MIDI but no sound

See original GitHub issue

Hi all,

I tried playing MIDI on an Apache Cordova app. I used to be able to play, but now it’s just plain silent. The player keeps listening, but no sound at all, even if I already set the volume to 127.

MIDI.loadPlugin({
    soundfontUrl: 'midi/soundfont/',
    instruments: 'acoustic_grand_piano',
    onsuccess: function () {
        pluginLoaded = true;
        var player = MIDI.Player;
        player.loadFile("midi/files/h" + number + ".mid", function () {
            MIDI.AudioTag.setVolume(0, 127);
            MIDI.AudioTag.setVolume(1, 127);
            for (var i = 0; i < 2; i++) {
                MIDI.channels[i].mute = !document.getElementById('chkChannel' + (i + 1)).checked;                            
            }
            player.start();
            $('#midiPlayPause > i').toggleClass('mdi-av-play-arrow mdi-av-pause');
            loaded = true;
        }, null, function (error) {
            createToast('midi file does not exist.');
        });
        player.addListener(function (data) {
            var now = data.now;
            var end = data.end;
            var channel = data.channel;
            var note = data.note;
            var velocity = data.velocity;
            if (now + 1 > end) {
                loaded = false;
                $('#midiPlayPause > i').toggleClass('mdi-av-play-arrow mdi-av-pause');
            }
        });
    }
});

What am I missing here? Thanks

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

3reactions
jeffcaizcommented, Apr 28, 2020

Yes, I just encounter simular issue today and finally figure out another way instead of pre-compile the soundfont into code.

When you use webpack, the MIDI object is not registered to global window (browser case). So the solution is very simple:

import * as MIDI from "midicube";
...
window.MIDI = MIDI; // Register to global first

MIDI.loadPlugin({
...
});
0reactions
acosmecommented, Aug 9, 2022

perfect @jeffcaiz, it works!

guys don’t forget to declare the player like this:

const player = new MIDI.Player();

Read more comments on GitHub >

github_iconTop Results From Across the Web

I have midi input, but no sound - Sunday Sounds, LLC
5. Select a channel strip, click the “MIDI Input” tab in the inspector area, make sure the “Keyboard:” section matches your assigned keyboard....
Read more >
MIDI device recognized but no sound! - Apple Community
Been recording audio on Logic Pro 7 for ages with no problems. Decided to do some MIDI for the first time, and not...
Read more >
MIDI keyboard not getting sound on laptop
If there's still no sound, troubleshoot with these possible solutions: 1) Check the volume settings of the tone generator and speaker system. 2) ......
Read more >
MIDI signal but no sound-please help all treads on the matter ...
Double Check MIDI Filters in the Preferences > MIDI > MIDI Filter. Make sure Note is not enabled in the filter. Also make...
Read more >
Simple Fixes For No Sound From Your MIDI Keyboard In ...
First, check to see if the MIDI keyboard is registering in Ableton. Second, ensure that you have a virtual instrument on the MIDI...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found