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

Bug: MIDI events not being fired #273

Open
batata004 opened this issue May 5, 2023 · 5 comments
Open

Bug: MIDI events not being fired #273

batata004 opened this issue May 5, 2023 · 5 comments

Comments

@batata004
Copy link

batata004 commented May 5, 2023

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>
@mscuthbert
Copy link
Contributor

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

https://github.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?

@acosme
Copy link

acosme commented Aug 9, 2023

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

it's a nice work!

@mscuthbert
Copy link
Contributor

hi @mscuthbert what about open the tab 'issues' to your repo in https://github.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?

@acosme
Copy link

acosme commented Aug 10, 2023

hi @mscuthbert what about open the tab 'issues' to your repo in https://github.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';

@mscuthbert
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants