diff --git a/.lefthook.yml b/.lefthook.yml index 963c932..0e8d8df 100644 --- a/.lefthook.yml +++ b/.lefthook.yml @@ -9,4 +9,4 @@ pre-commit: run: bunx prettier --check {staged_files} tsc: glob: '*.{js,ts}' - run: bunx tsc -b + run: bunx tsc-files --noEmit {staged_files} diff --git a/bun.lockb b/bun.lockb index d18886f..f3f56df 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index da71917..882f0f0 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "prettier": "^3.1.1", "rollup": "^3.19.1", "semantic-release": "^21.0.1", + "tsc-files": "^1.1.4", "typescript": "^4.9.5" }, "workspaces": [ diff --git a/packages/launchcontrol-common/src/page/fxParam.ts b/packages/launchcontrol-common/src/page/fxParam.ts index 036dbc5..2f0f6b4 100644 --- a/packages/launchcontrol-common/src/page/fxParam.ts +++ b/packages/launchcontrol-common/src/page/fxParam.ts @@ -8,6 +8,7 @@ import { root, setValue, } from '@mixxx-launch/mixxx/src/Control' +import { absoluteLin } from '@mixxx-launch/mixxx/src/util' import { LaunchControlDevice, MidiComponent } from '../device' export const makeFxParamPage = (_conf: FxParamPageConf, template: number, device: LaunchControlDevice) => @@ -122,7 +123,7 @@ export class FxParamPage extends Component { } const toEffectKnobRange = (value: number) => { - return value / 63.5 - 1 + return absoluteLin(value, 0, 1) } class FxComponent extends Component { diff --git a/packages/mixxx/src/util.ts b/packages/mixxx/src/util.ts index 8b04c23..9781d43 100644 --- a/packages/mixxx/src/util.ts +++ b/packages/mixxx/src/util.ts @@ -1,14 +1,5 @@ export type Action = (t: T) => void -/* -------- ------------------------------------------------------ - absoluteNonLin - Purpose: Maps an absolute linear control value to a non-linear Mixxx control - value (like EQs: 0..1..4) - Input: Control value (e.g. a knob,) MixxxControl values for the lowest, - middle, and highest points, lowest knob value, highest knob value - (Default knob values are standard MIDI 0..127) - Output: MixxxControl value corresponding to the knob position - -------- ------------------------------------------------------ */ export const absoluteNonLin = ( value: number, low: number, @@ -26,3 +17,6 @@ export const absoluteNonLin = ( return mid + (value - center) / (center / (high - mid)) } } + +export const absoluteLin = (value: number, low: number, high: number, min: number = 0, max: number = 127) => + ((high - low) / (max - min)) * (value - min) + low