How to change Midi CC to aftertouch in midi machine

I don’t want to use the aftertouch option (using velocity) but use an expression-pedal to control aftertouch in an addressed synth.
In some DAWs I can do that with a midi-transformer but not in all. So I would like to do that in MidiGuitar to be independent from DAWs or standalone-synth.

I did this so far but no result:
function OnNote(channel, pitch, velocity)
– for any note played, send out the exact same note
Note(channel, pitch, velocity)

function OnControl(channel, cc, value)
– Control(2, 20, value) --this works when I move the expression pedal
AfterTouch(channel, 60, value) --this does not send out aftertouch when I move the expression pedal

function OnFrame(notes)

function OnStart(info)
– assign a description to be displayed in the header
info.description = “transforms midi CC to aftertouch”

you may need to swtich the aftertouch on in the interface. and block this original aftertouch…

The idea is to convert cc to aftertouch.
The aftertouch option in the interface converts velocity to aftertouch as I understand it.
There is a midi-machine example of converting aftertouch to cc, so I thought it would be possible the other way around.
But I seems not to work the way I scripted it. I also tried with enabled aftertouch option in the interface.
I thought if I send AfterTouch(channel, 60, value) I would just do that.

it kind of works this way with pitchbend, so I thought maybe would this also work with aftertouch. I have indeed never wanted to convert from cc to aftertouch ( I actually added the aftertouch2cc at the time)
Maybe try to echo the existing OnAftertouch data first, and try mod that. I never tested the aftertouch() function…

I think it could be a good feature.
I played around with Arturia Analog Lab V presets. A lot of them have cool aftertouch settings.
To have this controlled with MG2/aftertouch = velocity is confusing as there are also parameters assigned to velocity on those presets.
Therefore to have a pedal sending CC11 being converted to aftertouch would separate velocity from aftertouch.
The aftertouch() is mentioned in the “Demo Script.lua” so I guess it is supported.
Thanks for your reply.

I found this page:
Here it says that the aftertouch functions are not implemented yet.
Is this still true?
Why is it in the “Demo Script.lua” ?

I dont know, I made that demo script spontaneously, I never checked the function aftertouch() because nobody asked for it at that time. I was workign for JO at that time, I quit in oktober 2020. The midi-machine web page was never complete (and I wasnt the web editor), so I auctually didnt look there at all.

  • enable aftertouch in MG
  • make sure your controller sends on the CC channel

-- Paul D 2023

-- our global stack:

function OnNote(channel, pitch, velocity)
	Note(channel, pitch, velocity)   -- alters every incomcing note message

function OnBend(channel, pitch, bend)
	Bend(channel, pitch, bend)       -- alters every incoming bend message     

function OnControl(channel, cc, value)
    if(CC==cc) then
       touch = value   -- store cc value
	Control(channel, cc, value)     

function OnAfterTouch(channel, pitch, velocity)
  AfterTouch(channel, pitch, touch) -- swap actual aftertouch value with CC value..

function OnFrame(notes)

function OnStart(info)
	info.description = "CC TO AFTERTOUCH" = ""
    Knob("CC", 0, 1, 127, 1)                      

1 Like

Hi Paul,

Thank you for thinking about this thread.
It is not working here. Just sending out the incoming CC.
I can’t see when and how the OnAftertouch() should be called.
There is no aftertouch received but Control.
I had tried before seeing your solution for the sostenuto to do the same in OnFrame but couldn’t get it working.

aftertouch in mg should be switched on, then the normal OnAftertouch is called. But the AfterTcuch() there uses the value the CC controller provided (touch)
The AfterTouch is only send when a note is sounding! It can not be send without the note known upon which it should act.

1 Like

Aah. I get it. Works now.
Thank you.

The AfterTouch looks like Poly-Pressure(aftertouch) because of the pitch-value. Some Synth only understand Channel-Pressure. Is there also a possibility to send channel-pressure?

1 Like

well, it IS poly aftertouch here… :wink:
there is currently no way to generate channel pressure in MG

1 Like