Jump to content

Using Midi Modifier To Convert Midi Note from one source to Midi CC to another source


luca9583

Recommended Posts

Hi guys

 

I'm running Jam Origin Midi Guitar into Mainstage.

 

I've set up an external midi instrument strip receiving midi from Midi Guitar and going out to Midi Channel 4

 

Is there a way i can use the Midi Modifier to convert one or several notes to CC messages going out to Midi Channel 4?

 

When i select Learn in the Modifier (inserted on the external instrument strip) it doesn't seem to learn the Midi note i'm playing in Midi Guitar

Link to comment
Share on other sites

  • 7 months later...
  • 1 month later...

Thanks a lot for your help. At this point i was hoping to just be able to experiment with different Note to CC conversions but the basic type of conversion i’m after is for a given Note On/Off message to be converted to a CC “On/Off” value of either 0 or 127.

The idea is to use pitch to turn fx on or off in an fx unit that accepts CCs to toggle fx bypass states.

 

For a first attempt, let’s say we want to activate an effect with CC 12 on Midi Channel 4 every time i hit G3 on the guitar. We would need Mainstage to assign a value of 127 on CC 12, Ch 4 every time G3 is played, and a value of 0 for that CC whenever G3 isn’t played.

 

After that i would like various other Midi notes to do the same but on other CCs, because each effect is activated by a different CC

Edited by luca9583
Link to comment
Share on other sites

For a first attempt, let’s say we want to activate an effect with CC 12 on Midi Channel 4 every time i hit G3 on the guitar. We would need Mainstage to assign a value of 127 on CC 12, Ch 4 every time G4 is played, and a value of 0 for that CC whenever G4 isn’t played.

 

Just for clarification (not sure if this is a typo):

 

Do you want to turn on the effect with G3 (or G4?) and then turn it off with another note; or do you want to turn the effect on when the note is played and turn it off when it is released?

Link to comment
Share on other sites

I've attached a very basic concept (that might not work with your setup, but stay with me for a moment).

 

Setting goes into ~/Music/Audio Music Apps/Plug-In Settings/Scripter/

 

Call up the Scripter plugin in the external MIDI channel strip that you want to control your effect with. Load the "Note to Control concept" setting. In theory playing a G3 will send ctrl 12, 127 and stopping to play it will send ctrl 12, 0. No other data are sent or passed by the plugin at the moment.

 

This works fine here when using a keyboard; here are a couple of things that might go wrong:

 

Assumption is that C4 = 60 hence G3 = 55. There might be an octave shift with some devices.

The script is assuming that Note Off is a REAL Note Off and not a Note On with Velocity = 0. If the latter is the case then ctrl 12, 127 will be sent twice (once for the beginning for the note and once for the end).

 

Should any of this happen it would be trivial to fix.

Let me know if this is going in the direction you envisioned.

 

Note to Control concept.pst

Link to comment
Share on other sites

Happy to hear it works. Feel free to ask if you have further questions; this was more or less just a first concept. Depending on the complexity of the things you want to achieve there might be other approaches.

I don't really know how much latency those scripts introduce. Essentially it's JavaScript (I think) so there might be a small tradeoff performance-wise. On the other hand the script in its current form is very small and rather straightforward so even adding more notes and controllers might not make much of a difference.

Link to comment
Share on other sites

  • 1 month later...

The script could be written any way you want it.

When I posted it I was assuming that you either modify it yourself to your needs or that you tell me more about the requirements so that I could do it (or perhaps modify it so that you could simply input the desired values into a couple of fields).

Link to comment
Share on other sites

The script could be written any way you want it.

When I posted it I was assuming that you either modify it yourself to your needs or that you tell me more about the requirements so that I could do it (or perhaps modify it so that you could simply input the desired values into a couple of fields).

 

Brilliant. In that case the last thing i want to do is to add 7 more CC events to the current script so that when Note 55 = On, Midi CCs 3, 4, 5, 6, 7, 8, 9, 10 all = 127 (or any value which i will then modify) and when Note 55 = Off, all of those Midi CCs = 0 (or again any value).

 

