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

ortho-remote

v0.4.0

Published

Client package for connecting to Ortho Remote Control by Teenage Engineering

Downloads

83

Readme

License Node Maintained

Ortho Remote client package for Node.js for interacting with Teenage Engineering's BLE-MIDI Ortho Remote

The ortho-remote package is designed to support multiple devices simultaneously, provide a high-level abstraction for interaction events, as well as provide access to the raw BLE-MIDI data.

For more information on BLE-MIDI see midi.org

Ortho Remote

Installation

To install ortho-remote for use within your project use yarn or npm

$ yarn add ortho-remote

ortho-remote is writing in TypeScript and contains the necessary type definitions, so no need to acquire @type definitions

Troubleshooting

It's worth adding help on troubleshooting before you get started. There may be times your Ortho Remote cannot be discovered for various reasons.

Linux Permissions

If using Linux be sure to check out noble for set up and configuration instructions

Low Power States

A Ortho Remote may have entered a low-power state. Simply interact with the dial or click the dial button to wake a Ortho Remote device up.

Persistent Pairing (Not Advertising)

BLE-MIDI devices on some OSes can retain paired connections. This can be problematic because once paired Ortho Remote will not be discoverable, leading to timed out connections.

Ensure you have disconnected from an Ortho Remote before running any example or writing code.

You may addtionally have to manually disconnect after each run-debug cycle during development, as has been my experience on macOS as it automatically pairs on connection...

disconnect

Getting Started

Check out examples for now for more usage.

Examples

Clone ortho-remote-node and run the examples to try things out. package.json contains many example scripts. Alternatively, for Visual Sudio Code users you have access to the pre-configured launch configurations to run the examples.

$ git clone https://github.com/pryomoax/ortho-remote-node.git
$ cd ortho-remote-node
$ yarn install

Run one of the following scripts

# Device discovery
$ yarn device-discovery

# Interaction events
$ yarn events

Getting Connected

The first thing you are going to want to do is connect to an unpaired Ortho Remote. The snippet below demonstrates the connection to single device

import { DeviceDiscoveryManager } from 'ortho-remote'

// Device connection manager
const manager = DeviceDiscoveryManager.defaultManager

/**
 * Main application entry point
 */
async function main() {
    console.log('Starting Ortho Remote discovery')

    // Create a new discovery session
    const session = manager.startDiscoverySession()

    console.log('Waiting for device...')

    // Convenience to wait the first discovered Ortho Remote
    const device = await session.waitForFirstDevice()

    console.log(`Found device '${device.id}'`)
    console.log('Connecting...')

    // Establish device connection
    if (await device.connect()) {
        console.log('Connected')

        //
        // You're connected, observe events and get started...
        //

        // If the device gets disconnected, exit the app
        device.on('disconnect', () => {
            console.log('Disconnected! Exiting.')

            // On a disconnect, exit
            process.exit(0)
        })
    }
}

// Boot strap async function
main().catch((err) => {
    console.log(err)
    process.exit(1)
})

Listening for Events

ortho-remote emits events for various interactions. All those interactions are on display in example-events.ts

if (await device.connect()) {
    // Button click
    device.on('click', () => {
        console.log('Clicked!')
    })

    // Button click, longer than 400ms
    device.on('longClick', () => {
        console.log('Clicked!')
    })

    // Rotation
    device.on('rotate', (rotation: number, buttonPressed: boolean) => {
        console.log(`Rotated: ${rotation}`)
    })
}

Accessing Raw Data

The abstractions in eventing may not work for everyone so ortho-remote emits BLE-MIDI events, or can be configured to emit raw data in other events like rotate ` instead of them being normalized.

import { OrthoRemoteConfig } from 'ortho-remote'

// Configure `OrthoRemote` to not normalize data
const orthoConfig: OrthoRemoteConfig = {
    normalizeData: false,
}

if (await device.connect(orthoConfig)) {
    device.on('rotate', (rotation: number, buttonPressed: boolean) => {
        console.log(`Rotated: ${rotation}`)
    })
}

To access the BLE-MIDI data in parsed or it's raw form, use the midi event

import { MidiData } from 'ortho-remote'

if (await device.connect()) {
    device.on('midi', (data: MidiData, rawData: Buffer) => {
        // Use BLE-MIDI data
    })
}

API

The API documention for the package can be found under docs

Known Issues

Ortho Remote was implemented for MIDI applications, and although some interpretation and abstractions have been implemented there are some current restrictions. Hopefully can be resolved in the future

Rotation Limitations

The package cannot set back a rotation value back to the Ortho Remote. This makes some applications difficult when needing to sync a existing value to an OrthoRemote object. For example, matching a volume level between devices.

Event Filtering

As humans we are not to precise with some interactions. Ortho Remotes can send rotation events when depressing/releasing the Ortho Remote button.

I hope to implement event filtering as an option to make it more reliable to use for some applications