Bind() is undefined

Hello there,

I was trying to back port Roland DJ-505 controller binding to DJ-202 when I stumbled upon a quirk.

When mixxx interprets js binding script places (or sym-linked) to ~/.mixxx/controlles Prototoype.function.bind is undefined. Speaking in other words, when I copy mapping files (xml and js) of DJ-505 and place them to a local folder instead they stop working and the reason is lack of .bind() function. If I define it explicitly as described here https://stackoverflow.com/a/7950495, it starts to work again.

I was trying to find something relevant here but didn’t manage.
Could someone please explain me why is this happening?

ln -s ~/src/mixxx/res/controllers/Roland_DJ-202-scripts.js ~/.mixxx/controllers/Roland_DJ-202-scripts.js
ln -s ~/src/mixxx/res/controllers/Roland_DJ-202.midi.xml ~/.mixxx/controllers/Roland_DJ-202.midi.xml

TypeError: Result of expression ‘function () {…}.bind’ [undefined] is not a function.

Thanks,
Art

You’ve stumbled on the one backwards-incompatible change in the controller system between the 2.3 and main branches of Mixxx. The main branch is using Qt’s newer JavaScript API (QJSEngine) which supports ES7. The legacy QtScript API does not support Function.prototype.bind. With the legacy API, we had a hack around this in the C++ code to get the this object for callbacks. With the new API in the main branch, you need to use Function.prototype.bind instead.

I forgot to mention, I run mixxx_beta-git r8103-1 on Arch Linux compiled from AUR.
It should use the 2.3 branch if I’m not mistaken.
It works fine with builtin presets but once I extract it to local folder bind becomes missing.

I have also tried to specify with no luck.

What would be the best option to work around this?

Are you sure you copied the 2.3 versions of the scripts to your local directory, not the versions from the “main” branch?

My bad, I thought main is 2.3 as an upcoming release.
Now I realize what’s going on.
Sorry and thanks for help guys!

By the way, I strongly recommend to check out the 2.3 branch of the Mixxx git repository and work directly on that. Then you can make use of our pre-commit hooks that check your code during development instead of having to clean it up afterwards.

1 Like