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! 🎹