MIDIVal 0.0.16: now with MIDI Clock support

The new version of MIDIVal just landed bringing an easier way to use MIDI Clock in your app.

If you didn’t come across MIDIVal before, it is a library that simplifies communication with MIDI devices from your JavaScript / TypeScript code by providing a high-level interface. It allows you to communicate with synthesizers (or any other MIDI devices) in an idiomatic way. You can read more about library itself in my initial post here.

Listening to MIDI Clock Messages

Now you can listen to all MIDI Clock messages like Clock Start, Stop and Continue as well as to individual pulse messages (sent 24 times every quarter note). This allows you to synchronize your Web-based music with an external clock from your synthesizer (or your DAW), create real-time applications based on the clock, or even send it over the web (or whatever else you can imagine).

Moreover, if you want to compute and use tempo (beats per minute) in which your MIDI device is sending those messages, you can use MIDIVal to automatically compute that for you. Then you can access it anytime:

If you forget to set computeClockTempo option, getting tempo will throw MIDIValConfigurationError on access attempt.

Sending MIDI Clock Messages

You can also send MIDI Messages to your MIDI Output device now. The following new methods are available:

  • sendClockStart()
  • sendClockStop()
  • sendClockContinue()
  • sendClockPulse()

These allow you to manually control the clock. This can be a great tool when you don’t have any physical MIDI device with a built-in clock/sequencer or when you want to have full control over the clock from your JavaScript / TypeScript code. Remember that you have to send pulse messages manually 24 times every quarter note, for example like the following:

Other Changes

Besides adding MIDI Clock messages extended support, new versions of MIDIVal have been reworked from the ground up to incorporate my other project, Omnibus — a simple implementation of platform-agnostic Event Bus. The initial implementation of the event bus in MIDIVal was a direct inspiration for this library and I decided to make it reusable in different projects.

In addition, MIDI Callbacks are not much nicely typed and Note On/Off, CC and Program Change messages get the parameters nicely mapped to logical names:

This can allow for tidier code without having to bother about MIDI message internals even more.

To get started with MIDIVal, you can head to https://midival.github.io.

To download this version, run:

yarn add @midival/core@0.0.16# or using NPM
npm install @midival/core@0.0.16

Happy playing! 🎹




Senior Engineer @ LEGO Group

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Deploy and Secure MongoDB on Atlas

Locators in Selenium

Handling the SVG element in Selenium

A Common JavaScript Phone Screen Question Asked By Facebook

Implementing a Maybe Pattern using a TypeScript Type Guard

Full-text search with Gatsby and Netlify CMS

Kick-start your Typescript migration with JSDoc and ts-migrate

Error Boundary for Next.js API routes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kacper Kula

Kacper Kula

Senior Engineer @ LEGO Group

More from Medium

Analyze and Optimize Webpack Bundles Size and Contents

Build a Functional Programming Library Using ES6 Iterator Protocol

Moving Libraries to Deno: The Whys and Hows

Using TomTom APIs with Node.js and TypeScript