DIYstompboxes.com

DIY Stompboxes => Digital & DSP => Topic started by: Steviebabes on February 11, 2019, 03:56:58 PM

Title: Midi CC to PC switching interface
Post by: Steviebabes on February 11, 2019, 03:56:58 PM
Hi,

Has any one built or considered building a CC to PC converter?

I've got a Boss GT 100 and it can only send PC changes when you select a patch.
My Blackstar Series One Amp happily receives PC changes.

The Boss can send CC messages from within a patch  and what I'd like to do though is change amp channels from within a patch.

It can be done with a Midi Solutions Event Processor (http://midisolutions.com/prodevp.htm)

It would be quite nice to do it as DIY box on something like an Ardurino :)

Can anyone point me in the right direction??

Thanks in advance
Title: Re: Midi CC to PC switching interface
Post by: ElectricDruid on February 11, 2019, 06:08:31 PM
That should be simple to do with an Arduino. You'd need a MIDI shield of some sort (haven't looked, but there must be plenty of those). There's certainly library functions that do most of the MIDI nitty-gritty for you. After that, it'd be a question of keeping track of what's coming in, spotting the message(s) you're interested in, and sending the other one(s) instead.

Eminently do-able. Go for it.

HTH,
Tom
Title: Re: Midi CC to PC switching interface
Post by: Ben N on February 12, 2019, 03:46:10 AM
... You'd need a MIDI shield of some sort (haven't looked, but there must be plenty of those).
Easy enough to roll your own, too. Coupla 5-pin jacks, optocouplers, and resistors, and a bit of perfboard, and wahla.
Title: Re: Midi CC to PC switching interface
Post by: potul on February 12, 2019, 08:40:58 AM
It's a perfect project for a small arduino. You don't even need any shield, just some resistors and an optocoupler will do the trick.
There are a couple of MIDI libraries ready to be used that you can grab.
You can take my MIDI Switcher project as a starting point, and change the relay control for a MIDI OUT function. The hardware is even there (both MIDI OUT and IN), although I only used MIDI IN in the software

https://www.diystompboxes.com/smfforum/index.php?topic=112424.0 (https://www.diystompboxes.com/smfforum/index.php?topic=112424.0)

I can help with the software changes, drop me a message if you want me to help.

Mat
Title: Re: Midi CC to PC switching interface
Post by: ElectricDruid on February 12, 2019, 03:29:19 PM
... You'd need a MIDI shield of some sort (haven't looked, but there must be plenty of those).
Easy enough to roll your own, too. Coupla 5-pin jacks, optocouplers, and resistors, and a bit of perfboard, and wahla.

It is indeed. The general IN/OUT/THRU schematic looks like this:

https://electricdruid.net/wp-content/uploads/2016/04/MIDISchematic-3.jpg (https://electricdruid.net/wp-content/uploads/2016/04/MIDISchematic-3.jpg)

Title: Re: Midi CC to PC switching interface
Post by: Steviebabes on February 12, 2019, 05:54:28 PM
Hi Guys,

Thanks in advance for the offers of help  - I've ordered some bits and will be back in touch when they arrive :)

I'm a bit confused, will I need the opto - isolators or can the Midi sockets connect straight on to the board?

Steve
Title: Re: Midi CC to PC switching interface
Post by: ElectricDruid on February 13, 2019, 08:47:00 AM
In order to meet the MIDI spec, the IN needs an optoisolator. Since all MIDI Inputs are opto-isolated, there's no need for outs or thrus to have optos.

In fact, you can wire a MIDI OUT from a processor with just a plug and a couple of resistors. It can be fantastically simple. The IN circuit is always more complicated.

HTH,
Tom
Title: Re: Midi CC to PC switching interface
Post by: potul on February 13, 2019, 10:32:21 AM
Hi Guys,

Thanks in advance for the offers of help  - I've ordered some bits and will be back in touch when they arrive :)

I'm a bit confused, will I need the opto - isolators or can the Midi sockets connect straight on to the board?

Steve

You need it for MIDI IN. Take a look at my project, you have a midi in and out already there using a 6n138 opto. With this and 4 resistors you have both midi in and out setup.

