chiptune2.js
chiptune2.js copied to clipboard
Uncaught TypeError: libopenmpt._malloc is not a function
Using part of the code of the demo-page I've been trying to get Chiptune2.js to play a song. But this error keeps coming up.
chiptune2.js:187 Uncaught TypeError: libopenmpt._malloc is not a function
at ChiptuneJsPlayer.createLibopenmptNode (chiptune2.js:187:30)
at ChiptuneJsPlayer.play (chiptune2.js:151:26)
This is the part of the demo-page that I'm using...
<script type="text/javascript">
window['libopenmpt'] = {};
libopenmpt.onRuntimeInitialized = function() {
var player;
function init() {
if (player == undefined) {
player = new ChiptuneJsPlayer(new ChiptuneJsConfig(-1));
} else {
player.stop();
}
}
function afterLoad(path, buffer) {
player.play(buffer);
}
function loadURL(path) {
init();
player.load(path, afterLoad.bind(this, path));
}
document.querySelectorAll('.song').forEach(function (e) {
e.addEventListener('click', function (evt) {
modurl = evt.target.getAttribute("data-modurl");
loadURL(modurl);
}, false);
});
};
</script>
<script type="text/javascript" src="js/libopenmpt.js"></script>
<script type="text/javascript" src="js/chiptune2.js"></script>
I can't figure out why this error is thrown. Can anyone help me out?
Apparently there is a difference between downloading the libopenmpt.js & chiptune2.js files provided here and using them internally (like: <script type="text/javascript" src="js/libopenmpt.js"></script>
) or using the external source on jsdelivr (like: <script type="text/javascript" src="//cdn.jsdelivr.net/gh/deskjet/chiptune2.js@master/libopenmpt.js"></script>
).
Because if I use the jsdelivr files my app works fine without any errors.
Sounds odd. There should not be a difference between the files from jsdelivr vs what you get from this repo. Are you sure the you're using identical files? Newer releases from the libopenmpt project might not export the same functions as they used to. If this is the case we would have to look into custom builds.