@jeffy-g/live-midi-types 0.8.2 → 0.9.0
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 +11 -1
- package/dist/midi-clip.js +47 -1
- package/dist/midi-event.d.ts +34 -18
- package/dist/midi-event.js +0 -1
- 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.
|
|
15
|
+
export declare const version = "v0.9.0";
|
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.
|
|
15
|
+
export const version = "v0.9.0";
|
package/dist/midi-clip.d.ts
CHANGED
|
@@ -63,7 +63,17 @@ export type TMidiClipData = {
|
|
|
63
63
|
ccMap: Record<string, ControlChangeEvent[]>;
|
|
64
64
|
/**
|
|
65
65
|
* Array of extracted control change events. (flatten {@link TMidiClipData.ccMap __`ccMap`__}, sort by time)
|
|
66
|
+
* + use `flattenCCEventMap` (recommended)
|
|
66
67
|
* @version 0.8.0
|
|
68
|
+
* @see {@link flattenCCEventMap}
|
|
67
69
|
*/
|
|
68
|
-
cc(): ControlChangeEvent[];
|
|
70
|
+
cc?(): ControlChangeEvent[];
|
|
69
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* @param {Record<string, ControlChangeEvent[]>} ccEventMap
|
|
74
|
+
* @param {number[]} knownCCEvents
|
|
75
|
+
*/
|
|
76
|
+
export declare const flattenCCEventMap: (ccEventMap: Record<string, ControlChangeEvent[]>, knownCCEvents: number[]) => ControlChangeEvent[];
|
|
77
|
+
/**
|
|
78
|
+
* @import { ControlChangeEvent } from "./midi-event.ts";
|
|
79
|
+
*/
|
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
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
* @file src/midi-event.ts
|
|
10
10
|
* @summary Common MIDI event types for Ableton Live and related tools.
|
|
11
11
|
*/
|
|
12
|
+
export type BaseEvent = {
|
|
13
|
+
/**
|
|
14
|
+
* Time relative to the start of the clip.
|
|
15
|
+
*
|
|
16
|
+
* **This is a floating point number representing the time in quarter notes. (Ableton Live)**
|
|
17
|
+
*
|
|
18
|
+
* + Beat-based timestamps (e.g. 4.5 = 4 beats and an eighth note)
|
|
19
|
+
*/
|
|
20
|
+
time: number;
|
|
21
|
+
};
|
|
12
22
|
/**
|
|
13
23
|
* ```
|
|
14
24
|
* // Path to `MidiClip` element
|
|
@@ -17,11 +27,7 @@
|
|
|
17
27
|
* `<MidiClip>/Notes/KeyTracks/KeyTrack[]/Notes/MidiNoteEvent[]`
|
|
18
28
|
* ```
|
|
19
29
|
*/
|
|
20
|
-
export type NoteEvent = {
|
|
21
|
-
/**
|
|
22
|
-
* NOTE: floating number
|
|
23
|
-
*/
|
|
24
|
-
time: number;
|
|
30
|
+
export type NoteEvent = BaseEvent & {
|
|
25
31
|
/**
|
|
26
32
|
* NOTE: floating number
|
|
27
33
|
* + quarter-note beats
|
|
@@ -38,13 +44,7 @@ export type NoteEvent = {
|
|
|
38
44
|
*/
|
|
39
45
|
velocity: number;
|
|
40
46
|
};
|
|
41
|
-
export type ControlChangeEvent = {
|
|
42
|
-
/**
|
|
43
|
-
* Time relative to the start of the clip.
|
|
44
|
-
*
|
|
45
|
-
* **This is a floating point number representing the time in quarter notes. (Ableton Live)**
|
|
46
|
-
*/
|
|
47
|
-
time: number;
|
|
47
|
+
export type ControlChangeEvent = BaseEvent & {
|
|
48
48
|
/**
|
|
49
49
|
* MIDI controller number.
|
|
50
50
|
*
|
|
@@ -65,17 +65,33 @@ export type ControlChangeEvent = {
|
|
|
65
65
|
source?: "curve" | "single";
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* @date 2026/09/14 06:21:51
|
|
69
69
|
*/
|
|
70
|
-
export type
|
|
70
|
+
export type ChannelPressureEvent = BaseEvent & {
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* `0` to `127`
|
|
73
73
|
*
|
|
74
|
-
*
|
|
74
|
+
* Value of the ChannelPressure (0-127, floating number).
|
|
75
75
|
*/
|
|
76
|
-
|
|
76
|
+
value: number;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* @date 2026/09/14 06:21:51
|
|
80
|
+
*/
|
|
81
|
+
export type PitchBendEvent = BaseEvent & {
|
|
82
|
+
/**
|
|
83
|
+
* `-8192 to 8191` (Live)
|
|
84
|
+
*
|
|
85
|
+
* Value of the PitchBend (floating number).
|
|
86
|
+
*/
|
|
87
|
+
value: number;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Tempo event object.
|
|
91
|
+
*/
|
|
92
|
+
export type TempoEvent = BaseEvent & {
|
|
77
93
|
/**
|
|
78
|
-
* Tempo in BPM.
|
|
94
|
+
* Tempo in BPM. (floating number)
|
|
79
95
|
*/
|
|
80
96
|
bpm: number;
|
|
81
97
|
};
|
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
|
}
|