(http://i471.photobucket.com/albums/rr74/mateu_ros/midiswitch.jpg)
Title: Re: Midi CC to PC switching interface
Post by: Willypp on June 29, 2020, 09:57:17 PM
This is something I'm massively interested in.  I have a Boss MS-3 and can only send PC changes on patch changes too.  Some devices like the Iridium and Neuron can accept a full range of CC# to control pretty much anything, but I'm looking at a Mooer Preamp Live which only accepts PC....
Title: Re: Midi CC to PC switching interface
Post by: potul on July 02, 2020, 02:16:38 AM
If I understand it right, you need a device that converts PC messages into CC messages, right?

Take into account that PC messages do not have any parameter, while CC messages have a 0-127 parameter... so it's not really a direct match, you will need to define what CC number AND CC value to use for each PC.

Do you have this clear?
Title: Re: Midi CC to PC switching interface
Post by: Willypp on July 02, 2020, 07:28:48 PM
Other way around, sorry.

I want to send something on, say, CC16, with a value of y, and convert it to a PC with the same value of y.

So CC16, 1, would become PC1
Title: Re: Midi CC to PC switching interface
Post by: potul on July 03, 2020, 03:25:01 AM
This code should do the trick.  Any incoming CC messages in controller number 16 will generate a PC message.
I haven't tested it myself, but it should work as is.

Code: [Select]
#include <MIDI.h>

#define CCNUMBER 16   //The CC number that will be monitored and converted to PC messages

MIDI_CREATE_DEFAULT_INSTANCE();

// -----------------------------------------------------------------------------
// This function will be automatically called when a CC message is received.
// if the CC number matches CCNUMBER confifured above, it will send a PC message
// with the program number matching the CC value, and using the same MIDI channel.

void handleCC(byte channel, byte number, byte value)
{
   if (number==CCNUMBER){
    MIDI.sendProgramChange(value,channel);
   }
}

// -----------------------------------------------------------------------------

void setup()
{
    // Connect the handleCC function to the library,
    // so it is called upon reception of a CC message
    MIDI.setHandleControlChange(handleCC);  // Put only the name of the function

    // Initiate MIDI communications, listen to all channels
    MIDI.begin(MIDI_CHANNEL_OMNI);
}

void loop()
{
    // Call MIDI.read the fastest you can for real-time performance.
    MIDI.read();

}
Title: Re: Midi CC to PC switching interface
Post by: Willypp on July 03, 2020, 05:01:34 AM
Holy hell.... that was quick, and fairly simple.  Wow.  Thanks heaps. I'm just waiting for my arduino stuff to arrive and I'll give it a crack.
Title: Re: Midi CC to PC switching interface
Post by: Willypp on July 09, 2020, 07:18:25 AM
Well, the code has compiled and uploaded ok.  Going to hook up all the other stuff around it and see if I can't mess this up.
Title: Re: Midi CC to PC switching interface
Post by: Willypp on July 13, 2020, 09:18:31 PM
Ok, I have a little black box with this layout all hooked up - but - does Pin 2 on the Midi In need to go to Pin 2 on the Midi Out?
Title: Re: Midi CC to PC switching interface
Post by: potul on July 14, 2020, 03:04:58 AM
No

Midi In pin 2 is left unconnected, and Midi OUT pin 2 is connected to ground. Something like this:



(https://i.postimg.cc/w71TMK1r/perotti-schematics.jpg) (https://postimg.cc/w71TMK1r)
Title: Re: Midi CC to PC switching interface
Post by: Willypp on August 01, 2020, 08:36:55 AM
Well, I've built it.  I'm just waiting for another midi patch cable and my Mooer Preamp Live to arrive...


(https://i.postimg.cc/ZBzVf0RW/116711525-3444329918962987-7584811954615197691-o.jpg) (https://postimg.cc/ZBzVf0RW)
Title: Re: Midi CC to PC switching interface
Post by: ElectricDruid on August 02, 2020, 07:28:05 PM
(https://i.postimg.cc/ZBzVf0RW/116711525-3444329918962987-7584811954615197691-o.jpg) (https://postimg.cc/ZBzVf0RW)

Very tidy! Nice work.

Tom

Title: Re: Midi CC to PC switching interface
Post by: Willypp on August 15, 2020, 06:36:33 AM
My build doesn't seem to be working, it doesn't even pass PC commands atm (the midi works if I connect directly from MS-3 to Mooer Preamp Live).  I have another nano I'll have a crack with, but I also have a Uno midi shield and Uno on the way to try.  I've probably got my pins hooked up wrong or something.
Title: Re: Midi CC to PC switching interface
Post by: ElectricDruid on August 15, 2020, 11:49:13 AM
Have you got some way you can get the MIDI output into the computer? A MIDI monitor program is invaluable for MIDI debugging.

I once got stuck for days with some MIDI code. It was sending bytes, but nothing was being understood at the other end. Eventually when I thought to feed it to a MIDI monitor I discovered all the byte values were wrong - I'd been sending the data back to front!!
Title: Re: Midi CC to PC switching interface
Post by: pruttelherrie on August 15, 2020, 01:37:01 PM
Have you tested reception and sending individually?
Sprinkle some println()'s throughout the code to monitor incoming and outgoing values, to make sure that part is ok.

[edit] oh wait, it's a Nano with only one serial port which is already used for the MIDI port, that won't work. Can you add LEDs to blink upon reception/forwarding?
Title: Re: Midi CC to PC switching interface
Post by: Willypp on August 15, 2020, 08:31:04 PM
IT WORKS!!!! IT WORKS!!!

I'd soldered midi in 4 to midi in 5 on the plugs and vice versa for the midi out plug, and now it's working exactly as I wanted.
Title: Re: Midi CC to PC switching interface
Post by: potul on August 18, 2020, 04:57:04 PM
I was about to writ this: "90% of the time my MIDI devices don't work, I misconnected pins 4 and 5"

But I see you already figured it out. It's not always trivial to see which is which in the diagrams you find on the web.

I'm glad to see it's working. Welcome to the MIDI madness.
Title: Re: Midi CC to PC switching interface
Post by: ElectricDruid on August 19, 2020, 01:53:24 PM
It's not always trivial to see which is which in the diagrams you find on the web.

+1 This! It's amazing how many different ways there are of interpreting "back" and "front" in a simple diagram of a MIDI socket or plug!!
Title: Re: Midi CC to PC switching interface
Post by: pruttelherrie on August 20, 2020, 06:27:54 AM
It's not always trivial to see which is which in the diagrams you find on the web.

+1 This! It's amazing how many different ways there are of interpreting "back" and "front" in a simple diagram of a MIDI socket or plug!!
+1. Happens to me all the time...

Some of the sockets/plugs have the numbering embossed in the plastic, but not all of them.