-
Notifications
You must be signed in to change notification settings - Fork 59
instrument.play() is not a function? #34
Comments
Hi @laniel, The soundfont.instrument(ac, 'marimba').play() you should write: soundfont.instrument(ac, 'marimba').then(function (marimba) {
marimba.play('C4')
}) Hope it helps. |
Thanks for the response. I saw those examples, but I would like to load an instrument on loading the page and then play a note based on future events without the need to reload the instrument each time. Any ways of doing this? |
Yes. You can call var marimba = load(ac, 'marimba');
marimba.then(function (inst) {
inst.play('C4')
})
// later...
marimba.then(function(inst) {
// you get the same inst instance than before
inst.play('d4')
}) Another (less clean) option is to setup a global variable and initialize when the promise resolves. Then play the note if the global variable is initialized. Hope it helps |
I understand this is working for you. Please feel free to reopen if not. |
This is still giving me "inst.play is not a function". |
Running the following code seems to be returning a "Uncaught TypeError: marimba.play is not a function".
var marimba = soundfont.instrument(new AudioContext(), 'marimba');
marimba.play('C4');
Seems as though every time I try to set a variable to an instrument I cannot play. Any suggestions?
The text was updated successfully, but these errors were encountered: