Skip to content

Commit

Permalink
Begin implementing Kontakt instrument switching
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejGolian committed Oct 17, 2024
1 parent c1b6510 commit 30d2880
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added option to disable the 'window may be covered' warning
- Added Kontakt 8 support
- Added Kontakt instrument switching

### Changed

Expand Down
47 changes: 47 additions & 0 deletions Includes/Overlays/Kontakt7.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Class Kontakt7 {
PluginHeader.AddCustomButton("LIBRARY On/Off",,, Kontakt7.ActivatePluginHeaderButton).SetHotkey("!L", "Alt+L")
PluginHeader.AddCustomButton("VIEW menu",,, Kontakt7.ActivatePluginHeaderButton).SetHotkey("!V", "Alt+V")
PluginHeader.AddCustomButton("SHOP (Opens in default web browser)",,, Kontakt7.ActivatePluginHeaderButton).SetHotkey("!S", "Alt+S")
PluginHeader.AddCustomButton("Previous instrument", Kontakt7.MoveToPluginInstrumentButton,,, Kontakt7.ActivatePluginInstrumentButton).SetHotkey("^P", "Ctrl+P")
PluginHeader.AddCustomButton("Next instrument", Kontakt7.MoveToPluginInstrumentButton,,, Kontakt7.ActivatePluginInstrumentButton).SetHotkey("^N", "Ctrl+N")
PluginHeader.AddCustomButton("Snapshot menu", Kontakt7.MoveToPluginSnapshotButton,,, Kontakt7.ActivatePluginSnapshotButton).SetHotkey("!M", "Alt+M")
PluginHeader.AddCustomButton("Previous snapshot", Kontakt7.MoveToPluginSnapshotButton,,, Kontakt7.ActivatePluginSnapshotButton).SetHotkey("!P", "Alt+P")
PluginHeader.AddCustomButton("Next snapshot", Kontakt7.MoveToPluginSnapshotButton,,, Kontakt7.ActivatePluginSnapshotButton).SetHotkey("!N", "Alt+N")
Expand Down Expand Up @@ -194,6 +196,32 @@ Class Kontakt7 {
}
}

Class ActivatePluginInstrumentButton {
Static Call(InstrumentButton) {
Critical
UIAElement := GetUIAElement("15,1,5")
If Not UIAElement = False And UIAElement.Name = "SHOP" {
Try
ControlGetPos &ControlX, &ControlY, &ControlWidth, &ControlHeight, ReaHotkey.GetPluginControl(), "A"
Catch
Return
Kontakt7.MoveToPluginInstrumentButton("Previous instrument")
If CheckColor() {
Kontakt7.MoveToPluginInstrumentButton(InstrumentButton)
Click
Return
}
}
AccessibilityOverlay.Speak("Instrument switching unavailable. Make sure that an instrument is loaded and that you're in rack view.")
CheckColor() {
MouseGetPos &mouseXPosition, &mouseYPosition
If PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x424142" Or PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x545454"
Return True
Return False
}
}
}

