Comments (7)
Nope, you've got things setup fine. You're loading a few more instruments then the demo, each soundfont package is about 1-2MB, you've got about 6mb where the demo is 2mb
You might attempt to figure out how to get the onprogress event working on your server. To do this you'll also have to enable the flag "USE_XHR" in ./js/MIDI/LoadPlugin.js -- You might run into issues calculating the percentage if your server is compressing the output automatically of JSON files. To get around this you can send "Content-Length-Raw" header with the bytesize of the uncompressed file... I know this sounds complex, and it kinda is, but that's the state of getting onprogress through XHR.
from midi.js.
I enabled USE_XHR and looked into using the loader. However, I found that there are two files in the Loader.js repo that aren't in the Window directory from having downloaded the MIDI.js package - DOMLoader.image.js and DOMLoader.link.js. Are these files needed? Did you forget to include them in MIDI.js or are they outdated? Or just not used in MIDI.js's examples?
Also, I'm not sure how to go about having the loader use the onprogress event. I see calls for MIDI.loader in LoadPlugin.js, but they're all conditionals - I don't see where loader is created. There are setup notes in loader.js, but I don't really understand them - are they saying I need to declare a var loader? If so, where?
from midi.js.
Those two files are not used in the MIDI.js demos.
Good point! To create a loader, it should work by typing in:
MIDI.loader = new widgets.Loader;
I would like to find some time to refactor the MIDI.js package, so it's a bit easier, but so it is for now!
from midi.js.
Ok, do I put that in my own code or in LoadPlugin.js? Or somewhere else? And then do I need those other two files? Or does it depend on what I'm trying to do? I just want a loader to show upon first reaching my site since it takes anywhere from around 3-10 seconds to load the page.
from midi.js.
You wont need those other two files.
You should call it right before MIDI.loadPlugin. Basic example:
window.onload = function () { MIDI.loader = new widgets.Loader; MIDI.loadPlugin({ soundfontUrl: "./soundfont/", instrument: "acoustic_grand_piano", callback: function() { var delay = 0; // play one note every quarter second var note = 50; // the MIDI note var velocity = 127; // how hard the note hits // play the note MIDI.setVolume(0, 127); MIDI.noteOn(0, note, velocity, delay); MIDI.noteOff(0, note, delay + 0.75); } }); };
Hope that works for ya!
from midi.js.
Awesome, that worked! However, it's not disappearing after loading reaches 100%. I tried adding MIDI.loader.stop(), but it didn't make any difference. Is there some setting I have to change somewhere?
[update] I moved the MIDI.loader.stop() to inside the loadPlugin callback, and that worked!
Also, what's the difference between Event.add(window, "load", function()) and Window.onLoad = function()? I've always used the latter (or the Jquery equivalent). Never seen the former before. It looks like a more general event handler, but for that I've used EventTarget.addEventListener() (or again the JQuery equivalent).
from midi.js.
Event.add (which is soon to be, or already eventjs.add) is my own custom events library. It's similar to jQuery's, but handles a lot of other types of gestures. There's not any big reason for using it in MIDI.js, other than it was easy for me to add. window.onload works just as nice...
Benefits of Eventjs is touch support, and cross browser support for things like click, drag:
https://github.com/mudcube/Event.js
from midi.js.
Related Issues (20)
- very long notes are truncated HOT 2
- pitch bending in webaudio HOT 2
- How can i send a note to specific stereo channel? HOT 1
- tracks
- Audio Mobile App : MIDI.js or Native ? HOT 2
- k
- Is it impossible to pause when using noteon noteoff instead of player HOT 3
- How to disable sound in Player.js?
- There is no sound when I am playing my own midi file HOT 2
- Question, Piano Layout HOT 1
- Midi files with multi channels doesn't work using MIDI.Player.Loadfile HOT 5
- How to play file.mid HOT 4
- can i use midi.js to create a online piano and guitar? HOT 1
- Color piano not found in chrome web store HOT 2
- Playing midi file with the wrong tempo HOT 1
- ReferenceError: Base64Binary is not defined HOT 1
- Current Position / Event Listener
- Loading all GM instruments for midi file HOT 27
- Slow start of playing HOT 3
- Bug: MIDI events not being fired HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from midi.js.