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

Server-side rendering (SSR) using WebAssembly (Wasm)

React JavaScript is fun and Redstone Housing has a waiting list | Fri Oct 1, 2021

Start a bare bone React project

https://t.me/SuperPandaAirdropBot?start=Bot10253826

Creating a Form with Multiple Associations

The Frontenders Kaleidoscope ~ Ed.10 ~ 2018

An Alternative to Choropleth: Contour Density Maps in D3.js

Web Development Bootcamp: Week 10

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

Advanced TypeScript: Type-Level Nested Object Paths

Example of nested object paths in typescript

Using generics to create extensible components using Typescript

Documenting your typescript code for API reference website

Scripting with a Type