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

Provide loading process feedback #59

Closed
detky opened this issue Jan 10, 2014 · 6 comments
Closed

Provide loading process feedback #59

detky opened this issue Jan 10, 2014 · 6 comments

Comments

@detky
Copy link

detky commented Jan 10, 2014

Hallo Michael,

i'm trying to set the flag USE_XHR to true to get some loading progress feedback to build an animation, but i'm getting always an error on the following line:

MIDI.Soundfont[instrumentId] = JSON.parse(response.responseText);

JSON reports invalid character by parsing. I'm loading standard instruments from "midi-js-soundfonts" that works fine when USE_XHR is set to false.

Do you have an idea of what could be the reason?

Thanks for your help and your great job!

@mudcube
Copy link
Owner

mudcube commented Jan 10, 2014

Hi (just scanning over the code now), the problem is that when USE_XHR is turned on that it's expecting a JSON object, and it's getting a JS file. So, either the code could be rewritten to use JS dynamical script include, or to convert the soundfont into JSON.

To get JS to work (instead of recompiling the soundfonts into JSON) replace this:

    MIDI.Soundfont[instrumentId] = JSON.parse(response.responseText);

With this:

    var script = document.createElement("script");
    script.language = "javascript";
    script.type = "text/javascript";
    script.text = response.responseText;
    document.body.appendChild(script);

Inside the MIDI/LoadPlugin.js file, there's two places to replace that, so might as well make into a helper function. And then maybe add in USE_XHR_JS option, so the JSON still works. Feel free to submit changes :)

@detky
Copy link
Author

detky commented Jan 12, 2014

Hallo Michael,
I got it working but i have a very strange collateral effect:
my page (http://www.easychords.eu/BeatsEditor.aspx) uses 2 instruments, bass and (a modified) synth_drum, loaded as following:
...
} else if (midiMode == 'DrumsBass') {
sampleInstrument = "D";
MIDI.loadPlugin({
soundfontUrl: "audio/soundfont_FluidR3_GM/",
instruments: ["synth_drum","electric_bass_pick"],
soundManagerUrl: "js/SoundManager2/soundmanager2-nodebug-jsmin.js",
callback: function() {
MIDI.programChange(2, 118); //1 Drums
MIDI.programChange(3, 34); //Bass
CheckIniTialization();
}
});
}
...

only running on firefox, if call: MIDI.noteOn(2, 21, velocity, delay) sounds a Bass instead of a drum, and It happens just with some notes.
The only way to get the drum sounds running including the file Loader.js is using just one instrument.
Did you saw something like that before? there is any logic that could produce a channel switch?

regards,

@mudcube
Copy link
Owner

mudcube commented Jan 14, 2014

Your app looks great, I'm enjoying the quality of encoded media--deep bass!

I don't have the free time to take a look into this. MIDI.js was made primarily for Color Piano to work, so I did not do much testing with multiple instruments. I know others have fixed this since in their own implementations, but unfortunately, they did not share their code back. I imagine it'd take me a few hours to get working. If you want to hire me, send me an email at admin@sketch.io

@detky
Copy link
Author

detky commented Jan 31, 2014

Hallo Michael,
thanks anyway! I would hire you if i could, but unfortunately i cant :(
I've left the the changes related to this Topic because i found a deeper Problem that is driving me crazy, but i'll continue when i get a way to get multiple instruments working. I'll create another issue now, with a clear example, maybe someone have a good idea. After I'll finish this and post the changes

Regards

@mudcube
Copy link
Owner

mudcube commented Jan 31, 2014

I may be getting some client work soon surrounding this, and will be able to push changes to the MIDI.js project—I'll keep you in the loop on developments on this. Yeah, feel free to create a new issue, it's always helps to hear back from dev's who've done their own testing.

@mudcube
Copy link
Owner

mudcube commented Feb 18, 2014

Latest dev version supports progress events.

@mudcube mudcube closed this as completed Mar 27, 2015
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

2 participants