npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ableton-push-canvas-display

v1.0.1

Published

send contents of a canvas 2d context to the Ableton Push 2 display

Downloads

4

Readme

ableton-push-canvas-display

Ableton Push 2 has a high resolution color display that can be updated via libusb very easily. The hardest part is drawing pretty graphics. Usually people use frameworks like JUCE for that, but with node and the web, we have something simple, that should also work: The canvas.

This package does that hard work of converting the image data from a canvas to the slightly weird push framebuffer format and sending it via USB.

How to use

Since this uses node libusb bindings, you need to have a node environment. This means that it actually works in electron, even in the renderer process. That also means that you can send a canvas that is actually rendered in a web page.

Here's a minimal example that assumes a set up canvas. The canvas should be 960x160 (the display size of Push 2).

const { initPush, sendFrame } = require('ableton-push-canvas-display')

function render() {
  ctx.clearRect(...)
  ctx.strokeLine(...)
  sendFrame(ctx, (err) => {
    render() // you probably want to do something like requestAnimationFrame or so.
  })
}

initPush((err) => {
  if (!err) {
    render()
  }
})

If you can't or don't want to use a web canvas, there's a npm package called "canvas" that replicates the API using libcairo which works as an image source as well.

Pitfalls

If you don't clear the canvas with a solid background, the results will look weird, as the conversion process doesn't take the alpha channel into account. As soon as you render to a solid background, the alpha masks (for antia aliasing for example) are baked and it should look ok.

For performance reasons I'm using direct access to typed arrays which means that things can go wrong in terms of endianness if you are not on a little endian machine. (which is VERY rare nowadays)

The libusb bulk transfer process takes up almost all of the 16 ms we have to make this a 60fps operation on my iMac, so there could be some jank sometimes. I have to test this on other hardware to see if it needs additional optimisations.

Status

This needs tests (sort of hard to test without actual hardware, but I guess I could at least test the conversion process properly).

It is not handling multiple push devices. Not sure that this is actually a valid usecase for me.

Contributions

...are welcome. Fork the project, open up a PR, yadda yadda.

Credits

This uses Tessel's node-usb library and Automattic's libcairo based canvas implementation for the example.

This library is inspired by an awesome weekend at JSConfEU 2019, and especially by my time spent with the wonderful people at live:js.

Also, thank you so much, Ableton for being very open with Push 2 and documenting almost everything about this awesome hardware.