I’ve been wanting to help my dad make a MIDI processor plugin for Logic Pro X, and I’ve found RtMidi to be a boon with MIDI interaction when I experimented with a simple program that, with the help of my dad at his mixer, I was able to automate the operation of a single mute. However, when it comes to JUCE, I’m utterly overwhelmed with what to do.
TL;DR: How would I go about translating this to JUCE?
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <RtMidi.h>
#include <vector>
void callback(double dtime, std::vector<uint8_t> *pMsg, void *data)
{
std::cout << "Message: ";
for (uint8_t &b : *pMsg)
std::cout << std::hex << std::setw(2) << std::uppercase << static_cast<int>(b) << ' ';
std::cout << '\n';
}
int main()
{
RtMidiIn *midiIn = new RtMidiIn();
RtMidiOut *midiOut = new RtMidiOut();
int inports = midiIn->getPortCount();
int outports = midiOut->getPortCount();
std::vector<uint8_t> msg;
std::cout << "API:" << midiIn->getApiDisplayName(midiIn->getCurrentApi()) << '\n';
std::cout << "Inputs: " << inports << "\n\n";
std::cout << "Outputs: " << outports << "\n\n";
for (int i = 0; i < inports; i++)
std::cout << "Input " << i << ": " << midiIn->getPortName(i) << '\n';
std::cout << '\n';
for (int i = 0; i < outports; i++)
std::cout << "Output " << i << ": " << midiOut->getPortName(i) << '\n';
std::cout << '\n';
int port;
std::cout << "Use port #: ";
std::cin >> port;
midiIn->openPort(port);
midiOut->openPort(port);
midiIn->setCallback(&callback);
midiIn->ignoreTypes(false, false, false);
std::cout << "\nReading MIDI input ... press 'q' and <enter> to quit.\n";
char input = ' ';
bool muteOn = false;
while(input != 'q')
{
if (input == 'm')
{
uint8_t state = muteOn ? 2 : 3 ;
std::vector<uint8_t> msg = { 178, 0, state };
muteOn = state == 2 ? false : true;
midiOut->sendMessage(&msg);
}
std::cin.get(input);
}
delete midiIn;
delete midiOut;
return 0;
}
