Skip to content

Commit

Permalink
fix fx params
Browse files Browse the repository at this point in the history
  • Loading branch information
dszakallas committed Feb 18, 2024
1 parent 9b02d30 commit 6915620
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 2 additions & 1 deletion packages/launchcontrol-common/src/page/fxParam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 3 additions & 9 deletions packages/mixxx/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
export type Action<T> = (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,
Expand All @@ -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

0 comments on commit 6915620

Please sign in to comment.