|
34 | 34 | print("macOS detected. Imported _dummy_thread module.") |
35 | 35 | import lib._dummy_thread as _thread |
36 | 36 |
|
| 37 | + |
37 | 38 | ###################################################################################################################### |
38 | 39 | # User-editable constants for script customization |
39 | 40 | # Edit this ones to make the script act as you wish |
@@ -84,15 +85,14 @@ def updateMixerTracks(dataType: str, selectedTrack: int): |
84 | 85 | # If the selected track belongs to the 16th group, it will declare the last two tracks as non existant |
85 | 86 | # Otherwise, it will declare all as existant |
86 | 87 | if trackGroup == 15: |
87 | | - for x in range(trackFirst, trackFirst + 8): |
88 | | - nihia.mixerSendInfo("EXIST", 0, value=1) |
89 | | - nihia.mixerSendInfo("EXIST", 1, value=1) |
90 | | - nihia.mixerSendInfo("EXIST", 2, value=1) |
91 | | - nihia.mixerSendInfo("EXIST", 3, value=1) |
92 | | - nihia.mixerSendInfo("EXIST", 4, value=1) |
93 | | - nihia.mixerSendInfo("EXIST", 5, value=1) |
94 | | - nihia.mixerSendInfo("EXIST", 6, value=0) |
95 | | - nihia.mixerSendInfo("EXIST", 7, value=0) |
| 88 | + nihia.mixerSendInfo("EXIST", 0, value=1) |
| 89 | + nihia.mixerSendInfo("EXIST", 1, value=1) |
| 90 | + nihia.mixerSendInfo("EXIST", 2, value=1) |
| 91 | + nihia.mixerSendInfo("EXIST", 3, value=1) |
| 92 | + nihia.mixerSendInfo("EXIST", 4, value=1) |
| 93 | + nihia.mixerSendInfo("EXIST", 5, value=1) |
| 94 | + nihia.mixerSendInfo("EXIST", 6, value=0) |
| 95 | + nihia.mixerSendInfo("EXIST", 7, value=0) |
96 | 96 |
|
97 | 97 | else: |
98 | 98 | for x in range(trackFirst, trackFirst + 8): |
@@ -158,8 +158,8 @@ def updateMixerTracks(dataType: str, selectedTrack: int): |
158 | 158 |
|
159 | 159 | # Checks the track group once more to clean up the last two tracks |
160 | 160 | if trackGroup == 15: |
161 | | - |
162 | 161 | if dataType == "NAME": |
| 162 | + nihia.mixerSendInfo("NAME", 6, info="") |
163 | 163 | nihia.mixerSendInfo("NAME", 7, info="") |
164 | 164 |
|
165 | 165 | # Track 7 --> Current |
@@ -324,6 +324,39 @@ def updatePeak(selectedTrack: int): |
324 | 324 | nihia.mixerSendInfo("PEAK", 0, peakValues = peakList) |
325 | 325 |
|
326 | 326 |
|
| 327 | +def detectDevice(): |
| 328 | + """ Gets the MIDI device name from FL Studio and sets `DEVICE_SERIES` to the right value in order for the script to work properly. """ |
| 329 | + |
| 330 | + # Imports DEVICE_SERIES from the global scope |
| 331 | + global DEVICE_SERIES |
| 332 | + |
| 333 | + # Retrieves the device name from FL Studio |
| 334 | + deviceName = device.getName() |
| 335 | + |
| 336 | + # Saves the 22th character of the device name for the S-Series check to isolate the extraction and avoid errors stopping the execution of the script |
| 337 | + char21 = None |
| 338 | + try: |
| 339 | + char21 = deviceName[21] |
| 340 | + except: |
| 341 | + char21 = None |
| 342 | + |
| 343 | + # Sets DEVICE_NAME depending on the retrieved name |
| 344 | + if deviceName == "Komplete Kontrol A DAW": |
| 345 | + DEVICE_SERIES = "A_SERIES" |
| 346 | + print("Detected device: Komplete Kontrol A-Series") |
| 347 | + |
| 348 | + elif deviceName == "Komplete Kontrol M DAW": |
| 349 | + DEVICE_SERIES = "M_SERIES" |
| 350 | + print("Detected device: Komplete Kontrol M-Series") |
| 351 | + |
| 352 | + elif char21 == "-": # Gets the 18th char on the name to see if it matches the "Komplete Kontrol DAW - X" naming scheme S-Series devices follow |
| 353 | + DEVICE_SERIES = "S_SERIES" |
| 354 | + print("Detected device: Komplete Kontrol S-Series") |
| 355 | + |
| 356 | + else: |
| 357 | + print("Device detection failed. Going with the manually specified device on the script:", DEVICE_SERIES) |
| 358 | + |
| 359 | + |
327 | 360 | ###################################################################################################################### |
328 | 361 | # Button to action definitions |
329 | 362 | ###################################################################################################################### |
@@ -753,7 +786,9 @@ def OnMidiIn(event): |
753 | 786 | ###################################################################################################################### |
754 | 787 |
|
755 | 788 | def OnInit(): |
756 | | - |
| 789 | + # Detects the device the script is running on |
| 790 | + detectDevice() |
| 791 | + |
757 | 792 | # Tells to FL Studio the device has peak meters |
758 | 793 | device.setHasMeters() |
759 | 794 |
|
|
0 commit comments