@jeffy-g/live-midi-types 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 jeffy-g
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # **@jeffy-g/live-midi-types** — TypeScript type definitions for Ableton Live MIDI data projects.
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@jeffy-g/live-midi-types.svg)](https://www.npmjs.com/package/@jeffy-g/live-midi-types)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Common TypeScript type definitions for working with Ableton Live MIDI data.
7
+
8
+ > ## Description
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.
11
+
12
+ 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
+
14
+ > ## Installation
15
+
16
+ You can install the package using npm or yarn:
17
+
18
+ ```sh
19
+ npm install @jeffy-g/live-midi-types
20
+ ```
21
+
22
+ or
23
+
24
+ ```sh
25
+ yarn add @jeffy-g/live-midi-types
26
+ ```
27
+
28
+ > ## Usage
29
+
30
+ Import the types you need directly into your TypeScript files.
31
+
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.`);
39
+
40
+ for (const note of clip.notes) {
41
+ logNoteInfo(note);
42
+ }
43
+ }
44
+
45
+ function logNoteInfo(note: NoteEvent) {
46
+ console.log(
47
+ ` - Note Pitch: ${note.pitch}, Velocity: ${note.velocity}, Duration: ${note.duration}`
48
+ );
49
+ }
50
+
51
+ ```
52
+
53
+ > ## Core Types
54
+
55
+ This library exports several key types to model the data within an Ableton Live project.
56
+
57
+ ### MIDI Event Types
58
+
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`.
62
+
63
+ ### MIDI Clip Types
64
+
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.
71
+
72
+ ### Project & UI Types
73
+
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.
77
+
78
+ ### Ableton Color Utilities
79
+
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
+ ```
87
+
88
+ > ## License
89
+
90
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
91
+
92
+ > ## Related Projects
93
+
94
+ - [live-midi-export](https://github.com/jeffy-g/live-midi-export) — CLI tool for extracting MIDI clips from Ableton Live sets.
@@ -0,0 +1,21 @@
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/ableton-colors.ts
10
+ */
11
+ /**
12
+ * Ableton Live color palette.
13
+ * @date 2025/6/27 4:51:48
14
+ */
15
+ export declare const abletonColorPalette: string[];
16
+ /**
17
+ * Get color code from Ableton color index.
18
+ * @param {number} colorIndex Index of Ableton color palette.
19
+ * @returns {string} Hex color code.
20
+ */
21
+ export declare function getColorFromIndex(colorIndex: number): string;
@@ -0,0 +1,34 @@
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/ableton-colors.ts
10
+ */
11
+ /**
12
+ * Ableton Live color palette.
13
+ * @date 2025/6/27 4:51:48
14
+ */
15
+ export const abletonColorPalette = [
16
+ "#ff94a6", "#ffa529", "#cc9927", "#f7f47c", "#bffb00", "#1aff2f", "#25ffa8",
17
+ "#5cffe8", "#8bc5ff", "#5480e4", "#92a7ff", "#d86ce4", "#e553a0", "#ffffff",
18
+ "#ff3636", "#f66c03", "#99724b", "#fff034", "#87ff67", "#3dc300", "#00bfaf",
19
+ "#19e9ff", "#10a4ee", "#007dc0", "#886ce4", "#b677c6", "#ff39d4", "#d0d0d0",
20
+ "#e2675a", "#ffa374", "#d3ad71", "#edffae", "#d2e498", "#bad074", "#9bc48d",
21
+ "#d4fde1", "#cdf1f8", "#b9c1e3", "#cdbbe4", "#ae98e5", "#e5dce1", "#a9a9a9",
22
+ "#c6928b", "#b78256", "#99836a", "#bfba69", "#a6be00", "#7db04d", "#88c2ba",
23
+ "#9bb3c4", "#85a5c2", "#8393cc", "#a595b5", "#bf9fbe", "#bc7196", "#7b7b7b",
24
+ "#af3333", "#a95131", "#724f41", "#dbc300", "#85961f", "#539f31", "#0a9c8e",
25
+ "#236384", "#1a2f96", "#2f52a2", "#624bad", "#a34bad", "#cc2e6e", "#3c3c3c"
26
+ ];
27
+ /**
28
+ * Get color code from Ableton color index.
29
+ * @param {number} colorIndex Index of Ableton color palette.
30
+ * @returns {string} Hex color code.
31
+ */
32
+ export function getColorFromIndex(colorIndex) {
33
+ return abletonColorPalette[colorIndex] ?? "#888"; // fallback gray
34
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./midi-event";
2
+ export * from "./midi-clip";
3
+ export * from "./project";
4
+ export * from "./ableton-colors";
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./midi-event";
2
+ export * from "./midi-clip";
3
+ export * from "./project";
4
+ export * from "./ableton-colors";
@@ -0,0 +1,53 @@
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
+ import type { NoteEvent, ControlChangeEvent } from "./midi-event";
13
+ /**
14
+ * MIDI clip data extracted from Ableton Live's MidiClip object.
15
+ *
16
+ * This type represents all essential information for a single MIDI clip,
17
+ * including note events, control change events, and timing information.
18
+ *
19
+ * ```ts
20
+ * import type { TMidiClipData } from "@jeffy-g/live-midi-types";
21
+ * const data: TMidiClipData = ...;
22
+ * ```
23
+ */
24
+ export type TMidiClipData = {
25
+ /**
26
+ * Start position of the clip on the Live MidiTrack (in beats).
27
+ */
28
+ clipStartInBeats: number;
29
+ /**
30
+ * Length of the clip (in beats).
31
+ */
32
+ clipLength: number;
33
+ /**
34
+ * Time adjustment for tempo mapping (in beats).
35
+ */
36
+ adjustTimeOftempee: number;
37
+ /**
38
+ * color for visualization (Color table index)
39
+ */
40
+ color: string;
41
+ /**
42
+ * Disabled property for the clip.
43
+ */
44
+ disabled: boolean;
45
+ /**
46
+ * Array of extracted note events.
47
+ */
48
+ notes: NoteEvent[];
49
+ /**
50
+ * Array of extracted control change events.
51
+ */
52
+ cc: ControlChangeEvent[];
53
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,66 @@
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-event.ts
10
+ * @summary Common MIDI event types for Ableton Live and related tools.
11
+ */
12
+ export type NoteEvent = {
13
+ /**
14
+ * NOTE: floating number
15
+ */
16
+ time: number;
17
+ /**
18
+ * NOTE: floating number
19
+ */
20
+ duration: number;
21
+ pitch: number;
22
+ /**
23
+ * `0` to `127`
24
+ * NOTE: floating number
25
+ */
26
+ velocity: number;
27
+ };
28
+ export type ControlChangeEvent = {
29
+ /**
30
+ * Time relative to the start of the clip.
31
+ *
32
+ * **This is a floating point number representing the time in quarter notes. (Ableton Live)**
33
+ */
34
+ time: number;
35
+ /**
36
+ * MIDI controller number.
37
+ */
38
+ controller: number;
39
+ /**
40
+ * `0` to `127`
41
+ *
42
+ * Value of the controller (0-127, may be float).
43
+ */
44
+ value: number;
45
+ /**
46
+ * Source type: "curve" for interpolated, "single" for discrete.
47
+ */
48
+ source?: "curve" | "single";
49
+ };
50
+ /**
51
+ * Tempo event object.
52
+ */
53
+ export type TempoEvent = {
54
+ /**
55
+ * Time in quarter notes.
56
+ *
57
+ * 拍ベースのタイムスタンプ(例:4.5 = 4拍と8分音符)
58
+ */
59
+ time: number;
60
+ /**
61
+ * Tempo in BPM.
62
+ *
63
+ * この地点でのテンポ(BPM)
64
+ */
65
+ bpm: number;
66
+ };
@@ -0,0 +1,12 @@
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-event.ts
10
+ * @summary Common MIDI event types for Ableton Live and related tools.
11
+ */
12
+ export {};
@@ -0,0 +1,36 @@
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/project.ts
10
+ */
11
+ export type TMidiClipSummary<T extends Record<string, any>> = {
12
+ /**
13
+ * UI などで使用する時のために付与される ID
14
+ *
15
+ * ```
16
+ * "clip-" + createUUID().toUpperCase()
17
+ * ```
18
+ */
19
+ id: string;
20
+ clipName: string;
21
+ trackName: string;
22
+ } & T;
23
+ export type TTrackInfo<T extends Record<string, any>> = {
24
+ name: string;
25
+ color: string;
26
+ /**
27
+ * ```
28
+ * Record<"clipName", TMidiClipSummary>
29
+ * ```
30
+ */
31
+ clips: Record<string, TMidiClipSummary<T>>;
32
+ };
33
+ export type TParsedLiveAlsProject<T extends Record<string, any>> = {
34
+ ticksPerQuarter: number;
35
+ tracks: TTrackInfo<T>[];
36
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@jeffy-g/live-midi-types",
3
+ "version": "0.1.0",
4
+ "description": "Common TypeScript types for Ableton Live MIDI clip and event data.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "author": "jeffy-g <hirotom1107@gmail.com>",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/jeffy-g/live-midi-types.git"
23
+ },
24
+ "keywords": [
25
+ "ableton",
26
+ "midi",
27
+ "typescript",
28
+ "types",
29
+ "music"
30
+ ],
31
+ "scripts": {
32
+ "prebuild": "rimraf -g ./dist/*",
33
+ "build": "tsc",
34
+ "watch": "tsc -w"
35
+ }
36
+ }