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

Make it posible to determine alternate location of data file #15

Merged
merged 4 commits into from Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Expand Up @@ -19,13 +19,17 @@ $( document ).ready(function() {
color: "red",
onUnpdate: midiUpdate,
onStop: midiStop,
width: 250
width: 250,
locateFile: function(file) {
//locate wildwebmidi.data
return '/path/to/'+file;
}
});
$("#player").midiPlayer.play(song);
});
```

Remark: you also need to include the `wildwebmidi.data` file that needs to be accessible from the root of your site.
Remark: you also need to include the `wildwebmidi.data` file that needs to be retrieved by locateFile option, or accessible from the root of your site if not specified.

The source code of the demo is available [here](https://github.com/rism-ch/midi-player/tree/gh-pages)

Expand Down
6 changes: 4 additions & 2 deletions player/midiplayer.js
Expand Up @@ -184,8 +184,6 @@ var MidiPlayer = {
}
}
};
MidiModule(MidiPlayer);


function onAudioProcess(audioProcessingEvent) {
var generated = circularBuffer.use();
Expand Down Expand Up @@ -342,6 +340,10 @@ function runConversion() {
// update rate should not be less than 10 milliseconds
options.updateRate = Math.max(options.updateRate, 10);

if(options.locateFile) MidiPlayer.locateFile = options.locateFile;

MidiModule(MidiPlayer);

$.fn.midiPlayer.play = function (song) {
if (midiPlayer_isLoaded == false) {
midiPlayer_input = song;
Expand Down