#027 Melodics controller [EN]
What is Melodics
Short description - this is app to learn how to play on MIDI keyboard, pad controller or electronic drum kit. More info - https://melodics.com/.
Why additional controller?
Because I hate to rotate myself to control app via PC. On melodics there is only one “hidden” shortcut from eDrum - but only for “repeat”/”play”. Shortcuts from Keyboard - https://melodics.com/support-articles/support-keyboard-shortcuts.
This is my setup right now:
You can see “DNA EasyPad” MIDI controller mounted on the wall - this is my controller for Melodics.
Now I can control almost everything via drumsticks.
How?
There is additiona app in background to convert MIDI signals from pad to:
- keyboard keys
- mouse clicks on selected position
- “scripts” - for example multiple clicks
What can I do?
Right now I can simulate:
- “space” key - to enter song/restart
- “esc” key - to exit song
- click in “retry” button after song
- click in “exit” button after song
- click in “play lesson” in course view
- arrows to select songs from menu
- multiple clicks to enter “autoBPM” mode with 2or3 start and ~60% start BPM
- click in “performance mode” button from “practice mode”
- increase/decrease BPM
But you can easily add new options.
Instruction
Basic installation and device buttons mapping
Download and install AHK (AutoHotKey) - https://www.autohotkey.com/ - this is tool for automation/scripting with option to integrate with MIDI devices.
Download scripts: https://gitlab.com/embedownik/melodicscontroller. This is my modified version of general MIDI to hotkey app - author’s site: https://github.com/genmce/AHK_Midi2Keypress
We need to check if out device is ok and create list of midi “buttons” IDs.
Connect device to your PC.
Run file “Midi2Keypress_1.0.ahk” via AHK application. In case of first start - we need to select device - click OK.
Select your device from the list and click “Done - Reload” - in my case this is “W-PAD”.
After restart you will see only “MidiMonitor” Window - click some buttons on pad and check result:
Now - prepare some notes about buttons to buttonID mapping - this is field “data1”.
Important note - there are 2 different types of buttons/events - “NoteOn” and “CC” (control).
My mapping for DNA EasyPad:
Create data for Melodics
Informations about MIDI key to action mappins are inside “userKeysActions.ahk” file - do not edit others files - this is separated file for “users”.
You can open and check content via notepad on windows.
But first - just basic file for test - replace actual content with this (copy-paste and save) + restart “Midi2Keypress_1.0.ahk” application:
; "wrapper" - simple logic to get only "pressed" events
; and separate to Pads/Control buttons
userKeysActions(stb, data1, data2)
{
if(stb = "NoteOn" and data2 != "0")
{
MsgBox % "TEST - button numer " . data1 . " clicked!"
}
}
Test result:
Test + simulate single keypress
Now replace content of “userKeysActions.ahk” with another test script - this is only for “space” key simulation (remember to restart “Midi2Keypress_1.0.ahk” app):
; buttons IDs:
testSpacePadId := 39
; "wrapper" - simple logic to get only "pressed" events
; and separate to Pads/Control buttons
userKeysActions(stb, data1, data2)
{
/*
Availaible variables:
stb -> "NoteOn"/"NoteOff"/"PC"
data1 -> button indicator
data2 -> in case of Note - "VELEOCITY"
in case of CC - 127 means pressed
0 means released
*/
; only when melodics is started
#If WinActive("ahk_exe Melodics.exe")
{
if(stb = "NoteOn" and data2 != "0")
{
clickPads(data1)
}
}
}
clickPads(button)
{
global testSpacePadId
switch button
{
case testSpacePadId:
{
send, {space}
return
}
}
}
This is “ready to use” script with only one feature - simulate “space” key - you need to change “39” on line 2 with your selected button ID. The rest of a file is necessary to react only to “pressed” events and only in Melodics application.
Line “send, {space}” is our action.
So, if you want to add another action - now with “Esc” key - you need to modify file this way:
; buttons IDs:
testSpacePadId := 39
testEscPadId := 40
; "wrapper" - simple logic to get only "pressed" events
; and separate to Pads/Control buttons
userKeysActions(stb, data1, data2)
{
/*
Availaible variables:
stb -> "NoteOn"/"NoteOff"/"PC"
data1 -> button indicator
data2 -> in case of Note - "VELEOCITY"
in case of CC - 127 means pressed
0 means released
*/
; only when melodics is started
#If WinActive("ahk_exe Melodics.exe")
{
if(stb = "NoteOn" and data2 != "0")
{
clickPads(data1)
}
}
}
clickPads(button)
{
global testSpacePadId, testEscPadId
switch button
{
case testSpacePadId:
{
send, {space}
return
}
case testEscPadId:
{
send, {Esc}
return
}
}
}
Quite simple.
Simulate clicks
For click simulation - we need to check click location (in pixels).
There is additional tool in AHK - “Window Spy” for such informations.
To open “Window Spy” - right click on “AHK” icon in windows toolbar and select “Window Spy”:
Now open melodics and check position for some button - in this example - for “playground mode”:
Get data from MousePosition/Window.
Example content of “userKeysActions.ahk” with only onle click - for testing:
; buttons IDs:
testClickPadId = "39"
; "wrapper" - simple logic to get only "pressed" events
; and separate to Pads/Control buttons
userKeysActions(stb, data1, data2)
{
/*
Availaible variables:
stb -> "NoteOn"/"NoteOff"/"PC"
data1 -> button indicator
data2 -> in case of Note - "VELEOCITY"
in case of CC - 127 means pressed
0 means released
*/
; only when melodics is started
#If WinActive("ahk_exe Melodics.exe")
{
if(stb = "NoteOn" and data2 != "0")
{
clickPads(data1)
}
}
}
clickPads(button)
{
switch button
{
case testClickPadId:
{
Click, 1710 117
return
}
}
}
Simulate multiple clicks
Get positions of multiple buttons and insert Clicks one by one with additional “delay” - so for multiple clicks in the same button content of “clicksPads” will be:
clickPads(button)
{
switch button
{
case testClickPadId:
{
Click, 1710 117
sleep, 1000
Click, 1710 117
sleep, 1000
Click, 1710 117
sleep, 1000
Click, 1710 117
sleep, 1000
return
}
}
}
Number after sleep - time to wait in miliseconds - this is necessary because of Melodics animations.
Control buttons
If case of actions for CC - there is one difference - you need to use function “clickControl” instead of “clickPads” - check my original “userKeysActions.ahk” for reference.
Summary
Now you can control Melodics via addtional MIDI device.
Simple demonstration: https://youtu.be/Xiy68o9aUl4.
Unfortunately - right now I don’t know how to use the same device for Melodics and as controller :/
With midi controller with 2x6 pads you can run just basic functions - in case of 2x10 i recomment to add also keys for “set loop” in practice mode - so I need to buy bigger version.