juce_mts_esp
A JUCE module wrapping the MTS-ESP client library for easy microtuning support in JUCE audio plugins
juce_mts_esp
A JUCE module wrapping the MTS-ESP client library for easy microtuning support in JUCE audio plugins.
MTS-ESP allows a single master plugin to control the tuning of any number of connected client plugins across a DAW session. This module provides a clean C++ wrapper around the MTS-ESP client API, making it simple to add microtuning support to any JUCE-based plugin.
Features
- RAII wrapper around MTS-ESP client registration/deregistration
- Full access to all MTS-ESP client API functions
- Convenience method for parsing MTS SysEx from
juce::MidiBuffer - Optional fallback to standard 12-TET tuning when MTS-ESP is not available
- Configurable reference frequency for fallback tuning
- MIT licensed
Usage
Adding to your project
-
Add this repo as a submodule to your project:
git submodule add https://github.com/jameshball/juce_mts_esp.git modules/juce_mts_esp cd modules/juce_mts_esp && git submodule update --init --recursive -
Add the module in Projucer or CMake.
Basic example
#include <juce_mts_esp/juce_mts_esp.h>
class MyProcessor : public juce::AudioProcessor
{
public:
MyProcessor()
{
// Client is automatically registered on construction
}
void processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midi) override
{
// Parse any MTS SysEx messages in the MIDI buffer (for fallback tuning)
mtsClient.parseMidiBuffer(midi);
for (const auto metadata : midi)
{
auto msg = metadata.getMessage();
if (msg.isNoteOn())
{
int note = msg.getNoteNumber();
int channel = msg.getChannel() - 1; // JUCE uses 1-16, MTS-ESP uses 0-15
// Check if the note should be filtered out (unmapped key)
if (mtsClient.shouldFilterNote(note, channel))
continue;
// Get the retuned frequency
double freq = mtsClient.noteToFrequency(note, channel);
// ... use freq to set oscillator pitch
}
}
}
private:
mts_esp::Client mtsClient;
};
Displaying connection status
bool connected = mtsClient.hasMaster();
const char* scaleName = mtsClient.getScaleName();
API Reference
See juce_mts_esp_Client.h for the full API. All MTS-ESP client functions are wrapped:
| Method | Description |
|---|---|
noteToFrequency(note, channel) | Get retuned frequency for a MIDI note |
retuningInSemitones(note, channel) | Get retuning offset in semitones |
retuningAsRatio(note, channel) | Get retuning as a frequency ratio |
shouldFilterNote(note, channel) | Check if a note should be ignored (unmapped) |
frequencyToNote(freq, channel) | Find nearest MIDI note for a frequency |
frequencyToNoteAndChannel(freq, &channel) | Find nearest note and suggested channel |
hasMaster() | Check if connected to an MTS-ESP master plugin |
shouldUpdateLibrary() | Check if the MTS-ESP library needs updating |
getScaleName() | Get the name of the current scale |
getPeriodRatio() | Get the period ratio (default 2.0 for octave) |
getPeriodSemitones() | Get the period in semitones (default 12.0) |
getMapSize() | Get the keyboard map size (-1 if not set) |
getMapStartKey() | Get the keyboard map start key (-1 if not set) |
getRefKey() | Get the reference key (-1 if not set) |
parseMidiBuffer(midiBuffer) | Parse MTS SysEx from a JUCE MidiBuffer |
parseMidiData(buffer, len) | Parse raw MIDI data for MTS SysEx |
hasReceivedMTSSysEx() | Check if valid MTS SysEx has been received |
setEnabled(bool) | Enable/disable MTS-ESP retuning |
setFallbackReferenceFrequency(hz) | Set A4 frequency for fallback 12-TET |
getClient() | Get raw MTSClient* for advanced use |
License
MIT — see LICENSE.
The MTS-ESP library itself is licensed under 0BSD.
Something wrong with this product?
ReportAre you the owner of this product?
Request Ownership