@jeffy-g/live-midi-types 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,5 +28,5 @@ export const abletonColorPalette = "#ff94a6:#ffa529:#cc9927:#f7f47c:#bffb00:#1af
28
28
  * @returns {string} Hex color code.
29
29
  */
30
30
  export function getColorFromIndex(colorIndex) {
31
- return abletonColorPalette[colorIndex] ?? "#888"; // fallback gray
31
+ return abletonColorPalette[colorIndex] ?? "#888";
32
32
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,15 @@
1
+ /*!
2
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ // Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
4
+ // Released under the MIT license
5
+ // https://opensource.org/licenses/mit-license.php
6
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
8
+ /**
9
+ * @file live-midi-types/src/index.ts
10
+ */
1
11
  export * from "./midi-event.js";
2
12
  export * from "./midi-clip.js";
3
13
  export * from "./project.js";
4
14
  export * from "./ableton-colors.js";
5
- export declare const version = "v0.8.2";
15
+ export declare const version = "v0.8.3";
package/dist/index.js CHANGED
@@ -1,5 +1,15 @@
1
+ /*!
2
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ // Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
4
+ // Released under the MIT license
5
+ // https://opensource.org/licenses/mit-license.php
6
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
8
+ /**
9
+ * @file live-midi-types/src/index.ts
10
+ */
1
11
  export * from "./midi-event.js";
2
12
  export * from "./midi-clip.js";
3
13
  export * from "./project.js";
4
14
  export * from "./ableton-colors.js";
5
- export const version = "v0.8.2";
15
+ export const version = "v0.8.3";
@@ -64,6 +64,15 @@ export type TMidiClipData = {
64
64
  /**
65
65
  * Array of extracted control change events. (flatten {@link TMidiClipData.ccMap __`ccMap`__}, sort by time)
66
66
  * @version 0.8.0
67
+ * @see {@link flattenCCEventMap}
67
68
  */
68
- cc(): ControlChangeEvent[];
69
+ cc?(): ControlChangeEvent[];
69
70
  };
71
+ /**
72
+ * @param {Record<string, ControlChangeEvent[]>} ccEventMap
73
+ * @param {number[]} knownCCEvents
74
+ */
75
+ export declare const flattenCCEventMap: (ccEventMap: Record<string, ControlChangeEvent[]>, knownCCEvents: number[]) => ControlChangeEvent[];
76
+ /**
77
+ * @import { ControlChangeEvent } from "./midi-event.ts";
78
+ */
package/dist/midi-clip.js CHANGED
@@ -1 +1,47 @@
1
- export {};
1
+ /*!
2
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ // Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
4
+ // Released under the MIT license
5
+ // https://opensource.org/licenses/mit-license.php
6
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
8
+ /**
9
+ * @file src/midi-clip.ts
10
+ * @summary Common MIDI clip data type for Ableton Live and related tools.
11
+ */
12
+ /**
13
+ * @param {Record<string, ControlChangeEvent[]>} ccEventMap
14
+ * @param {number[]} knownCCEvents
15
+ */
16
+ const getFlattenSize = (ccEventMap, knownCCEvents) => {
17
+ var total = 0;
18
+ for (var idx in knownCCEvents) {
19
+ total += ccEventMap[knownCCEvents[idx]].length;
20
+ }
21
+ return total;
22
+ };
23
+ const warn = console.warn;
24
+ /**
25
+ * @param {Record<string, ControlChangeEvent[]>} ccEventMap
26
+ * @param {number[]} knownCCEvents
27
+ */
28
+ export const flattenCCEventMap = (ccEventMap, knownCCEvents) => {
29
+ var afterFlattenSize = getFlattenSize(ccEventMap, knownCCEvents);
30
+ /** @type {ControlChangeEvent[]} */
31
+ var ccBuffer = Array(afterFlattenSize);
32
+ var bufferIndex = 0;
33
+ for (let idx = 0, ccEventsLen = knownCCEvents.length; idx < ccEventsLen;) {
34
+ let ccEvents = ccEventMap[knownCCEvents[idx++]];
35
+ for (let eventIndex = 0, ccEventsLen = ccEvents.length; eventIndex < ccEventsLen;) {
36
+ ccBuffer[bufferIndex++] = ccEvents[eventIndex++];
37
+ }
38
+ }
39
+ if (bufferIndex !== afterFlattenSize) {
40
+ ccBuffer.length = bufferIndex;
41
+ warn(`⚠️ flattenCCEventMap: afterFlattenSize=${afterFlattenSize} lastSize=${bufferIndex}`);
42
+ }
43
+ return ccBuffer.sort((a, b) => a.time - b.time);
44
+ };
45
+ /**
46
+ * @import { ControlChangeEvent } from "./midi-event.ts";
47
+ */
@@ -33,7 +33,6 @@ export const eventsIs = (events, type) => {
33
33
  return typeof e.pitch === "number" && typeof e.velocity === "number";
34
34
  case "cc":
35
35
  return typeof e.controller === "number" && typeof e.value === "number";
36
- // case "tempo":
37
36
  default:
38
37
  return typeof e.bpm === "number";
39
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffy-g/live-midi-types",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Common TypeScript types for Ableton Live MIDI clip and event data.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",