Skip to content
Draft
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
Binary file not shown.
Binary file not shown.
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"description": "Library of useful Max for Live objects",
"private": true,
"dependencies": {
"core-js": "^3.39.0",
"dotenv": "^8.2.0"
},
"devDependencies": {
"@types/core-js": "^2.5.8",
"prettier": "^3.3.3",
"ts-loader": "^9.5.1",
"typescript": "^5.5.3",
Expand Down
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as launchpadColourIndices } from "./launchpadColourIndices";
76 changes: 76 additions & 0 deletions src/config/launchpadColourIndices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
export default [
56, // salmon
61, // frank orange
100, // dirty gold
73, // lemonade
85, // lime
87, // highlighter green
88, // bianchi
28, // turquoise
91, // sky blue
92, // sapphire
40, // periwinkle
82, // orchid
58, // magenta
3, // white

106, // fire hydrant red
127, // tangerine
117, // sand
14, // sunshine yellow
86, // terminal green
19, // forest
65, // tiffany blue
68, // cyan
39, // cerulean
43, // united nations blue
93, // amtethyst
70, // iris
53, // flamingo
2, // aluminum

105, // terracotta
107, // light salmon
8, // whiskey
73, // canary
113, // primrose
16, // wild willow
24, // dark sea green
114, // honeydew
114, // pale turquoise
118, // periwinkle
2, // fog
39, // dull lavender
119, // whisper
118, // silver chalice

2, // dusty pink
105, // barley corn
118, // pale oyster; difficult
110, // dark khaki
18, // pistachio
102, // dollar bill
89, // neptune
89, // nepal
36, // polo blue
40, // vista blue
2, // amethyst smoke
118, // lilac
70, // turkish rose
117, // steel

121, // medium carmine
83, // red ochre
71, // coffee
15, // durian yellow
19, // pomelo green
27, // apple
65, // aquamarine
68, // sea blue
104, // cosmic cobalt
112, // sapphire
71, // plump purple
70, // purpureus
55, // fuchsia rose
103, // eclipse
];
3 changes: 2 additions & 1 deletion src/maxForLive.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ declare global {
mode: number;
type: string;
info: string;
property: string;
property: string | null;
call: Function;
freepeer: Function;
get: Function;
getcount: Function;
getstring: Function;
Expand Down
88 changes: 88 additions & 0 deletions src/objects/betterLaunchpadColours/betterLaunchpadColours.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import "core-js";
import type { Id } from "../../types";
import { log, ApiManager, getCount } from "../../util";
import { launchpadColourIndices } from "../../config";

autowatch = 1;
outlets = 3;

enum LightType {
on,
blink,
pulse,
off,
}

const apiMan = new ApiManager();

export function bang() {
const numberOfTracks = getCount("live_set tracks");
for (
let trackIndex = 0;
trackIndex < Math.min(8, numberOfTracks);
trackIndex++
) {
const numberOfClipSlots = getCount(
`live_set tracks ${trackIndex} clip_slots`,
);
for (
let clipSlotIndex = 0;
clipSlotIndex < Math.min(8, numberOfClipSlots);
clipSlotIndex++
) {
const clipSlotId = `live_set tracks ${trackIndex} clip_slots ${clipSlotIndex} has_clip`;
const clipId = `live_set tracks ${trackIndex} clip_slots ${clipSlotIndex} clip color_index`;
const padIndex = getPadIndex(trackIndex, clipSlotIndex);
const clipSlot = apiMan.make(clipSlotId, (hasClip) => {
log(
`Track ${trackIndex + 1} clip slot ${clipSlotIndex + 1} ${hasClip === 0 ? "is empty" : "has a clip"}`,
);
if (hasClip === 0) {
clipSlot.killChildren();
return;
}
const clip = clipSlot.add(clipId, (colourIndex) => {
log(
`Track ${trackIndex + 1} clip in slot ${clipSlotIndex + 1} has color index ${colourIndex} (pad index ${padIndex})`,
);
sendPadLightMidiMessage(
LightType.on,
padIndex,
launchpadColourIndices[colourIndex],
);
});
if (clip) {
clip.start();
}
});
log("starting to observe slots and clips");
clipSlot.start();
}
}
}

function getPadIndex(trackIndex: number, clipSlotIndex: number) {
return 80 - clipSlotIndex * 10 + trackIndex + 1;
}

function sendPadLightMidiMessage(
lightType: LightType,
position: number,
colourIndex?: number,
) {
switch (lightType) {
case LightType.on:
outlet(0, [144, position, colourIndex]);
break;
case LightType.blink:
outlet(0, [144, position, 0]);
outlet(1, [145, position, colourIndex]);
break;
case LightType.pulse:
outlet(2, [146, position, colourIndex]);
break;
case LightType.off:
outlet(0, [144, position, 0]);
break;
}
}
1 change: 1 addition & 0 deletions src/objects/betterLaunchpadColours/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./betterLaunchpadColours";
Loading