Skip to content

Instantly share code, notes, and snippets.

@kerrishotts
kerrishotts / CorrectLoudNotes.js
Last active December 18, 2022 20:34
Loud Note Correction Script for Logic Pro X / Mainstage Midi FX Scripter plugin
/* Logic Pro Script to detect and apply velocity corrections to load notes. This is particularly useful for the Yamaha NU1X
* hybrid piano, which can sometimes register a key press with high velocity by accident, usually during rapid trilling or repeating of notes (in this case a regular acoustic
* would simply play a silent or much quieter note).
*
* This script is based on the Kontakt script by herqX located at https://github.com/herqX/YamahaNU1LoudNoteFix. I took the
* liberty to add a few more parameters (see README)
*
* LICENSE: GNU General Public License V3
*
*/
@kerrishotts
kerrishotts / FileManager.js
Last active September 21, 2022 10:14
Simple File API wrapper using Q.js. Same code as in http://github.com/photokandyStudios/YASMF-Next/blob/master/lib/yasmf/util/fileManager.js, except wrapped in a global function. The code below will add a FileManager object to `window`, if it is passed in (otherwise it will only return it). It can then be used as seen in this demo: http://jsbin.…
;(
function( Q, BaseObject, globalContext ) {
/**
* Defined by Q, actually, but defined here to make type handling nicer
* @typedef {{}} Promise
*/
var DEBUG = false;
/**
* Requests a quota from the file system
* @method _requestQuota
@kerrishotts
kerrishotts / decimal-workaround.js
Last active October 13, 2021 22:23
Numeric sp-textfield issues & buggyfill
(function () {
function fixNumericSpTextField() {
if(require("uxp").versions.uxp.startsWith("uxp-5.5.1")) {
const candidates = document.querySelectorAll("sp-textfield[type=number]");
candidates.forEach(el => {
el.setAttribute("type", "text");
el.setAttribute("data-uxp-type", "number");
});
}
document.addEventListener("input", evt => {
@kerrishotts
kerrishotts / manual-workaround.js
Created October 13, 2021 22:19
Setting UXP textfield value manual workaround
const numberField = document.querySelector("sp-textfield[type=number]");
numberField.value = `${numberOfSteps}`; /* template literals will work */
numberField.value = "" + numberOfSteps; /* or you can do this. */
@kerrishotts
kerrishotts / setting-value.js
Created October 13, 2021 22:18
UXP setting sp-textfield value issue
const numberField = document.querySelector("sp-textfield[type=number]");
numberField.value = 10; /* won't work; field will be blank */
numberField.value = "10"; /* will work. */
@kerrishotts
kerrishotts / fix-change-event.js
Created October 13, 2021 22:11
Buggyfill for sp-textfield not firing `change` event
(function () {
if(require("uxp").versions.uxp.startsWith("uxp-5.5.1")) {
let curField, curValue;
document.addEventListener("focus", evt => {
curField = evt.target;
curValue = curField.value;
}, true);
document.addEventListener("blur", evt => {
if (evt.target.tagName === "SP-TEXTFIELD") {
if (curField === evt.target) {
@kerrishotts
kerrishotts / README.md
Last active March 14, 2021 20:32
Pitch-based Velocity Mapper for Logic Pro X / Mainstage
@kerrishotts
kerrishotts / Schedule.md
Created December 8, 2020 19:47
WCTD: Level II Training Content & Schedule

Session 1

Introduction and Prerequisites

A quick overview of what we'll be covering, and what you're expected to already know, including:

  • Basic HTML tags
  • CSS Syntax
  • Interacting with the DOM
  • Variables
@kerrishotts
kerrishotts / support.csv
Last active November 19, 2020 23:03
Support Matrix for in-app Extensibility
Extensibility Feature Intel Windows ARM Apple silicon (Rosetta 2) Apple silicon (Native)
C++ Plugins ✅ (Recompile) ✅ (Recompile)
CEP on Photoshop ⛔️ ⛔️
CEP on all other apps
Extend Script (& ScriptUI) on all apps)
Generator (Ps-only) ⛔️ ⛔️
UXP
@kerrishotts
kerrishotts / tokenizer.js
Created July 11, 2020 22:47
JS Code from Building a Basic Interpreter, '80s Style Part 2
const tokens = ["CLS", "PRINT", ":" ];
function tokenize(inStr) {
let out = []; // return value is "crunched" array
let idx = 0; // index into inStr
let ch = ""; // current character
while (idx < inStr.length) {
ch = inStr.charCodeAt(idx); // get the current character code
if (ch >= 48 && ch <= 57) { // NUMERIC LITERAL
out.push (0xFD);