Patch SM midi pins

Hi, Which of USART pins would my midi come out of on my Patch SM, does anybody know? Am using oopsy and wired something up to the ones that are also for usb. No midi comes out so far. Can I choose which pins to use in my custom board json or are the midi pins fixed?

Hi Ted!

Thank you for the wait.

I believe the SM pins that you can use for MIDI are A8 and A9, which it sounds like you are using.
Please double check that TRS is wired correctly.

As for Oopsy, you may need a custom JSON file.
It should be similar to the patch_init.json file but with "OOPSY_TARGET_HAS_MIDI_OUTPUT": 1 added. I hope this works:

{
	"name": "patch_init",
	"som": "patch_sm",
	"defines":  {
            "OOPSY_TARGET_HAS_MIDI_OUTPUT": 1
        },
	"components": {
		"cv_1": {
			"component": "AnalogControl",
			"pin": "C5",
			"is_default": true
		},
		"cv_2": {
			"component": "AnalogControl",
			"pin": "C4",
			"is_default": true
		},
		"cv_3": {
			"component": "AnalogControl",
			"pin": "C3",
			"is_default": true
		},
		"cv_4": {
			"component": "AnalogControl",
			"pin": "C2",
			"is_default": true
		},
		"cv_5": {
			"component": "AnalogControlBipolar",
			"pin": "C6",
			"is_default": true
		},
		"cv_6": {
			"component": "AnalogControlBipolar",
			"pin": "C7",
			"is_default": true
		},
		"cv_7": {
			"component": "AnalogControlBipolar",
			"pin": "C8",
			"is_default": true
		},
		"cv_8": {
			"component": "AnalogControlBipolar",
			"pin": "C9",
			"is_default": true
		},
		"adc_9": {
			"component": "AnalogControl",
			"pin": "A2",
			"is_default": true
		},
		"adc_10": {
			"component": "AnalogControl",
			"pin": "A3",
			"is_default": true
		},
		"adc_11": {
			"component": "AnalogControl",
			"pin": "D9",
			"is_default": true
		},
		"adc_12": {
			"component": "AnalogControl",
			"pin": "D8",
			"is_default": true
		},
		"gate_out_1": {
			"component": "GateOut",
			"pin": "B5",
			"display": "",
			"is_default": true
		},
		"gate_out_2": {
			"component": "GateOut",
			"pin": "B6",
			"display": "",
			"is_default": true
		},
		"cvout": {
			"component": "CVOuts",
			"is_default": true
		},
		"gate_in_1": {
			"component": "GateIn",
			"pin": "B10",
			"is_default": true
		},
		"gate_in_2": {
			"component": "GateIn",
			"pin": "B9",
			"is_default": true
		},
		"sw1": {
			"component": "Switch",
			"pin": "B7"
		},
		"sw2": {
			"component": "Switch",
			"pin": "B8"
		}
	},
	"aliases": {
		"switch": "sw1",
		"switch1": "sw1",
		"switch2": "sw2",
		"button": "sw1",
		"toggle": "sw2",
		"gate": "gate_in_1",
		"gate1": "gate_in_1",
		"gate2": "gate_in_2",
		"gateout": "gate_out_1",
		"gateout1": "gate_out_1",
		"gateout2": "gate_out_2",
		"cvout": "cvout1",
		"cv_out_1": "cvout1",
		"cv_out_2": "cvout2",
		"led": "cvout2",
		"knob": "cv_1",
		"knob1": "cv_1",
		"knob2": "cv_2",
		"knob3": "cv_3",
		"knob4": "cv_4",
		"knob5": "cv_5",
		"knob6": "cv_6",
		"knob7": "cv_7",
		"knob8": "cv_8",
		"ctrl": "cv_1",
		"ctrl1": "cv_1",
		"ctrl2": "cv_2",
		"ctrl3": "cv_3",
		"ctrl4": "cv_4",
		"ctrl5": "cv_5",
		"ctrl6": "cv_6",
		"ctrl7": "cv_7",
		"ctrl8": "cv_8",
		"cv1": "cv_1",
		"cv2": "cv_2",
		"cv3": "cv_3",
		"cv4": "cv_4",
		"cv5": "cv_5",
		"cv6": "cv_6",
		"cv7": "cv_7",
		"cv8": "cv_8",
		"adc9": "adc_9",
		"adc10": "adc_10",
		"adc11": "adc_11",
		"adc12": "adc_12"
	}
}

