@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 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. 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.
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
- ```typescript
33
- import type { TMidiClipData, NoteEvent } from "@jeffy-g/live-midi-types";
34
-
35
- // Example function that processes MIDI clip data
36
- function processMidiClip(clip: TMidiClipData) {
37
- console.log(`Processing clip starting at ${clip.clipStartInBeats} beats.`);
38
- 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
+ ```
39
69
 
40
- for (const note of clip.notes) {
41
- logNoteInfo(note);
42
- }
43
- }
70
+ Ableton Live color palette and utility functions:
44
71
 
45
- function logNoteInfo(note: NoteEvent) {
46
- console.log(
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
- > ## Core Types
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
- This library exports several key types to model the data within an Ableton Live project.
110
+ > ## Core Type Definitions (Reference)
56
111
 
57
112
  ### MIDI Event Types
58
113
 
59
- - **`NoteEvent`**: Represents a single MIDI note with properties for `time`, `duration`, `pitch`, and `velocity`.
60
- - **`ControlChangeEvent`**: Represents a MIDI CC message with `time`, `controller` number, and `value`.
61
- - **`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.
62
117
 
63
118
  ### MIDI Clip Types
64
119
 
65
- - **`TMidiClipData`**: A comprehensive type representing all the essential data extracted from a single MIDI clip in Ableton Live. It includes:
66
- - `clipStartInBeats`: The clip's start time in beats.
67
- - `clipLength`: The clip's duration.
68
- - `notes`: An array of `NoteEvent` objects.
69
- - `cc`: An array of `ControlChangeEvent` objects.
70
- - 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`.
71
127
 
72
128
  ### Project & UI Types
73
129
 
74
- - **`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`.
75
- - **`TTrackInfo<T>`**: Represents the information for a single track, including its `name`, `color`, and a collection of its associated `TMidiClipSummary` objects.
76
- - **`TParsedLiveAlsProject<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.
77
133
 
78
134
  ### Ableton Color Utilities
79
135
 
80
- This library also provides a predefined Ableton Live color palette and utility functions.
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
 
@@ -34,6 +34,10 @@ export type TMidiClipData = {
34
34
  * Time adjustment for tempo mapping (in beats).
35
35
  */
36
36
  adjustTimeOftempee: number;
37
+ /**
38
+ * List of known CC events in this clip.
39
+ */
40
+ knownCCEvents: number[];
37
41
  /**
38
42
  * Array of extracted note events.
39
43
  */
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.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
  }