@jeffy-g/live-midi-types 0.8.1 → 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.
- package/dist/ableton-colors.js +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +11 -1
- package/dist/midi-clip.d.ts +23 -2
- package/dist/midi-clip.js +47 -1
- package/dist/midi-event.d.ts +7 -1
- package/dist/midi-event.js +0 -1
- package/dist/project.d.ts +5 -5
- package/package.json +1 -1
package/dist/ableton-colors.js
CHANGED
|
@@ -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";
|
|
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.
|
|
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.
|
|
15
|
+
export const version = "v0.8.3";
|
package/dist/midi-clip.d.ts
CHANGED
|
@@ -28,6 +28,18 @@ export type TMidiClipData = {
|
|
|
28
28
|
clipStartInBeats: number;
|
|
29
29
|
/**
|
|
30
30
|
* Length of the clip (in beats). Usually `CurrentEnd.Value - CurrentStart.Value`.
|
|
31
|
+
*
|
|
32
|
+
* ```
|
|
33
|
+
* // e.g. obtain `midiClip` object
|
|
34
|
+
* // xpath: "/Ableton/LiveSet/Tracks/MidiTrack[0]/DeviceChain/MainSequencer/ClipTimeable/ArrangerAutomation/Events/MidiClip[0]"
|
|
35
|
+
* const midiClip = Ableton.LiveSet.Tracks.MidiTrack[0].DeviceChain.MainSequencer.ClipTimeable.ArrangerAutomation.Events.MidiClip[0];
|
|
36
|
+
* // clip start position in Live arrangement view
|
|
37
|
+
* const clipStart = midiClip.CurrentStart.Value;
|
|
38
|
+
* // clip end position in Live arrangement view
|
|
39
|
+
* const clipEnd = midiClip.CurrentEnd.Value;
|
|
40
|
+
* // calculate clip range
|
|
41
|
+
* const clipLength = +clipEnd - +clipStart;
|
|
42
|
+
* ```
|
|
31
43
|
*/
|
|
32
44
|
clipLength: number;
|
|
33
45
|
/**
|
|
@@ -35,7 +47,7 @@ export type TMidiClipData = {
|
|
|
35
47
|
*/
|
|
36
48
|
adjustTimeOftempee: number;
|
|
37
49
|
/**
|
|
38
|
-
*
|
|
50
|
+
* CC numbers known to this clip, sorted in ascending order.
|
|
39
51
|
*
|
|
40
52
|
* {@link TMidiClipData.ccMap __`ccMap`__}
|
|
41
53
|
*/
|
|
@@ -52,6 +64,15 @@ export type TMidiClipData = {
|
|
|
52
64
|
/**
|
|
53
65
|
* Array of extracted control change events. (flatten {@link TMidiClipData.ccMap __`ccMap`__}, sort by time)
|
|
54
66
|
* @version 0.8.0
|
|
67
|
+
* @see {@link flattenCCEventMap}
|
|
55
68
|
*/
|
|
56
|
-
cc(): ControlChangeEvent[];
|
|
69
|
+
cc?(): ControlChangeEvent[];
|
|
57
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
|
-
|
|
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
|
+
*/
|
package/dist/midi-event.d.ts
CHANGED
|
@@ -24,10 +24,12 @@ export type NoteEvent = {
|
|
|
24
24
|
time: number;
|
|
25
25
|
/**
|
|
26
26
|
* NOTE: floating number
|
|
27
|
+
* + quarter-note beats
|
|
27
28
|
*/
|
|
28
29
|
duration: number;
|
|
29
30
|
/**
|
|
30
|
-
* NOTE: Must be an integer. Floating-point values are
|
|
31
|
+
* NOTE: Must be an integer. Floating-point values are invalid.
|
|
32
|
+
* + `0..127` integer
|
|
31
33
|
*/
|
|
32
34
|
pitch: number;
|
|
33
35
|
/**
|
|
@@ -45,6 +47,9 @@ export type ControlChangeEvent = {
|
|
|
45
47
|
time: number;
|
|
46
48
|
/**
|
|
47
49
|
* MIDI controller number.
|
|
50
|
+
*
|
|
51
|
+
* NOTE: Must be an integer. Floating-point values are invalid.
|
|
52
|
+
* + `0..127` integer
|
|
48
53
|
*/
|
|
49
54
|
controller: number;
|
|
50
55
|
/**
|
|
@@ -55,6 +60,7 @@ export type ControlChangeEvent = {
|
|
|
55
60
|
value: number;
|
|
56
61
|
/**
|
|
57
62
|
* Source type: "curve" for interpolated, "single" for discrete.
|
|
63
|
+
* + In **LME**, the "curve" is assigned to Bezier events, while it is omitted in regular discrete events.
|
|
58
64
|
*/
|
|
59
65
|
source?: "curve" | "single";
|
|
60
66
|
};
|
package/dist/midi-event.js
CHANGED
|
@@ -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/dist/project.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export type TClipSummary<T extends Record<string, any>> = {
|
|
|
40
40
|
* "/Ableton/LiveSet/Tracks/MidiTrack/DeviceChain/MainSequencer/ClipTimeable/ArrangerAutomation/Events/MidiClip/Color/@Value"
|
|
41
41
|
*
|
|
42
42
|
* // how to actual color
|
|
43
|
-
* //
|
|
43
|
+
* // e.g - "0" to "#ff94a6", "12" to "#e553a0"
|
|
44
44
|
* const hexColor = getColorFromIndex(+clip.color);
|
|
45
45
|
* ```
|
|
46
46
|
*
|
|
@@ -95,7 +95,7 @@ export type TTrackInfo<T extends Record<string, any>> = {
|
|
|
95
95
|
*
|
|
96
96
|
* ```
|
|
97
97
|
* // e.g.
|
|
98
|
-
* "
|
|
98
|
+
* "track-" + crypto.randomUUID()
|
|
99
99
|
* ```
|
|
100
100
|
*/
|
|
101
101
|
id: string;
|
|
@@ -117,8 +117,8 @@ export type TTrackInfo<T extends Record<string, any>> = {
|
|
|
117
117
|
* "/Ableton/LiveSet/Tracks/MidiTrack/Color/@Value"
|
|
118
118
|
*
|
|
119
119
|
* // Convert the index to a CSS color:
|
|
120
|
-
* //
|
|
121
|
-
* const hexColor = getColorFromIndex(+
|
|
120
|
+
* // e.g - "0" to "#ff94a6", "12" to "#e553a0"
|
|
121
|
+
* const hexColor = getColorFromIndex(+track.color);
|
|
122
122
|
* ```
|
|
123
123
|
* @see {@link getColorFromIndex}
|
|
124
124
|
*/
|
|
@@ -134,7 +134,7 @@ export type TTrackInfo<T extends Record<string, any>> = {
|
|
|
134
134
|
*/
|
|
135
135
|
annotation: string;
|
|
136
136
|
/**
|
|
137
|
-
* MIDI clips indexed by
|
|
137
|
+
* MIDI clips indexed by {@linkcode TClipSummary.id TClipSummary.id}
|
|
138
138
|
*/
|
|
139
139
|
clips: Record<string, TClipSummary<T>>;
|
|
140
140
|
};
|