@jeffy-g/live-midi-types 0.3.0 → 0.5.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/README.md +89 -38
- package/dist/midi-clip.d.ts +4 -0
- package/dist/project.d.ts +5 -0
- package/package.json +2 -8
package/README.md
CHANGED
|
@@ -7,7 +7,9 @@ Common TypeScript type definitions for working with Ableton Live MIDI data.
|
|
|
7
7
|
|
|
8
8
|
> ## Description
|
|
9
9
|
|
|
10
|
-
This package provides a centralized collection of TypeScript type definitions for working with data extracted from Ableton Live Set (`.als`) files.
|
|
10
|
+
This package provides a centralized collection of TypeScript type definitions for working with data extracted from Ableton Live Set (`.als`) files.
|
|
11
|
+
|
|
12
|
+
It is designed to ensure type safety and data consistency across projects that handle Ableton Live's MIDI data, such as the `live-midi-export` tool.
|
|
11
13
|
|
|
12
14
|
By providing a single source of truth for data structures, this library simplifies development and reduces errors when passing MIDI and project data between different modules.
|
|
13
15
|
|
|
@@ -29,61 +31,110 @@ yarn add @jeffy-g/live-midi-types
|
|
|
29
31
|
|
|
30
32
|
Import the types you need directly into your TypeScript files.
|
|
31
33
|
|
|
32
|
-
```
|
|
33
|
-
import type { TMidiClipData, NoteEvent } from "@jeffy-g/live-midi-types";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
```ts
|
|
35
|
+
import type { TMidiClipData, NoteEvent, ControlChangeEvent, TempoEvent } from "@jeffy-g/live-midi-types";
|
|
36
|
+
|
|
37
|
+
/** @type {NoteEvent} */
|
|
38
|
+
const note = {
|
|
39
|
+
time: 0.0,
|
|
40
|
+
duration: 1.0,
|
|
41
|
+
pitch: 60,
|
|
42
|
+
velocity: 100
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** @type {ControlChangeEvent} */
|
|
46
|
+
const cc = {
|
|
47
|
+
time: 0.5,
|
|
48
|
+
controller: 64,
|
|
49
|
+
value: 127,
|
|
50
|
+
source: "single"
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** @type {TempoEvent} */
|
|
54
|
+
const tempo = {
|
|
55
|
+
time: 0.0,
|
|
56
|
+
bpm: 120
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** @type {TMidiClipData} */
|
|
60
|
+
const clip = {
|
|
61
|
+
clipStartInBeats: 0,
|
|
62
|
+
clipLength: 16,
|
|
63
|
+
adjustTimeOftempee: 0,
|
|
64
|
+
knownCCEvents: [64, 1],
|
|
65
|
+
notes: [note],
|
|
66
|
+
cc: [cc]
|
|
67
|
+
};
|
|
68
|
+
```
|
|
39
69
|
|
|
40
|
-
|
|
41
|
-
logNoteInfo(note);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
70
|
+
Ableton Live color palette and utility functions:
|
|
44
71
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
` - Note Pitch: ${note.pitch}, Velocity: ${note.velocity}, Duration: ${note.duration}`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
72
|
+
```ts
|
|
73
|
+
import { abletonColorPalette, getColorFromIndex } from "@jeffy-g/live-midi-types";
|
|
50
74
|
|
|
75
|
+
const color: string = getColorFromIndex(5); // "#1aff2f"
|
|
51
76
|
```
|
|
52
77
|
|
|
53
|
-
|
|
78
|
+
Project & UI types:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import type { TClipSummary, TTrackInfo, TParsedAbletonLiveSet } from "@jeffy-g/live-midi-types";
|
|
82
|
+
|
|
83
|
+
/** @type {TClipSummary<{custom: string}>} */
|
|
84
|
+
const clipSummary = {
|
|
85
|
+
id: "clip-XXXX",
|
|
86
|
+
color: "#ff94a6",
|
|
87
|
+
disabled: false,
|
|
88
|
+
clipName: "Piano",
|
|
89
|
+
trackName: "Track 1",
|
|
90
|
+
custom: "meta"
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** @type {TTrackInfo<{custom: string}>} */
|
|
94
|
+
const trackInfo = {
|
|
95
|
+
name: "Track 1",
|
|
96
|
+
color: "#ff94a6",
|
|
97
|
+
clips: {
|
|
98
|
+
"Piano": clipSummary
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** @type {TParsedAbletonLiveSet<{custom: string}>} */
|
|
103
|
+
const project = {
|
|
104
|
+
alsName: "MyProject",
|
|
105
|
+
ticksPerQuarter: 480,
|
|
106
|
+
tracks: [trackInfo]
|
|
107
|
+
};
|
|
108
|
+
```
|
|
54
109
|
|
|
55
|
-
|
|
110
|
+
> ## Core Type Definitions (Reference)
|
|
56
111
|
|
|
57
112
|
### MIDI Event Types
|
|
58
113
|
|
|
59
|
-
- **`NoteEvent`**: Represents a single MIDI note
|
|
60
|
-
- **`ControlChangeEvent`**:
|
|
61
|
-
- **`TempoEvent`**:
|
|
114
|
+
- **`NoteEvent`**: `{ time: number; duration: number; pitch: number; velocity: number; }` — Represents a single MIDI note. All values are float except pitch (int).
|
|
115
|
+
- **`ControlChangeEvent`**: `{ time: number; controller: number; value: number; source?: "curve" | "single"; }` — MIDI CC message, with optional source type.
|
|
116
|
+
- **`TempoEvent`**: `{ time: number; bpm: number; }` — Tempo change event.
|
|
62
117
|
|
|
63
118
|
### MIDI Clip Types
|
|
64
119
|
|
|
65
|
-
- **`TMidiClipData`**:
|
|
66
|
-
- `clipStartInBeats`:
|
|
67
|
-
- `clipLength`:
|
|
68
|
-
- `
|
|
69
|
-
- `
|
|
70
|
-
-
|
|
120
|
+
- **`TMidiClipData`**: Represents all essential data for a single MIDI clip.
|
|
121
|
+
- `clipStartInBeats`: Start time in beats.
|
|
122
|
+
- `clipLength`: Duration in beats.
|
|
123
|
+
- `adjustTimeOftempee`: Time adjustment for tempo mapping.
|
|
124
|
+
- `knownCCEvents`: Array of CC numbers present in the clip.
|
|
125
|
+
- `notes`: Array of `NoteEvent`.
|
|
126
|
+
- `cc`: Array of `ControlChangeEvent`.
|
|
71
127
|
|
|
72
128
|
### Project & UI Types
|
|
73
129
|
|
|
74
|
-
- **`
|
|
75
|
-
- **`TTrackInfo<T>`**:
|
|
76
|
-
- **`
|
|
130
|
+
- **`TClipSummary<T>`**: Generic summary type for a clip, with `id`, `color`, `clipName`, `trackName`, and custom fields.
|
|
131
|
+
- **`TTrackInfo<T>`**: Track info type, with `name`, `color`, and a collection of `TClipSummary` objects.
|
|
132
|
+
- **`TParsedAbletonLiveSet<T>`**: Parsed project type, with `alsName`, `ticksPerQuarter`, and array of tracks.
|
|
77
133
|
|
|
78
134
|
### Ableton Color Utilities
|
|
79
135
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
```ts
|
|
83
|
-
import { abletonColorPalette, getColorFromIndex } from "@jeffy-g/live-midi-types";
|
|
84
|
-
|
|
85
|
-
console.log(getColorFromIndex(5)); // → "#1aff2f"
|
|
86
|
-
```
|
|
136
|
+
- **`abletonColorPalette`**: Array of 70+ Ableton Live color hex codes.
|
|
137
|
+
- **`getColorFromIndex(index: number): string`**: Returns color code for given index, fallback is gray ("#888").
|
|
87
138
|
|
|
88
139
|
> ## License
|
|
89
140
|
|
package/dist/midi-clip.d.ts
CHANGED
package/dist/project.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* @file src/project.ts
|
|
10
10
|
*/
|
|
11
|
+
import type { TempoEvent } from "./midi-event.ts";
|
|
11
12
|
export type TClipSummary<T extends Record<string, any>> = {
|
|
12
13
|
/**
|
|
13
14
|
* UI などで使用する時のために付与される ID
|
|
@@ -52,4 +53,8 @@ export type TParsedAbletonLiveSet<T extends Record<string, any>> = {
|
|
|
52
53
|
* NOTE: currently, this is a Midi tracks only.
|
|
53
54
|
*/
|
|
54
55
|
tracks: TTrackInfo<T>[];
|
|
56
|
+
/**
|
|
57
|
+
* Tempo automation events.
|
|
58
|
+
*/
|
|
59
|
+
tempoAutomation?: TempoEvent[];
|
|
55
60
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffy-g/live-midi-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Common TypeScript types for Ableton Live MIDI clip and event data.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,11 +27,5 @@
|
|
|
27
27
|
"typescript",
|
|
28
28
|
"types",
|
|
29
29
|
"music"
|
|
30
|
-
]
|
|
31
|
-
"scripts": {
|
|
32
|
-
"prebuild": "rimraf -g ./dist/*",
|
|
33
|
-
"format": "prettier --tab-width 2 -w \"./dist/**/*\"",
|
|
34
|
-
"build": "tsc",
|
|
35
|
-
"watch": "tsc -w"
|
|
36
|
-
}
|
|
30
|
+
]
|
|
37
31
|
}
|