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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@chenberti/street-piano-sdk

v1.0.3

Published

This SDK wraps mqtt.js and EMQX features to provide a robust, production-ready MQTT consumer for backend services.

Readme

Street Piano SDK

A lightweight TypeScript/Node.js SDK for connecting securely to the** ** Street Piano MQTT Broker , receiving MIDI events, and reacting to piano activity in real time.

This SDK is used internally by** Street Piano and by integrators who receive access credentials and a unique ****Piano ID**from the company.


🚀 Installation

Or with yarn:


📦 Quick Start Example


🎹 Understanding the SDK

initializeClient(clientInfo, pianoId, callback)

This is the main function provided by the SDK.

Parameters

| Parameter | Type | Description | | -------------- | -------------- | ------------------------------------------------------------ | | clientInfo | ClinetInfo | Connection information for the MQTT broker. | | pianoId | string | The unique Piano ID provided by Street Piano. | | callback | SubCB | Function that fires whenever a new MIDI message is received. |

What** **initializeClient does

  • Establishes a secure MQTT connection.
  • Authenticates using your credentials.
  • Subscribes to the topic belonging to the given piano ID.
  • Listens for incoming messages.
  • Triggers your callback automatically for each new MIDI event.

🧩 Types

ClinetInfo

Connection settings required to authenticate:

These are usually taken from environment variables.


SubCB

Callback definition for incoming messages:

  • topic → MQTT topic
  • payload → Buffer containing the MIDI message
  • packet → Raw MQTT packet

🎵 MIDI Payload Explanation

All messages received through this SDK originate from the Street Piano system and contain MIDI events.

✅ Topic format

Incoming messages are published to:

piano/play/<piano_id>

Example topic:

piano/play/68ce6762f775e17b114e899d

✅ How to parse the message

Your callback receives the MQTT payload as a Buffer. To extract the structured data, you must parse it like this:

const { payload, timestamp, topic } = JSON.parse(payload.toString());

Example parsed payload

{
  "payload": {
    "type": "note_on",
    "time": 0,
    "note": 91,
    "velocity": 34,
    "channel": 0
  },
  "timestamp": 1763795201.983794,
  "topic": "piano/play/68ce6762f775e17b114e899d"
}

Field explanations

payload (MIDI message)

This object is a standard MIDI event produced by the piano.

  • type

    • note_on: a key was pressed.
    • note_off: a key was released.
  • note MIDI note number (0–127).Each value maps to a musical pitch on the keyboard.Example: 91 is a high note.

  • velocity How strongly the key was pressed (0–127).Higher velocity = louder / stronger press.Note: a note_on with velocity 0 is often treated as note_off.

  • channel MIDI channel (0–15).Most pianos use channel 0, but setups with multiple instruments may use others.

  • time Delta time (seconds) relative to the previous MIDI event. In real-time streaming it is often 0.

timestamp

Unix timestamp (seconds, including fractions) indicating when the event was produced/sent by the piano system. Useful for ordering events, measuring latency, or syncing visuals.

topic

The MQTT topic the message arrived on:

piano/play/<piano_id>

🎹 Piano ID (IMPORTANT)

You must pass a valid** Piano ID when calling **initializeClient:

This** **"1234" is a unique ID assigned by Street Piano.

  • Each piano has its own ID
  • You can only subscribe to pianos you were authorized to access
  • If you do not know your piano ID, contact Street Piano support

❗ Error Handling

The SDK automatically protects your application from:

  • Duplicate MQTT clientId issues
  • Reconnect storms
  • Forced disconnections
  • Session takeover events

If a fatal problem occurs, the SDK** **stops reconnecting and informs you through logs/events.


🤝 Support

For credentials, piano IDs, or integration help:

📧** **[email protected] (Or your internal Street Piano engineering contact)


❤️ Contributions

This SDK is maintained internally. Feel free to open issues or PRs for improvements.