@jeffy-g/live-midi-types 0.5.1 → 0.6.1
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/midi-event.d.ts +11 -3
- package/dist/midi-event.js +26 -1
- package/dist/project.d.ts +5 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/midi-event.d.ts
CHANGED
|
@@ -54,13 +54,21 @@ export type TempoEvent = {
|
|
|
54
54
|
/**
|
|
55
55
|
* Time in quarter notes.
|
|
56
56
|
*
|
|
57
|
-
*
|
|
57
|
+
* Beat-based timestamps (e.g. 4.5 = 4 beats and an eighth note)
|
|
58
58
|
*/
|
|
59
59
|
time: number;
|
|
60
60
|
/**
|
|
61
61
|
* Tempo in BPM.
|
|
62
|
-
*
|
|
63
|
-
* この地点でのテンポ(BPM)
|
|
64
62
|
*/
|
|
65
63
|
bpm: number;
|
|
66
64
|
};
|
|
65
|
+
type TEventMap = {
|
|
66
|
+
note: NoteEvent[];
|
|
67
|
+
cc: ControlChangeEvent[];
|
|
68
|
+
tempo: TempoEvent[];
|
|
69
|
+
};
|
|
70
|
+
export declare const eventsIs: <K extends keyof TEventMap>(
|
|
71
|
+
events: unknown[],
|
|
72
|
+
type: K,
|
|
73
|
+
) => events is TEventMap[K];
|
|
74
|
+
export {};
|
package/dist/midi-event.js
CHANGED
|
@@ -9,4 +9,29 @@
|
|
|
9
9
|
* @file src/midi-event.ts
|
|
10
10
|
* @summary Common MIDI event types for Ableton Live and related tools.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
function isObject(value) {
|
|
13
|
+
return typeof value === "object" && value !== null;
|
|
14
|
+
}
|
|
15
|
+
export const eventsIs = (events, type) => {
|
|
16
|
+
const e = events?.[0];
|
|
17
|
+
switch (type) {
|
|
18
|
+
case "note": {
|
|
19
|
+
return (
|
|
20
|
+
isObject(e) &&
|
|
21
|
+
typeof e.pitch === "number" &&
|
|
22
|
+
typeof e.velocity === "number"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
case "cc": {
|
|
26
|
+
return (
|
|
27
|
+
isObject(e) &&
|
|
28
|
+
typeof e.controller === "number" &&
|
|
29
|
+
typeof e.value === "number"
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
default: {
|
|
33
|
+
// tempo
|
|
34
|
+
return typeof e.bpm === "number";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
package/dist/project.d.ts
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
import type { TempoEvent } from "./midi-event.ts";
|
|
12
12
|
export type TClipSummary<T extends Record<string, any>> = {
|
|
13
13
|
/**
|
|
14
|
-
* UI
|
|
14
|
+
* ID assigned for use in UI etc.
|
|
15
15
|
*
|
|
16
16
|
* ```
|
|
17
|
-
* "clip-" +
|
|
17
|
+
* "clip-" + crypto.randomUUID()
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
id: string;
|
|
@@ -28,6 +28,7 @@ export type TClipSummary<T extends Record<string, any>> = {
|
|
|
28
28
|
annotations?: string;
|
|
29
29
|
} & T;
|
|
30
30
|
export type TTrackInfo<T extends Record<string, any>> = {
|
|
31
|
+
id: string;
|
|
31
32
|
name: string;
|
|
32
33
|
color: string;
|
|
33
34
|
annotations?: string;
|
|
@@ -40,8 +41,8 @@ export type TTrackInfo<T extends Record<string, any>> = {
|
|
|
40
41
|
};
|
|
41
42
|
export type TParsedAbletonLiveSet<T extends Record<string, any>> = {
|
|
42
43
|
/**
|
|
43
|
-
* Ableton Live
|
|
44
|
-
*
|
|
44
|
+
* Ableton Live project name
|
|
45
|
+
* Usually the als file name without the extension.
|
|
45
46
|
*/
|
|
46
47
|
alsName: string;
|
|
47
48
|
/**
|