All i need to know is how to add more CC events correctly to the script. I tried to paste the same event several times in the script but i’m sure the punctuation or method is wrong.

Link to comment
Share on other sites

Something like this?

Let me know if you need additional modifications or if I should explain how the code is working. There is probably still some room for optimization and clarity.

 

Thanks so much again..this is fantastic. Apologies..i actually made an error in the wording of my request and should have made it more clear. I just need to modify this new script so that each of those CCs can have their own On/Off values:

 

Note 55 = On,

CC 3 = 22

CC 4 = 30

CC 5 = 50

CC 6 = 48

CC 7 = 39

CC 8 = 120

CC 9 = 123

CC 10 = 69

 

Note 55 = Off,

CC 3 = 0

CC 4 = 49

CC 5 = 19

CC 6 = 20

CC 7 = 39

CC 8 = 50

CC 9 = 0

CC 10 = 0

 

The values for each CC are just an example which i can then modify.

Link to comment
Share on other sites

  • 1 year later...

Hello guys, 

Do you if it could possible ton convert notes to specific number of a cc ? 

For example, send the 

C3 would be transformed intro midi CC 21 with a value of 25

C#3 would be transformed intro midi CC 21 with a value of 28

D3 would be transformed intro midi CC 21 with a value of 35

Any idea ? It could be a dream for me.

Thank a lot,

Nicolas

 

Link to comment
Share on other sites

I tried that for one note but it's not working

 

V¸GAMETSPP.TSCS'bplist00_Òfunction HandleMIDI(event) {
    var cc = new ControlChange;
        cc.channel = 1;
    
     if (event instanceof NoteOn) { 
    
        if (event.pitch == 55)    {
                cc.number = 21;
             cc.value = 64;
               cc.send();
                } 
    }
}

Link to comment
Share on other sites

Works fine here. Not sure if that "gibberish" in front of "function HandleMIDI(event)" is throwing things off - without it it's running fine.

Add a "Trace(event)" near the top and a "Trace(cc)" before cc.send() to check if actual MIDI data is getting to the script and of course also out of it.

function HandleMIDI(event) {
	var cc = new ControlChange;
	Trace(event);
    cc.channel = 1;
    
     if (event instanceof NoteOn) { 
    
        if (event.pitch == 55)    {
                cc.number = 21;
             cc.value = 64;
             Trace(cc);
             cc.send();
             } 
    }
} 

When pressing G2 on my keyboard I'm getting

[NoteOn channel:1 pitch:55 [G2] velocity:85]
[ControlChange channel:1 number:21 [Ctrl 21] value:64]
[NoteOff channel:1 pitch:55 [G2] velocity:64]

in the console - as expected. MIDI data is also sent as expected.

Link to comment
Share on other sites

Gacki, 

First of all a big thank you for your answer ! 

In theory it works perfectly but in fact it doesn't work for what I'm trying to do.

I want to have real-time midi transpose with my input midi.

It is working with the "transposer" midi effect plugin, and the trick is I want to use it  in real time with a keyboard.

So if I put a "midi modifier" midi effect plugin plugin before the "midi transpose" one, it's working.

I tried to use the midi cc value in the input of the midi modifier, sending to the transpose function of the transposer and it's just perfect. But I want to use a midi keyboard input, not midi CC. 

The right thing to do I think is putting "note number" in the input of the modifier plugin and that's working well. 

I would like to press C2 (note number 40) to have the value 0 of the transposer plugin, press C#2 to have the value 1 of the transposer, D2 to the value 2 etc...

So I need a kind of midi mapping :

If I press C2 on my keyboard, the script should send C#3 to the modifier, because C#3 is sending value O of the transposer. 

So to be simple, the script should tell :

If note number is 48, it should send the note number 64

If note number is 49, it should send the note number 67

If note number is 50, it should send the note number 69

If note number is 51, it should send the note number 71

Cheers !

 

 

 

 

 

