(Reaper 5.987 x64, Win 10)
Thanks for the suggestion about using the HUI mode, RuudNL.
A nice friend of mine (sitting next to me as I type!) gave me an Arduino looking for those codes from the HUI mode. It had an optocoupler on the input, connected to the MIDI OUT of a cheap USB MIDI interface dongle - see the github page link below for a schematic.
It worked!
For a bit.
It then started only detecting 'Record' being clicked after a delay, of between 4-12 seconds, depending on the project and time of day. Sometimes it worked immediately again. It would always switch off immediately Record was clicked off.
Not so useful.
Using a terminal, we could see that the problem was actually Reaper not outputting the relevant code for some seconds after the record icon goes red and recording starts - sometimes. No other problem with record seems in evidence, just the delay in outputting the MIDI code.
This could of course be a problem with the USB-MIDI interface, but in previous use the only issue I had with this device was latency measurable in milliseconds, not ten seconds!
** Therefore, a warning - the HUI output is not to be trusted, at least not in v5.987 **
SO, we tried investigated the output of the FRONTIER TRANZPORT mode.
planktone (above) reports this as B6 on Ch 1. We couldn't see this code being sent.
What we COULD find, eventually, was a 3 byte MIDI code when RECORD is clicked:
90 5F 7F = RECORDING
90 5F 00 = NOT RECORDING
(Codes:
90: note on for channel 0
5F: note value
3rd byte = velocity(!): 7F for record on, 00 for record off )
This seems to work consistently now.
The output switches on a 'Record' light in my audio booth, as well as turning off the air conditioning fan.
Arduino sketch below.
__________________________________________________ _____________________
/* Code courtesy of Martyn Davies
https://github.com/magiccow/midi-reaper */
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setOutput(int on){
if(on){
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}else{
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
}
}
int state=0;
unsigned char buffer[5];
int buflen=0;
void add(unsigned char ch){
if(state==0){
unsigned char op = ch & 0xF0;
if(op == 0xB0){
buffer[buflen++]=ch;
state=1;
}else if(op==0x80 || op==0x90 || op==0xC0 || op==0xD0){
buffer[buflen++]=ch;
state=5;
}
}else if(state==1){
if(buflen<3){
buffer[buflen++]=ch;
if(buflen==3){
for(int i=0;i<3;i++){
Serial.print(buffer[i],HEX);
Serial.print(' ');
}
Serial.println();
if(buffer[0]==0xB0 && buffer[1]==0x2C){
int on = (buffer[2]==0x45);
if(on)
Serial.println("Output on");
else
Serial.println("Output off");
setOutput(on);
}
state=0;
buflen=0;
}
}
}else if(state==5){
if(buflen<3){
buffer[buflen++]=ch;
if(buflen==3){
for(int i=0;i<3;i++){
Serial.print(buffer[i],HEX);
Serial.print(" ");
}
Serial.println();
if(buffer[0]==0x90 && buffer[1]==0x5F){
int on = (buffer[2]==0x7F);
if(on)
Serial.println("Note on: Output on");
else
Serial.println("Note off: Output off");
setOutput(on);
}
state=0;
buflen=0;
}
}
}else if(ch==0xFA || ch==0xFC){
if(ch==0xFA){
Serial.println("Start");
}else{
Serial.println("Stop");
}
}
}
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
pinMode(LED_BUILTIN, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
setOutput(0);
// set the data rate for the SoftwareSerial port
mySerial.begin(31250);
Serial.println("Running");
}
void loop() { // run over and over
if (mySerial.available()) {
unsigned char c = mySerial.read();
add(c);
}
}