Class ActivatePluginSnapshotButton {
Static Call(SnapshotButton) {
Critical
Expand Down Expand Up @@ -261,6 +289,25 @@ Class Kontakt7 {
}
}

Class MoveToPluginInstrumentButton {
Static Call(InstrumentButton) {
Label := InstrumentButton
If InstrumentButton Is Object
Label := InstrumentButton.Label
UIAElement := GetUIAElement("15,1,5")
If Not UIAElement = False And UIAElement.Name = "SHOP" {
Try
ControlGetPos &ControlX, &ControlY, &ControlWidth, &ControlHeight, ReaHotkey.GetPluginControl(), "A"
Catch
Return
If Label = "Previous instrument"
MouseMove ControlX + ControlWidth - 352, ControlY + 88
Else
MouseMove ControlX + ControlWidth - 332, ControlY + 88
}
}
}

Class MoveToPluginSnapshotButton {
Static Call(SnapshotButton) {
If SnapshotButton Is Object And InStr(SnapshotButton.Label, "Snapshot", True)
Expand Down
47 changes: 47 additions & 0 deletions Includes/Overlays/Kontakt8.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Class Kontakt8 {
PluginHeader.AddCustomButton("LIBRARY On/Off",,, Kontakt8.ActivatePluginHeaderButton).SetHotkey("!L", "Alt+L")
PluginHeader.AddCustomButton("VIEW menu",,, Kontakt8.ActivatePluginHeaderButton).SetHotkey("!V", "Alt+V")
PluginHeader.AddCustomButton("SHOP (Opens in default web browser)",,, Kontakt8.ActivatePluginHeaderButton).SetHotkey("!S", "Alt+S")
PluginHeader.AddCustomButton("Previous instrument", Kontakt8.MoveToPluginInstrumentButton,,, Kontakt8.ActivatePluginInstrumentButton).SetHotkey("^P", "Ctrl+P")
PluginHeader.AddCustomButton("Next instrument", Kontakt8.MoveToPluginInstrumentButton,,, Kontakt8.ActivatePluginInstrumentButton).SetHotkey("^N", "Ctrl+N")
PluginHeader.AddCustomButton("Snapshot menu", Kontakt8.MoveToPluginSnapshotButton,,, Kontakt8.ActivatePluginSnapshotButton).SetHotkey("!M", "Alt+M")
PluginHeader.AddCustomButton("Previous snapshot", Kontakt8.MoveToPluginSnapshotButton,,, Kontakt8.ActivatePluginSnapshotButton).SetHotkey("!P", "Alt+P")
PluginHeader.AddCustomButton("Next snapshot", Kontakt8.MoveToPluginSnapshotButton,,, Kontakt8.ActivatePluginSnapshotButton).SetHotkey("!N", "Alt+N")
Expand Down Expand Up @@ -194,6 +196,32 @@ Class Kontakt8 {
}
}

Class ActivatePluginInstrumentButton {
Static Call(InstrumentButton) {
Critical
UIAElement := GetUIAElement("15,1,5")
If Not UIAElement = False And UIAElement.Name = "SHOP" {
Try
ControlGetPos &ControlX, &ControlY, &ControlWidth, &ControlHeight, ReaHotkey.GetPluginControl(), "A"
Catch
Return
Kontakt7.MoveToPluginInstrumentButton("Previous instrument")
If CheckColor() {
Kontakt7.MoveToPluginInstrumentButton(InstrumentButton)
Click
Return
}
}
AccessibilityOverlay.Speak("Instrument switching unavailable. Make sure that an instrument is loaded and that you're in classic view.")
CheckColor() {
MouseGetPos &mouseXPosition, &mouseYPosition
If PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x424142" Or PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x545454"
Return True
Return False
}
}
}

Class ActivatePluginSnapshotButton {
Static Call(SnapshotButton) {
Critical
Expand Down Expand Up @@ -261,6 +289,25 @@ Class Kontakt8 {
}
}

Class MoveToPluginInstrumentButton {
Static Call(InstrumentButton) {
Label := InstrumentButton
If InstrumentButton Is Object
Label := InstrumentButton.Label
UIAElement := GetUIAElement("15,1,5")
If Not UIAElement = False And UIAElement.Name = "SHOP" {
Try
ControlGetPos &ControlX, &ControlY, &ControlWidth, &ControlHeight, ReaHotkey.GetPluginControl(), "A"
Catch
Return
If Label = "Previous instrument"
MouseMove ControlX + ControlWidth - 352, ControlY + 88
Else
MouseMove ControlX + ControlWidth - 332, ControlY + 88
}
}
}

Class MoveToPluginSnapshotButton {
Static Call(SnapshotButton) {
If SnapshotButton Is Object And InStr(SnapshotButton.Label, "Snapshot", True)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Our changelog can be found [in our dedicated changelog file](https://github.com/
- Works both inside REAPER and in the standalone version of Komplete Kontrol.
* Makes it possible to interact with Kontakt menus.
- Works both inside REAPER and in the standalone version of Kontakt, Full and Player. Note that Kontakt version 7.10 or higher is required.
* Makes it possible to switch Between instruments/NKIs in Kontakt.
- Only works inside REAPER.
* Makes it possible to select and cycle through snapshots in Kontakt.
- Only works inside REAPER.
* Provides support for the 'Browse' button in the Kontakt Content Missing dialog.
Expand Down Expand Up @@ -105,5 +107,4 @@ HotspotHelper is a special utility to make developing these kind of scripts a li

This is an incomplete list of features we're planning to look into in the future or are currently developing. Noone can guarantee that they will ever become reality, but they might at some point, and you can always open an issue to either offer help or request a new entry on this list. This list doesn't necessarily include bugfixes or additional features for entries above, except if they require special treatment and time to investigate them.

* Switching between instruments in Kontakt
* Melodyne accessibility

0 comments on commit 30d2880

Please sign in to comment.