Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add quick effect #77

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/launchcontrol-common/src/eq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { range } from "@mixxx-launch/common"
import { absoluteNonLin, Component, MidiMessage } from "@mixxx-launch/mixxx"
import { ControlComponent, ControlMessage, root, setValue } from "@mixxx-launch/mixxx/src/Control"
import { LaunchControlDevice, LCMidiComponent } from "./device"
import { defaultVerticalGroupParams, VerticalGroupParams } from "./util"
import { VerticalGroupParams } from "./util"

export enum Eq3Channel {
Low,
Expand All @@ -18,7 +18,8 @@ const eq3 = (deck: number, col: number) => {
] as const
}

export const makeEq3 = ({ template, columnOffset, numDecks }: VerticalGroupParams = defaultVerticalGroupParams) => (device: LaunchControlDevice): Component[] => {
export const makeEq3 = ({ template, columnOffset, numDecks }: VerticalGroupParams) => (device: LaunchControlDevice): Component[] => {
columnOffset = columnOffset || 0
const children: Component[] = []

const channelColorPalette = [
Expand Down
50 changes: 50 additions & 0 deletions packages/launchcontrol-common/src/fx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { range } from "@mixxx-launch/common"
import { Component, MidiMessage } from "@mixxx-launch/mixxx"
import { ControlComponent, ControlMessage, root, setValue } from "@mixxx-launch/mixxx/src/Control"
import { LaunchControlDevice, LCMidiComponent } from "./device"
import { VerticalGroupParams } from "./util"


const quickEffect = (deck: number, col: number) => {
return [
[`knob.0.${col}`, { type: 'quickEffect', params: { deck: deck } }],
// [`knob.1.${col}`, { type: 'eq3', params: { channel: Eq3Channel.Mid, deck: deck } }],
// [`knob.2.${col}`, { type: 'eq3', params: { channel: Eq3Channel.Low, deck: deck } }],
] as const
}

export const makeQuickEffect = ({ template, columnOffset, numDecks }: VerticalGroupParams) => (device: LaunchControlDevice): Component[] => {
columnOffset = columnOffset || 0
const children: Component[] = []

const channelColorPalette = [
[device.colors.hi_red, device.colors.lo_red],
[device.colors.hi_yellow, device.colors.lo_yellow],
[device.colors.hi_green, device.colors.lo_green],
[device.colors.hi_amber, device.colors.lo_amber],
]

for (const i of range(numDecks)) {
const col = i + columnOffset
const quickFx = quickEffect(i, col)
for (const [midi, cd] of quickFx) {
const effectParam = root.quickEffectRacks[0].effect_units[cd.params.deck]
const paramControlComponent = new ControlComponent(effectParam.super1, true)
children.push(paramControlComponent)

const killedControlComponent = new ControlComponent(effectParam.enabled)
children.push(killedControlComponent)

const midiComponent = new LCMidiComponent(device, template, midi)
midiComponent.addListener('midi', ({ value }: MidiMessage) => {
setValue(effectParam.super1, value / 127)
})

killedControlComponent.addListener('update', ({ value }: ControlMessage) => {
device.sendColor(template, midiComponent.led, channelColorPalette[i % 4][value ? 1 : 0])
})
children.push(midiComponent)
}
}
return children
}
75 changes: 66 additions & 9 deletions packages/launchcontrol-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { ControlMessage, createEffectUnitChannelDef, getValue, numDecks as mixxx
import { LaunchControlDevice, LCMidiComponent } from './device'
import { makeEffectParameterPage } from './effectParameter'
import { makeEq3 } from './eq'
import { makeQuickEffect } from './fx'
import { makePadSelector } from './padSelector'
import { MakePage, makePager } from './pager'
import { defaultVerticalGroupParams, VerticalGroupParams } from './util'
import { VerticalGroupParams } from './util'

export type MakeComponent = (device: LaunchControlDevice) => Component

Expand Down Expand Up @@ -68,7 +69,8 @@ const container = (children: Component[]) => {
}()
}

const makeGain = ({ template, columnOffset, numDecks }: VerticalGroupParams = defaultVerticalGroupParams) => (device: LaunchControlDevice): Component[] => {
const makeGain = ({ template, columnOffset, numDecks }: VerticalGroupParams) => (device: LaunchControlDevice): Component[] => {
columnOffset = columnOffset || 0
const children: Component[] = []

for (const i of range(numDecks)) {
Expand Down Expand Up @@ -199,7 +201,7 @@ const makeEnablers = (template: number) => (device: LaunchControlDevice) => {
for (const i of range(4)) {
const row = ~~(i / 2)
const col = i % 2
const controls = [...map(j => root.effectRacks[0].effect_units[i].effects[j].enabled, range(3)), null]
const controls = [...map(j => root.effectRacks[0].effect_units[i].effects[j].enabled, range(3)), root.effectRacks[0].effect_units[i].enabled]
controls.forEach((control, j) => {
const midiControl = device.controls[`${template}.pad.${row}.${(col * 4) + j}.on`]
const midiComponent = new LCMidiComponent(device, template, `pad.${row}.${(col * 4) + j}`, 'on')
Expand Down Expand Up @@ -229,7 +231,8 @@ const makeEnablers = (template: number) => (device: LaunchControlDevice) => {
return container(children)
}

const makeEffectSuper = ({ template, columnOffset, numDecks }: VerticalGroupParams = defaultVerticalGroupParams) => (device: LaunchControlDevice): Component[] => {
const makeEffectMeta = ({ template, columnOffset, numDecks }: VerticalGroupParams) => (device: LaunchControlDevice): Component[] => {
columnOffset = columnOffset || 0
const children: Component[] = []

const channelColorPalette = [
Expand Down Expand Up @@ -263,7 +266,42 @@ const makeEffectSuper = ({ template, columnOffset, numDecks }: VerticalGroupPara
return children
}

const makeEffectMix = ({ template, columnOffset, numDecks }: VerticalGroupParams = defaultVerticalGroupParams) => (device: LaunchControlDevice): Component[] => {

const makeEffectSuper = ({ template, columnOffset, rowOffset, numDecks }: VerticalGroupParams) => (device: LaunchControlDevice): Component[] => {
columnOffset = columnOffset || 0
rowOffset = rowOffset || 0
const children: Component[] = []

const channelColorPalette = [
device.colors.hi_red,
device.colors.hi_yellow,
device.colors.hi_green,
device.colors.hi_amber,
]

for (const i of range(numDecks)) {
const effect = root.effectRacks[0].effect_units[i]
const super1 = new ControlComponent(effect.super1, true)
children.push(super1)

const midiComponent = new LCMidiComponent(device, template, `knob.${rowOffset}.${i + columnOffset}`)
midiComponent.addListener('midi', ({ value }: MidiMessage) => {
setValue(effect.super1, value / 127)
})
children.push(midiComponent)

const enabled = new ControlComponent(effect.enabled)
enabled.addListener('update', ({ value }: ControlMessage) => {
device.sendColor(template, midiComponent.led, value ? channelColorPalette[i % 4] : device.colors.black)
})

children.push(enabled)
}
return children
}

const makeEffectMix = ({ template, columnOffset, numDecks }: VerticalGroupParams) => (device: LaunchControlDevice): Component[] => {
columnOffset = columnOffset || 0
const children: Component[] = []
for (const i of range(numDecks)) {
const effectUnit = root.effectRacks[0].effect_units[i]
Expand All @@ -280,8 +318,6 @@ const makeEffectMix = ({ template, columnOffset, numDecks }: VerticalGroupParams
return children
}



// const makeEffectUnit = (device: LaunchControlDevice) => {
// const children: Component[] = []

Expand Down Expand Up @@ -327,15 +363,36 @@ const makeEffectMix = ({ template, columnOffset, numDecks }: VerticalGroupParams
// return container(children)
// }

// const makeKitchenSinkPage = (template: number) => (device: LaunchControlDevice) => container([
// ...makeEq3({ template, columnOffset: 0, numDecks: mixxxNumDecks })(device),
// ...makeGain({ template, columnOffset: 0, numDecks: mixxxNumDecks })(device),
// ...makeAlt([
// container(makeEffectSuper({ template, columnOffset: 4, numDecks: mixxxNumDecks })(device)),
// container(makeQuickEffect({ template, columnOffset: 4, numDecks: mixxxNumDecks })(device)),
// ])(template)(device),
// ...makeEffectMix({ template, columnOffset: 4, numDecks: mixxxNumDecks })(device),
// ])


const makeKitchenSinkPage = (template: number) => (device: LaunchControlDevice) => container([
...makeEq3({ template, columnOffset: 0, numDecks: mixxxNumDecks })(device),
...makeGain({ template, columnOffset: 0, numDecks: mixxxNumDecks })(device),
...makeEffectSuper({ template, columnOffset: 4, numDecks: mixxxNumDecks })(device),
...makeEffectMeta({ template, columnOffset: 4, numDecks: mixxxNumDecks })(device),
...makeEffectMix({ template, columnOffset: 4, numDecks: mixxxNumDecks })(device),
])


const makeKitchenSinkPage2 = (template: number) => (device: LaunchControlDevice) => container([
...makeEq3({ template, columnOffset: 0, numDecks: mixxxNumDecks })(device),
...makeGain({ template, columnOffset: 0, numDecks: mixxxNumDecks })(device),
...makeQuickEffect({ template, columnOffset: 4, numDecks: mixxxNumDecks })(device),
...makeEffectSuper({ template, columnOffset: 4, rowOffset: 1, numDecks: mixxxNumDecks })(device),
...makeEffectMix({ template, columnOffset: 4, numDecks: mixxxNumDecks })(device),
])


const makeApp = (device: LaunchControlDevice) => container([
makePager([makeKitchenSinkPage, makeEffectParameterPage], 16)(device),
makePager([makeKitchenSinkPage, makeKitchenSinkPage2, makeEffectParameterPage], 16)(device),
makePager(
[() => makePadSelector([
statelessFreePage(makeEffectSelector),
Expand Down
11 changes: 2 additions & 9 deletions packages/launchcontrol-common/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { numDecks } from "@mixxx-launch/mixxx/src/Control"

export type VerticalGroupParams = {
template: number,
columnOffset: number,
columnOffset?: number,
rowOffset?: number,
numDecks: number,
}

export const defaultVerticalGroupParams: VerticalGroupParams = {
template: 0,
columnOffset: 0,
numDecks: numDecks,
}