laurence-myers / midi-to-macro

AutoHotKey (AHK) script to map MIDI inputs to keyboard shortcuts or macros
25 stars 4 forks source link

FIXED #2

Closed Brandon203111 closed 1 year ago

Brandon203111 commented 1 year ago

Using it for noteon events instead of CC, and now the "and value !=0) " doesnt seem to cancel the midi controller from triggering on release..... if anybody knows a fix please let me know I don't want to spend 40$ on some software

laurence-myers commented 1 year ago

Here's a demo of how to map "Note On/Off" events for a middle C note.

I use a Novation Nocturn. First, I set up the mapping in my Nocturn, so that button 8 triggers MIDI note #60 (middle C).

2022-11-13 12_49_27-Edit Mapping

Then, I edit the ProcessNote() function in MidiRules.ahk:

ProcessNote(device, channel, note, velocity, isNoteOn) {
    if (note = 60) {
        if (isNoteOn) {
            DisplayOutput("Middle C on", velocity)
        } else {
            DisplayOutput("Middle C off", velocity)
        }
    }
}

This will:

Pressing the button:

2022-11-13 13_00_26-Edit Mapping

Releasing the button:

2022-11-13 13_00_34-Edit Mapping

I hope this helps. If not, please post your MidiRules.ahk so we can see what you've tried.

Brandon203111 commented 1 year ago

Here's a demo of how to map "Note On/Off" events for a middle C note.

I use a Novation Nocturn. First, I set up the mapping in my Nocturn, so that button 8 triggers MIDI note #60 (middle C).

2022-11-13 12_49_27-Edit Mapping

Then, I edit the ProcessNote() function in MidiRules.ahk:

ProcessNote(device, channel, note, velocity, isNoteOn) {
    if (note = 60) {
        if (isNoteOn) {
            DisplayOutput("Middle C on", velocity)
        } else {
            DisplayOutput("Middle C off", velocity)
        }
    }
}

This will:

  • Check if the note is middle C (i.e. it has value 60)
  • Check if it's a "note on" event
  • If it is, display a message in the MidiMonitor, with event "Middle C on" and a value of the note velocity (for me, it will always be 127)
  • If it is note a note on event, i.e. it's a note off event, display a message in the MidiMonitor, with event "Middle C off" and a value of the note velocity (which will always be 0 for a note off)

Pressing the button:

2022-11-13 13_00_26-Edit Mapping

Releasing the button:

2022-11-13 13_00_34-Edit Mapping

I hope this helps. If not, please post your MidiRules.ahk so we can see what you've tried.

First off i have a cheaper version of the novation, i have the launchpad S and from looking at the novation website i don't think there's any software that allows me to reroute the midi that it came with. But here is a picture of my issue, most of my launch keys use "NoteOn" not "CC", so i put "note on" so that the script works, but the "and value != 0" isn't stopping the release from triggering the note. I don't know if there's another way but i don't have a rerouting software like the nocturn

issue

Brandon203111 commented 1 year ago

also here is proof that it just won't let me edit the mapping

image

laurence-myers commented 1 year ago

Sorry for confusing you. My example was for a Nocturn, just to show how I do it with my hardware. Your hardware config will be different, e.g. you don't need Automap.

Please have another look at the example code I posted. The secret is to check isNoteOn. It will be true for a "note on" event, and false for a "note off" event.

In your code, replace value != 0 with isNoteOn. That should do the trick. 🙂

Brandon203111 commented 1 year ago

Sorry for confusing you. My example was for a Nocturn, just to show how I do it with my hardware. Your hardware config will be different, e.g. you don't need Automap.

Please have another look at the example code I posted. The secret is to check isNoteOn. It will be true for a "note on" event, and false for a "note off" event.

In your code, replace value != 0 with isNoteOn. That should do the trick. 🙂

Thankyou! Your help is much appreciated