@jeffy-g/live-midi-types 0.4.1 → 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 CHANGED
@@ -31,61 +31,110 @@ yarn add @jeffy-g/live-midi-types
31
31
 
32
32
  Import the types you need directly into your TypeScript files.
33
33
 
34
- ```typescript
35
- import type { TMidiClipData, NoteEvent } from "@jeffy-g/live-midi-types";
36
-
37
- // Example function that processes MIDI clip data
38
- function processMidiClip(clip: TMidiClipData) {
39
- console.log(`Processing clip starting at ${clip.clipStartInBeats} beats.`);
40
- console.log(`It contains ${clip.notes.length} notes.`);
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
+ ```
41
69
 
42
- for (const note of clip.notes) {
43
- logNoteInfo(note);
44
- }
45
- }
70
+ Ableton Live color palette and utility functions:
46
71
 
47
- function logNoteInfo(note: NoteEvent) {
48
- console.log(
49
- ` - Note Pitch: ${note.pitch}, Velocity: ${note.velocity}, Duration: ${note.duration}`
50
- );
51
- }
72
+ ```ts
73
+ import { abletonColorPalette, getColorFromIndex } from "@jeffy-g/live-midi-types";
52
74
 
75
+ const color: string = getColorFromIndex(5); // "#1aff2f"
53
76
  ```
54
77
 
55
- > ## Core Types
78
+ Project & UI types:
56
79
 
57
- This library exports several key types to model the data within an Ableton Live project.
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
+ ```
109
+
110
+ > ## Core Type Definitions (Reference)
58
111
 
59
112
  ### MIDI Event Types
60
113
 
61
- - **`NoteEvent`**: Represents a single MIDI note with properties for `time`, `duration`, `pitch`, and `velocity`.
62
- - **`ControlChangeEvent`**: Represents a MIDI CC message with `time`, `controller` number, and `value`.
63
- - **`TempoEvent`**: Represents a tempo change event with `time` and `bpm`.
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.
64
117
 
65
118
  ### MIDI Clip Types
66
119
 
67
- - **`TMidiClipData`**: A comprehensive type representing all the essential data extracted from a single MIDI clip in Ableton Live. It includes:
68
- - `clipStartInBeats`: The clip's start time in beats.
69
- - `clipLength`: The clip's duration.
70
- - `notes`: An array of `NoteEvent` objects.
71
- - `cc`: An array of `ControlChangeEvent` objects.
72
- - and other metadata.
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`.
73
127
 
74
128
  ### Project & UI Types
75
129
 
76
- - **`TMidiClipSummary<T>`**: A generic type for creating a summary of a MIDI clip, often used for UI purposes. It includes a unique `id`, `clipName`, and `trackName`.
77
- - **`TTrackInfo<T>`**: Represents the information for a single track, including its `name`, `color`, and a collection of its associated `TMidiClipSummary` objects.
78
- - **`TParsedAbletonLiveSet<T>`**: Represents the entire parsed project, containing `ticksPerQuarter` and an array of `TTrackInfo` objects.
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.
79
133
 
80
134
  ### Ableton Color Utilities
81
135
 
82
- This library also provides a predefined Ableton Live color palette and utility functions.
83
-
84
- ```ts
85
- import { abletonColorPalette, getColorFromIndex } from "@jeffy-g/live-midi-types";
86
-
87
- console.log(getColorFromIndex(5)); // → "#1aff2f"
88
- ```
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").
89
138
 
90
139
  > ## License
91
140
 
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.4.1",
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
  }