By the way, are you compiling and flashing the midi_io.maxpat example?

Thanks for the reply Takumi. I shall double check my wiring but I was messing around with a screwdriver making various connections to test it out and carelessly short circuited the patch sm. I’ll let you know how I get on when I get the replacement. In the midi_io.maxpat, it looks to me like the note out and velocity out are swapped round maybe?

I’m sorry to hear about that. Accidents with screwdriver does happen…

Regarding midi_io.maxpat, I think it does need to be swapped indeed. Thank you for catching that!
We’ll double check and make the changes needed.

Thanks @Takumi_Ogata

Still not having much luck getting midi out from my custom board using a patch SM. I did a little digging in the code today though and found that in the product specific .h / .cpp files “daisy_patch_sm.cpp &.h”, there don’t appear to be any refences to “midi” when searching for it. However some other files such as the one for “patch”, do have midi elements. I then had a look in the code for dsp cofee DPT which I believe is an independently created module with major functionality (including midi out) for the Patch SM and there are some significant bits of code added (see below). This makes me suspect that the patch_sm as it stands would not output midi without adding these sorts of elements to the code. Perhaps the intended route for patch_sm being a eurorack module core, has meant that midi is less of an important feature, but I’m just speculating here so excuse me if I have that all wrong. Anyway I’ll have a go at messing around with this at some point and I’ll let you know how I get on.

InitMidi();

void DPT::InitMidi() {
        /*
        MidiUsbHandler::Config midi_cfg;
        midi_cfg.transport_config.periph = MidiUsbTransport::Config::EXTERNAL;
        usb_midi.Init(midi_cfg);
        */

        // This is using USART1 here
        MidiUartHandler::Config midi_config;
        midi_config.transport_config.rx = DPT::A9;
        midi_config.transport_config.tx = DPT::A8;
        midi.Init(midi_config);
    }

// midi helping stuff yoinked from makingsoundmachines @ electrosmith forum
        void MIDISendNoteOn(uint8_t channel, uint8_t note, uint8_t velocity)
        {
            uint8_t data[3] = {0};

            data[0] = (channel & 0x0F) + 0x90; // limit channel byte, add status byte
            data[1] = note & 0x7F;             // remove MSB on data
            data[2] = velocity & 0x7F;

            midi.SendMessage(data, 3);
        }

        void MIDISendNoteOff(uint8_t channel, uint8_t note, uint8_t velocity)
        {
            uint8_t data[3] = {0};

            data[0] = (channel & 0x0F) + 0x80; // limit channel byte, add status byte
            data[1] = note & 0x7F;             // remove MSB on data
            data[2] = velocity & 0x7F;

            midi.SendMessage(data, 3);
        }

  MidiUartHandler midi;
  MidiUsbHandler usb_midi;

Thank you for looking into this, Ted.
I didn’t know that MIDI was not configured for the SM when using Oopsy, I’m sorry about that.

Yes, please let me know if that code works.
And I just put in my note to bring this all up to the team member who is involved in the Oopsy development.

Hi @teddexter

Were you ever able to get this working? I’d like to use pins D7 and D6 on the patch_sm for midi out and in.

@Takumi_Ogata
Is it possible to use any of the 4 sets of UART_TX/RX pins for midi?

Any help is much appreciated!

Hi, I must admit I gave up on it. I should perhaps have reported back on my lack of success here. Do let me know if you get anywhere with it though.

I just got it working for Arduino using SoftwareSerial. This uses the Arduino MIDI library so I’m not sure how it will translate over to cpp. But I’ve got MIDI notes coming out of pin D7 on the Patch SM! :smiley:

#include <MIDI.h>
#include <SoftwareSerial.h>
using Transport = MIDI_NAMESPACE::SerialMIDI<SoftwareSerial>;
int rxPin = PIN_PATCH_SM_D6;
int txPin = PIN_PATCH_SM_D7;
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
Transport serialMIDI(mySerial);
MIDI_NAMESPACE::MidiInterface<Transport> MIDI((Transport&)serialMIDI);

That’s interesting, but is DaisyDuino what you want to use?
Have you tried the DPT .cpp code, modified for the pins you want?