Capture d’écran 2022-11-13 à 14.40.29.jpg

Link to comment
Share on other sites

I'm still trying to parse this.

What precisely are you trying to accomplish here? Is the Transposer plugin really important for this; or is this straight transposition (without scale mapping)? If it's straight transposition it can easily be done within Scripter itself - or in a combination of Scripter and Transposer

Your idea of using note numbers (and re-mapping it on the fly to control Transposer) has the drawback that the Transposer plugin will react to all other keys that are pressed as well. So the Scripter might turn note number 48 into note number 64; however the Transposer will also react when you actually press note number 64 (or any other key). Your initial idea of using a controller instead sounds better to me - here you could use Scripter to send specific controllers with specific values for for a handful of keys only; and the rest is not affected.

 

Link to comment
Share on other sites

Thank you Gacki for your message.

yes Iit's just straight transposition I need.

The inconvenient for me with the first code you gave me is it's working perfectly except I'm sending too notes into the sequencer, so the notes are sent with the controller value.

I just want to transpose my midi sequence without the note I'm sending and the transpose is made by the logic midi transpose effect before the logic pattern sequencer in my mani window.

The controller value transpose the logic pattern sequence in the main window but with that script I'm sending a note too and I want that note to be bypassed.

I need the notes "bypassed" and only the value of the controller sent by the script into the transpose effect. In this case everything should work perfectly 🙂

I hope I'm clear. Cheers

Link to comment
Share on other sites

1 minute ago, Pale Shelter said:

Thank you Gacki for your message.

 

The goal is that 

- I have a "Logic pattern sequence" playing in my grid

- I transpose that sequence with my external midi keyboard

 

1 minute ago, Pale Shelter said:

 

To answer you, it's just straight transposition I need.

The inconvenient for me with the first code you gave me is it's working perfectly except I'm sending too notes into the sequencer, so the notes are sent with the controller value.

I just want to transpose my midi sequence without the note I'm sending and the transpose is made by the logic midi transpose effect before the logic pattern sequencer in my mani window.

The controller value transpose the logic pattern sequence in the main window but with that script I'm sending a note too and I want that note to be bypassed.

I need the notes "bypassed" and only the value of the controller sent by the script into the transpose effect. In this case everything should work perfectly 🙂

 

I hope I'm clear. Cheers

Quote

 

 

Link to comment
Share on other sites

39 minutes ago, Pale Shelter said:

The goal is that 

- I have a "Logic pattern sequence" playing in my grid

- I transpose that sequence with my external midi keyboard

Got it.

I suspect the problem is not so much with notes being sent from the keyboard and getting passed to the track - my initial script explicitely did NOT do this (it's only output was/is the controller; note commands are not passed).

However in your scenario the MIDI output of the track is also being passed through the script - in fact it needs to be passed through the Scripter (or other MIDI FX) to reach the actual plugin. Meaning that any notes in the sequence must not be the notes that also control transposition, otherwise those notes will automatically transpose the MIDI data.

Here's the script as I understand it right now:

function HandleMIDI(event) {
	var cc = new ControlChange;
	Trace(event);
    cc.channel = 1;
    cc.number = 21;
    
     if (event instanceof NoteOn) {
         
        if (event.pitch == 48)    {
             cc.value = 64;
             Trace(cc);
             cc.send();
             } 
		else if (event.pitch == 49)    {
             cc.value = 67;
             Trace(cc);
             cc.send();
             } 
		else if (event.pitch == 50)    {
             cc.value = 70;
             Trace(cc);
             cc.send();
             } 
		else if (event.pitch == 51)    {
             cc.value = 73;
             Trace(cc);
             cc.send();
             } 
        else	{
        		event.send();
        	}  
    }
} 

(I have no idea why the formatting looks that bad - in the editor it looks fine.)

Right now the script will pass all notes coming from either the keyboard or from the sequence - except notes 48 to 51 which will send controller 21 instead. If the sequence contains other data that also should be sent the script needs a small modification.

All the Trace commands can probably be deleted.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...