Comments (7)
Hi Danny,
You're reloading the plugin each time "click" is called, you should only need to run noteOn/noteOff. It should look something like this:
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);
$("#play").click(function () {
MIDI.noteOn(0, note, velocity, delay);
MIDI.noteOff(0, note, delay + 0.75);
});
}
});
from midi.js.
@mudcube, is there a way to load an additional instrument without reloading the plugin itself? That is how I'm doing it at http://tribex.derfers.us/index.php?page=MIDI_Piano but after loading 10 or 12 instruments, it fails with the same error as the OP.
function loadInstrument(id) {
MIDI.loadPlugin({
soundfontUrl: "./soundfonts/",
instrument: id,
callback: function () {
//Set the instrument to the channel 0 so we can actually hear it.
MIDI.programChange(0, id);
},
})
};
...
...
...
<p class="selection" onclick="loadInstrument(0)">Acoustic Grand Piano</p>
(I hope you don't mind a reply to a closed thread)
from midi.js.
Load all the instruments in one go when you load the plugin. Then have your onclick call a program change instead of an instrument load.
from midi.js.
Unfortunately, that requires sending about 347.3MB to the client, and it would all be loaded in order, so the client would have to wait until the instrument he wanted to actually use was loaded.
The way I have it now, only the instruments that the client actually wants are loaded when he selects an item from a list.
(The code example above is very shortened. I actually have a list of all the instruments that is automagically generated).
from midi.js.
Ah ok, yeah that's a lot of data to send. Mine is only a tenth of that amount. Well, I still think the way you have it now is fine.
from midi.js.
@tribex Sorry about trying to contact you via this issue. I couldn't seem to find an email to reach you on your website (am I blind?).
Did you create all those base64 encoded soundfonts? Are they available to the public? It's quite an impressive list!
Edit: Did some more sleuthing and I found the https://github.com/gleitz/midi-js-soundfonts :) So you can disregard.
from midi.js.
@Silverwolf90 No you're not blind, The website is still VERY fresh and I haven't finished adding all the content.
And no, I got them from the link you posted.
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 3
- 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 25
- 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.