From dbea8db4ba0a1fe984e2ba44a4d26b33b716e6c0 Mon Sep 17 00:00:00 2001 From: pimpjuic3 Date: Sun, 6 Nov 2022 22:02:27 +0100 Subject: [PATCH 1/3] live11-ps1-install-script: added Powershell script for Windows installation --- Devices/install.ps1 | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Devices/install.ps1 diff --git a/Devices/install.ps1 b/Devices/install.ps1 new file mode 100644 index 0000000..c1336b8 --- /dev/null +++ b/Devices/install.ps1 @@ -0,0 +1,49 @@ +############################################################################################## +# Windows 10 / WIndows 11 PowerShell install script # +# Paths may differ from the defaults used in this script and may be adjusted # +############################################################################################## +$LIVE_MIDI_REMOTE_PATH = "C:\ProgramData\Ableton\Live 11 Suite\Resources\MIDI Remote Scripts" + +# Backup Existing Midi Remote Folder +# Copy-Item $LIVE_MIDI_REMOTE_PATH -Destination $LIVE_MIDI_REMOTE_PATH" ORIG" -Recurse + +# Copy +$UBERMAP_MIDI_REMOTE_PATH = $LIVE_MIDI_REMOTE_PATH + '/Ubermap' +New-Item -Path $UBERMAP_MIDI_REMOTE_PATH -ItemType "directory" -Force +Copy-Item ../Common/__init__.py -Destination $UBERMAP_MIDI_REMOTE_PATH -Force +Copy-Item ../Common/configobj.py -Destination $UBERMAP_MIDI_REMOTE_PATH -Force +Copy-Item ../Common/UbermapLibs.py -Destination $UBERMAP_MIDI_REMOTE_PATH -Force +Copy-Item UbermapDevices.py -Destination $UBERMAP_MIDI_REMOTE_PATH -Force +Copy-Item UbermapDevicesPatches.py -Destination $UBERMAP_MIDI_REMOTE_PATH -Force + +# Copy config +$UBERMAP_USER = $HOME + '/Ubermap' +New-Item -Path $UBERMAP_USER -ItemType "directory" -Force +New-Item -Path $UBERMAP_USER"/Devices" -ItemType "directory" -Force +Copy-Item ..\Config\devices.cfg -Destination $UBERMAP_USER -Force +Copy-Item ..\Config\global.cfg -Destination $UBERMAP_USER -Force +Copy-Item ..\Config\browser.cfg -Destination $UBERMAP_USER -Force + +# PluginAutoPopulateThreshold Setting +$SETTINGS_FOLDER_SEARCH = $HOME + '\AppData\Roaming\Ableton' +$LIVE_VERSION_FOLDER_NAME = (Get-ChildItem $SETTINGS_FOLDER_SEARCH | Where-Object {$_.name -match "Live .[0-9.]"} | Sort-Object | Select-Object -Last 1).Name +$OPTIONS_FILE = $HOME + '\AppData\Roaming\Ableton\' + $LIVE_VERSION_FOLDER_NAME + '\Preferences\Options.txt' + +$SETTING = "-_PluginAutoPopulateThreshold=-1" +if(!(Test-path $OPTIONS_FILE)) +{ + $SETTING | Out-File $OPTIONS_FILE +} else { + $contains = Select-String -Path $OPTIONS_FILE "-_PluginAutoPopulateThreshold" + + if ($null -eq $contains) + { + Add-Content $OPTIONS_FILE $SETTING + } +} + +# Remove .pyc +Get-ChildItem -Path $LIVE_MIDI_REMOTE_PATH"/Ubermap" *.pyc | ForEach-Object { Remove-Item -Path $_.FullName } + +Write-Output 'Ubermap installed - now restart Ableton Live.' +Read-Host 'Press ENTER to close...' \ No newline at end of file From ffc2210f3eb95ab57e4b023dc2125a9bf18c9a74 Mon Sep 17 00:00:00 2001 From: pimpjuic3 Date: Thu, 10 Nov 2022 18:28:54 +0100 Subject: [PATCH 2/3] feature-improvements: removed hash from device config name --- Devices/UbermapDevices.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Devices/UbermapDevices.py b/Devices/UbermapDevices.py index 37c0bcd..04a061d 100644 --- a/Devices/UbermapDevices.py +++ b/Devices/UbermapDevices.py @@ -26,7 +26,6 @@ def get_device_name(self, device): params = '' for i in device.parameters[1:]: params += i.original_name - name += '_' + hashlib.md5(params.encode('utf-8')).hexdigest() return name def get_device_filename(self, device): From c049f1504661e6687d93913b0c63360b9418afc6 Mon Sep 17 00:00:00 2001 From: pimpjuic3 Date: Fri, 11 Nov 2022 17:26:01 +0100 Subject: [PATCH 3/3] feature-improvements: optimized function get_parameter_by_name --- .gitignore | 4 ++++ Devices/UbermapDevices.py | 42 +++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index d26b33d..e9d2ea8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ working +Devices/ableton +Devices/Push2 +Devices/Ubermap +Devices/configobj.py diff --git a/Devices/UbermapDevices.py b/Devices/UbermapDevices.py index 04a061d..8eb3c38 100644 --- a/Devices/UbermapDevices.py +++ b/Devices/UbermapDevices.py @@ -1,8 +1,8 @@ import os.path +import re from . configobj import ConfigObj from functools import partial -import hashlib -from Ubermap.UbermapLibs import log, log_call, config +from Ubermap.UbermapLibs import log, config class UbermapDevices: PARAMS_PER_BANK = 8 @@ -24,8 +24,8 @@ def get_device_name(self, device): name = device.class_display_name if self.cfg.get('use_md5'): params = '' - for i in device.parameters[1:]: - params += i.original_name + for device_parameter in device.parameters[1:]: + params += device_parameter.original_name return name def get_device_filename(self, device): @@ -56,13 +56,13 @@ def dump_device(self, device): count = 0 bank = 1 total_count = 1 - for i in device.parameters[1:]: + for device_parameter in device.parameters[1:]: if(count == 0): section = 'Bank ' + str(bank) config[self.SECTION_BANKS][section] = {} bank = bank + 1 - config[self.SECTION_BANKS][section][str(total_count) + "_" + i.original_name] = i.original_name + config[self.SECTION_BANKS][section][str(total_count) + "_" + device_parameter.original_name] = device_parameter.original_name count = count + 1 total_count = total_count + 1 @@ -118,16 +118,28 @@ def get_custom_parameter_values(parameter_name): if values_type: return parse_custom_parameter_values(values_type) - def get_parameter_by_name(device, nameMapping): + def get_parameter_by_name(device, name_mapping): count = 0 - for i in device.parameters: - if nameMapping[0] == str(count) + "_" + i.original_name or nameMapping[0] == i.original_name: - log.info("got " + nameMapping[1] + " for " + nameMapping[0]) - i.custom_name = nameMapping[1] - - [i.custom_parameter_values, i.custom_parameter_start_points] = get_custom_parameter_values(nameMapping[0]) - - return i + for device_parameter in device.parameters: + original_name = name_mapping[0] + if (original_name == device_parameter.original_name) \ + or (original_name == str(count) + "_" + device_parameter.original_name) \ + or re.match("^\\d+_\\w+$" + device_parameter.original_name, original_name): + + if not name_mapping[1]: + custom_name = original_name + elif name_mapping[1] == "*": + # this line just splits words by case: SomeWord -> Some Word + custom_name = " ".join(re.sub('([A-Z][a-z]+)', r' \1', re.sub('([A-Z]+)', r' \1', original_name)).split()) + else: + custom_name = name_mapping[1] + + device_parameter.custom_name = custom_name + + [device_parameter.custom_parameter_values, device_parameter.custom_parameter_start_points] = \ + get_custom_parameter_values(original_name) + + return device_parameter count = count + 1 def names_to_params(bank):