-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e67d0a
commit f02c9a9
Showing
7 changed files
with
392 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import { MakeControlTemplate } from '@mixxx-launch/launch-common/src/Control' | ||
import { MidiMessage, absoluteNonLin } from "@mixxx-launch/mixxx" | ||
import { ControlComponent, ControlMessage, getValue, root, setValue } from "@mixxx-launch/mixxx/src/Control" | ||
import { Control, ControlBindingTemplate, MidiBindingTemplate } from '../Control' | ||
import { LCMidiComponent } from "../device" | ||
import { channelColorPalette } from '../util' | ||
|
||
const eq3Channel = ['low', 'mid', 'hi'] | ||
|
||
export type Eq3Type = { | ||
type: 'eq3' | ||
bindings: { | ||
[ch in typeof eq3Channel[number] as `knob.${ch}`]: MidiBindingTemplate<Eq3Type> | ||
} & { | ||
[ch in typeof eq3Channel[number] as `kill.${ch}`]: ControlBindingTemplate<Eq3Type> | ||
} & { | ||
[ch in typeof eq3Channel[number] as `val.${ch}`]: ControlBindingTemplate<Eq3Type> | ||
} | ||
params: { | ||
template: number | ||
column: number | ||
deck: number | ||
} | ||
state: Record<string, unknown> | ||
} | ||
|
||
export const makeEq3: MakeControlTemplate<Eq3Type> = ({ template, column, deck }) => { | ||
const bindings: Eq3Type['bindings'] = {} | ||
const fxParams = root.equalizerRacks[0].effect_units[deck].effects[0].parameters | ||
eq3Channel.forEach((v, i) => { | ||
bindings[`knob.${v}`] = { | ||
type: LCMidiComponent, | ||
target: [template, `knob.${2-i}.${column}`], | ||
listeners: { | ||
midi: ({ bindings }: Control<Eq3Type>) => ({ value }: MidiMessage) => { | ||
setValue(bindings[`val.${v}`].control, absoluteNonLin(value, 0, 1, 4)) | ||
} | ||
} | ||
} | ||
|
||
bindings[`kill.${v}`] = { | ||
type: ControlComponent, | ||
target: fxParams[i].button_value, | ||
listeners: { | ||
update: ({ context: { device }, bindings }: Control<Eq3Type>) => ({ value }: ControlMessage) => { | ||
device.sendColor(template, bindings[`knob.${v}`].led, device.colors[channelColorPalette[deck % 4][value ? 1 : 0]]) | ||
} | ||
} | ||
} | ||
|
||
bindings[`val.${v}`] = { | ||
type: ControlComponent, | ||
target: fxParams[i].value, | ||
softTakeOver: true, | ||
listeners: {} | ||
} | ||
}) | ||
|
||
return { | ||
state: {}, | ||
bindings, | ||
} | ||
} | ||
|
||
|
||
export type Eq3KillType = { | ||
type: 'eq3kill' | ||
bindings: { | ||
[ch in typeof eq3Channel[number] | "qfx" as `pad.${ch}`]: MidiBindingTemplate<Eq3KillType> | ||
} & { | ||
[ch in typeof eq3Channel[number] | "qfx" as `kill.${ch}`]: ControlBindingTemplate<Eq3KillType> | ||
} | ||
params: { | ||
template: number | ||
row: number | ||
column: number | ||
deck: number | ||
} | ||
state: Record<string, unknown> | ||
} | ||
|
||
export const makeEq3Kill: MakeControlTemplate<Eq3KillType> = ({ template, row, column, deck }) => { | ||
const bindings: Eq3KillType['bindings'] = {} | ||
const fxParams = root.equalizerRacks[0].effect_units[deck].effects[0].parameters | ||
|
||
const eq3KillChannel = [ | ||
...['low', 'mid', 'hi'].map((v, i) => [v, fxParams[2-i].button_value] as const), | ||
['qfx', root.quickEffectRacks[0].effect_units[deck].enabled] as const | ||
] as const | ||
|
||
|
||
eq3KillChannel.forEach(([v, c], i) => { | ||
bindings[`pad.${v}`] = { | ||
type: LCMidiComponent, | ||
target: [template, `pad.${row}.${column + i}`, 'on'], | ||
listeners: { | ||
midi: ({ bindings }: Control<Eq3KillType>) => ({ value }: MidiMessage) => { | ||
if (value) { | ||
const ctrl = bindings[`kill.${v}`].control | ||
setValue(ctrl, 1 - getValue(ctrl)) | ||
} | ||
} | ||
} | ||
} | ||
bindings[`kill.${v}`] = { | ||
type: ControlComponent, | ||
target: c, | ||
listeners: { | ||
update: ({ context: { device }, bindings }: Control<Eq3KillType>) => ({ value }: ControlMessage) => { | ||
device.sendColor(template, bindings[`pad.${v}`].led, value ? device.colors.hi_red : device.colors.black) | ||
} | ||
} | ||
} | ||
}) | ||
|
||
return { | ||
state: {}, | ||
bindings, | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import { array, map, range } from '@mixxx-launch/common' | ||
import { MakeControlTemplate } from '@mixxx-launch/launch-common/src/Control' | ||
import { MidiMessage } from "@mixxx-launch/mixxx" | ||
import { ControlComponent, ControlMessage, createEffectUnitChannelDef, getValue, root, setValue } from "@mixxx-launch/mixxx/src/Control" | ||
import { Control, ControlBindingTemplate, MidiBindingTemplate } from '../Control' | ||
import { LCMidiComponent } from "../device" | ||
import { channelColorPalette } from '../util' | ||
|
||
export type FxEnablerType = { | ||
type: 'fxEnabler' | ||
bindings: { | ||
[_: `pad.${number}`]: MidiBindingTemplate<FxEnablerType> | ||
[_: `ctrl.${number}`]: ControlBindingTemplate<FxEnablerType> | ||
} | ||
params: { | ||
template: number | ||
row: number | ||
column: number | ||
deck: number | ||
} | ||
state: Record<string, unknown> | ||
} | ||
|
||
export const makeFxEnabler: MakeControlTemplate<FxEnablerType> = ({ template, row, column, deck }) => { | ||
const unit = root.effectRacks[0].effect_units[deck] | ||
const controls = [...map(i => unit.effects[i].enabled, range(3)), unit.enabled] | ||
|
||
const bindings: FxEnablerType['bindings'] = {} | ||
|
||
controls.forEach((control, i) => { | ||
bindings[`pad.${i}`] = { | ||
type: LCMidiComponent, | ||
target: [template, `pad.${row}.${column + i}`, 'on'], | ||
listeners: { | ||
midi: ({ bindings }: Control<FxEnablerType>) => ({ value }: MidiMessage) => { | ||
if (value) { | ||
const ctrl = bindings[`ctrl.${i}`].control | ||
setValue(ctrl, 1 - getValue(ctrl)) | ||
} | ||
} | ||
} | ||
} | ||
bindings[`ctrl.${i}`] = { | ||
type: ControlComponent, | ||
target: control, | ||
listeners: { | ||
update: ({ context: { device }, bindings }: Control<FxEnablerType>) => ({ value }: ControlMessage) => { | ||
device.sendColor(template, bindings[`pad.${i}`].led, value ? device.colors.hi_green : device.colors.black) | ||
} | ||
} | ||
} | ||
}) | ||
|
||
return { | ||
state: {}, | ||
bindings, | ||
} | ||
} | ||
|
||
export type FxSelectorType = { | ||
type: 'fxSelector' | ||
bindings: { | ||
[_: `pad.${number}`]: MidiBindingTemplate<FxSelectorType> | ||
[_: `ctrl.${number}`]: ControlBindingTemplate<FxSelectorType> | ||
} | ||
params: { | ||
template: number | ||
row: number | ||
column: number | ||
deck: number | ||
} | ||
state: Record<string, unknown> | ||
} | ||
|
||
export const makeFxSelector: MakeControlTemplate<FxSelectorType> = ({ template, row, column, deck }) => { | ||
const bindings: FxSelectorType['bindings'] = {} | ||
|
||
array(range(4)).forEach(i => { | ||
const control = createEffectUnitChannelDef( | ||
"EffectRack1", `EffectUnit${i + 1}`, `Channel${deck + 1}`, | ||
).enable | ||
|
||
bindings[`pad.${i}`] = { | ||
type: LCMidiComponent, | ||
target: [template, `pad.${row}.${column + i}`, 'on'], | ||
listeners: { | ||
midi: ({ bindings }: Control<FxSelectorType>) => ({ value }: MidiMessage) => { | ||
if (value) { | ||
setValue(bindings[`ctrl.${i}`].control, 1 - getValue(bindings[`ctrl.${i}`].control)) | ||
} | ||
} | ||
} | ||
} | ||
bindings[`ctrl.${i}`] = { | ||
type: ControlComponent, | ||
target: control, | ||
listeners: { | ||
update: ({ context: { device }, bindings }: Control<FxSelectorType>) => ({ value }: ControlMessage) => { | ||
device.sendColor(template, bindings[`pad.${i}`].led, value ? device.colors.hi_yellow : device.colors.black) | ||
} | ||
} | ||
} | ||
}) | ||
|
||
return { | ||
state: {}, | ||
bindings, | ||
} | ||
} | ||
|
||
export type FxMetaType = { | ||
type: 'fxMeta' | ||
bindings: { | ||
[_: `knob.${number}`]: MidiBindingTemplate<FxMetaType> | ||
[_: `ctrl.${number}`]: ControlBindingTemplate<FxMetaType> | ||
} | ||
params: { | ||
template: number | ||
column: number | ||
unit: number | ||
} | ||
state: Record<string, unknown> | ||
} | ||
|
||
export const makeFxMeta: MakeControlTemplate<FxMetaType> = ({ template, column, unit }) => { | ||
const bindings: FxMetaType['bindings'] = {} | ||
|
||
array(range(3)).forEach(i => { | ||
const control = root.effectRacks[0].effect_units[unit].effects[i].meta | ||
|
||
bindings[`knob.${i}`] = { | ||
type: LCMidiComponent, | ||
target: [template, `knob.${i}.${column}`], | ||
listeners: { | ||
midi: ({ bindings }: Control<FxMetaType>) => ({ value }: MidiMessage) => { | ||
setValue(bindings[`ctrl.${i}`].control, value / 127) | ||
} | ||
} | ||
} | ||
bindings[`ctrl.${i}`] = { | ||
type: ControlComponent, | ||
target: control, | ||
listeners: { | ||
update: ({ context: { device }, bindings }: Control<FxMetaType>) => ({ value }: ControlMessage) => { | ||
device.sendColor(template, bindings[`knob.${i}`].led, value ? device.colors[channelColorPalette[unit % 4][0]] : device.colors.black) | ||
} | ||
} | ||
} | ||
}) | ||
return { | ||
state: {}, | ||
bindings, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.