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

MIDI.Player doesn't play multiple channels. #184

Closed
muratgorken opened this issue Jun 25, 2016 · 2 comments
Closed

MIDI.Player doesn't play multiple channels. #184

muratgorken opened this issue Jun 25, 2016 · 2 comments

Comments

@muratgorken
Copy link

Hi there, is this problem only for me?

I just

$(document).ready(function () {
  MIDI.loadPlugin({
    soundfontUrl: "assets/test/soundfont/",

    onprogress: function(state, progress) {
      console.log(state, progress);
    },
    onsuccess: function() {

        player = MIDI.Player;
        player.loadFile('test.mid', function(){
                  player.start();
        });
    }
  });
});

it's starts normally, but i have 6 channel (instrument) in this midi file. But, only playing first channel with "grand piano"..

note : i have all of instrument files in soundfonts folder.

someone could help me?

@muratgorken
Copy link
Author

muratgorken commented Jun 25, 2016

I wrote some code about this.

First of all, I just want play midi file normally.

Note : Its including Jquery

I wrote this function in player.js

midi.loadInstruments = function(){
    var inst = midi.getFileInstruments();
    $.each(inst, function(){
        MIDI.loadResource({instrument:MIDI.GM.byName[this].number});
    })
}

And added this line midi.getFileInstruments() function in player.js. (in case of 'programChange')
MIDI.programChange(event.channel, event.programNumber);

after I changed my loadFile args.

$(document).ready(function () {
  MIDI.loadPlugin({
    soundfontUrl: "assets/test/soundfont/",
    onprogress: function(state, progress) {
      console.log(state, progress);
    },
    onsuccess: function() {
        player = MIDI.Player;
        player.loadFile('test.mid', function(){
            player.loadInstruments();
        });
    }
  });
});

Note : You must all of soundfonts put to soundfonts folder

It will, parse the midi file and needed instruments will be loaded.

you just run MIDI.Player.play() command.

Maybe it works for someone.

@muratgorken
Copy link
Author

I just noticed . there is a commented line in midi.loadMidiFile function same as instruments: midi.getFileInstruments(),
I removed comment tags and added this line midi.getFileInstruments() function in player.js. (in case of 'programChange')
MIDI.programChange(event.channel, event.programNumber);

this works same.

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

1 participant