ableton-js 2.4.0 → 2.5.2
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/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/index.d.ts +2 -0
- package/index.js +5 -1
- package/midi-script/AbletonJS.py +15 -1
- package/midi-script/DeviceParameter.py +0 -6
- package/midi-script/Internal.py +1 -1
- package/midi-script/Midi.py +55 -0
- package/midi-script/Track.py +7 -0
- package/ns/device-parameter.d.ts +6 -6
- package/ns/device-parameter.js +6 -6
- package/ns/midi.d.ts +63 -0
- package/ns/midi.js +100 -0
- package/ns/track.d.ts +1 -0
- package/ns/track.js +6 -0
- package/package.json +2 -9
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,30 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v2.5.2](https://github.com/leolabs/ableton.js/compare/v2.5.1...v2.5.2)
|
|
8
|
+
|
|
9
|
+
- :mute: Don't emit errors when received events can't be assigned to any listener [`da32ca5`](https://github.com/leolabs/ableton.js/commit/da32ca5924df0ffb20fab981e0e98bb606cbef4a)
|
|
10
|
+
|
|
11
|
+
#### [v2.5.1](https://github.com/leolabs/ableton.js/compare/v2.5.0...v2.5.1)
|
|
12
|
+
|
|
13
|
+
> 7 August 2022
|
|
14
|
+
|
|
15
|
+
- Remove unused devDependencies [`6491216`](https://github.com/leolabs/ableton.js/commit/6491216bff5f1fed8ca20ad00105022eeb44c656)
|
|
16
|
+
- :bug: Fix AutomationState and ParameterState being incorrect [`431d377`](https://github.com/leolabs/ableton.js/commit/431d377a1526ec02369df54e1826d19901950666)
|
|
17
|
+
|
|
18
|
+
#### [v2.5.0](https://github.com/leolabs/ableton.js/compare/v2.4.0...v2.5.0)
|
|
19
|
+
|
|
20
|
+
> 8 July 2022
|
|
21
|
+
|
|
22
|
+
- adds support for getting the group_track property from a Track object [`#46`](https://github.com/leolabs/ableton.js/pull/46)
|
|
23
|
+
- Forward requested midi cc and note messages [`#48`](https://github.com/leolabs/ableton.js/pull/48)
|
|
24
|
+
- add Track's `duplicate_clip_to_arrangement` method [`#49`](https://github.com/leolabs/ableton.js/pull/49)
|
|
25
|
+
- Create LICENSE [`3f42141`](https://github.com/leolabs/ableton.js/commit/3f42141f33fc5b13eea2c46675c72182ec691bfb)
|
|
26
|
+
|
|
7
27
|
#### [v2.4.0](https://github.com/leolabs/ableton.js/compare/v2.3.4...v2.4.0)
|
|
8
28
|
|
|
29
|
+
> 21 May 2022
|
|
30
|
+
|
|
9
31
|
- :wrench: Use ports 39031 and 39041 to avoid collisions with other applications [`e3bd84c`](https://github.com/leolabs/ableton.js/commit/e3bd84cadf92af5d648533fd656c90722f5d8ab2)
|
|
10
32
|
- :sparkles: Run the heartbeat check once after initializing the class [`8db0bd6`](https://github.com/leolabs/ableton.js/commit/8db0bd66f5dec534f38c1319cacd2cc91da89f6a)
|
|
11
33
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Leo Bernard
|
|
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/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { EventEmitter } from "events";
|
|
|
3
3
|
import { Song } from "./ns/song";
|
|
4
4
|
import { Internal } from "./ns/internal";
|
|
5
5
|
import { Application } from "./ns/application";
|
|
6
|
+
import { Midi } from "./ns/midi";
|
|
6
7
|
interface Command {
|
|
7
8
|
uuid: string;
|
|
8
9
|
ns: string;
|
|
@@ -45,6 +46,7 @@ export declare class Ableton extends EventEmitter implements ConnectionEventEmit
|
|
|
45
46
|
song: Song;
|
|
46
47
|
application: Application;
|
|
47
48
|
internal: Internal;
|
|
49
|
+
midi: Midi;
|
|
48
50
|
constructor(host?: string, sendPort?: number, listenPort?: number, heartbeatInterval?: number);
|
|
49
51
|
close(): void;
|
|
50
52
|
/**
|
package/index.js
CHANGED
|
@@ -68,6 +68,7 @@ var zlib_1 = require("zlib");
|
|
|
68
68
|
var song_1 = require("./ns/song");
|
|
69
69
|
var internal_1 = require("./ns/internal");
|
|
70
70
|
var application_1 = require("./ns/application");
|
|
71
|
+
var midi_1 = require("./ns/midi");
|
|
71
72
|
var package_version_1 = require("./util/package-version");
|
|
72
73
|
var TimeoutError = /** @class */ (function (_super) {
|
|
73
74
|
__extends(TimeoutError, _super);
|
|
@@ -100,6 +101,7 @@ var Ableton = /** @class */ (function (_super) {
|
|
|
100
101
|
_this.song = new song_1.Song(_this);
|
|
101
102
|
_this.application = new application_1.Application(_this);
|
|
102
103
|
_this.internal = new internal_1.Internal(_this);
|
|
104
|
+
_this.midi = new midi_1.Midi(_this);
|
|
103
105
|
_this.client = dgram_1.default.createSocket({ type: "udp4" });
|
|
104
106
|
_this.client.bind(_this.listenPort, host);
|
|
105
107
|
_this.client.addListener("message", _this.handleIncoming.bind(_this));
|
|
@@ -215,7 +217,9 @@ var Ableton = /** @class */ (function (_super) {
|
|
|
215
217
|
if (eventCallback) {
|
|
216
218
|
return eventCallback.forEach(function (cb) { return cb(data.data); });
|
|
217
219
|
}
|
|
218
|
-
|
|
220
|
+
if (data.uuid) {
|
|
221
|
+
this.emit("error", "Message could not be assigned to any request: " + msg);
|
|
222
|
+
}
|
|
219
223
|
};
|
|
220
224
|
/**
|
|
221
225
|
* Sends a raw command to Ableton. Usually, you won't need this.
|
package/midi-script/AbletonJS.py
CHANGED
|
@@ -14,6 +14,7 @@ from .Track import Track
|
|
|
14
14
|
from .Internal import Internal
|
|
15
15
|
from .ClipSlot import ClipSlot
|
|
16
16
|
from .Clip import Clip
|
|
17
|
+
from .Midi import Midi
|
|
17
18
|
from _Framework.ControlSurface import ControlSurface
|
|
18
19
|
import Live
|
|
19
20
|
|
|
@@ -21,6 +22,7 @@ import Live
|
|
|
21
22
|
class AbletonJS(ControlSurface):
|
|
22
23
|
def __init__(self, c_instance):
|
|
23
24
|
super(AbletonJS, self).__init__(c_instance)
|
|
25
|
+
self.tracked_midi = set()
|
|
24
26
|
|
|
25
27
|
Socket.set_log(self.log_message)
|
|
26
28
|
Socket.set_message(self.show_message)
|
|
@@ -37,7 +39,8 @@ class AbletonJS(ControlSurface):
|
|
|
37
39
|
"song-view": SongView(c_instance, self.socket),
|
|
38
40
|
"track": Track(c_instance, self.socket),
|
|
39
41
|
"clip_slot": ClipSlot(c_instance, self.socket),
|
|
40
|
-
"clip": Clip(c_instance, self.socket)
|
|
42
|
+
"clip": Clip(c_instance, self.socket),
|
|
43
|
+
"midi": Midi(c_instance, self.socket, self.tracked_midi, self.request_rebuild_midi_map)
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
self.recv_loop = Live.Base.Timer(
|
|
@@ -47,6 +50,17 @@ class AbletonJS(ControlSurface):
|
|
|
47
50
|
|
|
48
51
|
self.socket.send("connect")
|
|
49
52
|
|
|
53
|
+
def build_midi_map(self, midi_map_handle):
|
|
54
|
+
script_handle = self._c_instance.handle()
|
|
55
|
+
for midi in self.tracked_midi:
|
|
56
|
+
if midi[0] == "cc":
|
|
57
|
+
Live.MidiMap.forward_midi_cc(script_handle, midi_map_handle, midi[1], midi[2])
|
|
58
|
+
elif midi[0] == "note":
|
|
59
|
+
Live.MidiMap.forward_midi_note(script_handle, midi_map_handle, midi[1], midi[2])
|
|
60
|
+
|
|
61
|
+
def receive_midi(self, midi_bytes):
|
|
62
|
+
self.handlers["midi"].send_midi(midi_bytes)
|
|
63
|
+
|
|
50
64
|
def disconnect(self):
|
|
51
65
|
self.log_message("Disconnecting")
|
|
52
66
|
self.recv_loop.stop()
|
|
@@ -19,11 +19,5 @@ class DeviceParameter(Interface):
|
|
|
19
19
|
def __init__(self, c_instance, socket):
|
|
20
20
|
super(DeviceParameter, self).__init__(c_instance, socket)
|
|
21
21
|
|
|
22
|
-
def get_automation_state(self, ns):
|
|
23
|
-
return str(ns.automation_state)
|
|
24
|
-
|
|
25
|
-
def get_state(self, ns):
|
|
26
|
-
return str(ns.state)
|
|
27
|
-
|
|
28
22
|
def get_value_items(self, ns):
|
|
29
23
|
return list(ns.value_items)
|
package/midi-script/Internal.py
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
|
|
3
|
+
from .Interface import Interface
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Midi(Interface):
|
|
7
|
+
event_id = None
|
|
8
|
+
|
|
9
|
+
def __init__(self, c_instance, socket, tracked_midi, update_midi_callback):
|
|
10
|
+
super(Midi, self).__init__(c_instance, socket)
|
|
11
|
+
self.outputs = set()
|
|
12
|
+
self.tracked_midi = tracked_midi
|
|
13
|
+
self.update_midi = update_midi_callback
|
|
14
|
+
|
|
15
|
+
def get_ns(self, nsid):
|
|
16
|
+
return self
|
|
17
|
+
|
|
18
|
+
def set_midi_outputs(self, ns, outputs):
|
|
19
|
+
self.outputs.clear()
|
|
20
|
+
for output in outputs:
|
|
21
|
+
try:
|
|
22
|
+
midi_type = output.get("type")
|
|
23
|
+
if midi_type != "cc" and midi_type != "note":
|
|
24
|
+
raise ValueError("invalid midi type " + str(midi_type))
|
|
25
|
+
self.outputs.add((midi_type, output.get("channel"), output.get("target")))
|
|
26
|
+
except ValueError as e:
|
|
27
|
+
self.log_message(e)
|
|
28
|
+
except:
|
|
29
|
+
self.log_message("invalid midi output requested: " + str(output))
|
|
30
|
+
|
|
31
|
+
def remove_midi_listener(self, fn):
|
|
32
|
+
self.event_id = None
|
|
33
|
+
self.tracked_midi.clear()
|
|
34
|
+
self.update_midi()
|
|
35
|
+
|
|
36
|
+
def add_listener(self, ns, prop, eventId, nsid="Default"):
|
|
37
|
+
if prop != "midi":
|
|
38
|
+
raise Exception("Listener " + str(prop) + " does not exist.")
|
|
39
|
+
|
|
40
|
+
if self.event_id is not None:
|
|
41
|
+
self.log_message("midi listener already exists")
|
|
42
|
+
return self.event_id
|
|
43
|
+
|
|
44
|
+
self.log_message("Attaching midi listener")
|
|
45
|
+
|
|
46
|
+
self.tracked_midi.clear()
|
|
47
|
+
self.tracked_midi.update(self.outputs)
|
|
48
|
+
self.update_midi()
|
|
49
|
+
self.event_id = eventId
|
|
50
|
+
|
|
51
|
+
return eventId
|
|
52
|
+
|
|
53
|
+
def send_midi(self, midi_bytes):
|
|
54
|
+
if self.event_id is not None:
|
|
55
|
+
self.socket.send(self.event_id, {"bytes": midi_bytes})
|
package/midi-script/Track.py
CHANGED
|
@@ -25,3 +25,10 @@ class Track(Interface):
|
|
|
25
25
|
|
|
26
26
|
def get_clip_slots(self, ns):
|
|
27
27
|
return list(map(ClipSlot.serialize_clip_slot, ns.clip_slots))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_group_track(self, ns):
|
|
31
|
+
return Track.serialize_track(ns.group_track)
|
|
32
|
+
|
|
33
|
+
def duplicate_clip_to_arrangement(self, ns, clip_id, time):
|
|
34
|
+
return ns.duplicate_clip_to_arrangement(self.get_obj(clip_id), time)
|
package/ns/device-parameter.d.ts
CHANGED
|
@@ -31,14 +31,14 @@ export interface RawDeviceParameter {
|
|
|
31
31
|
is_quantized: boolean;
|
|
32
32
|
}
|
|
33
33
|
export declare enum AutomationState {
|
|
34
|
-
None =
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
None = 0,
|
|
35
|
+
Playing = 1,
|
|
36
|
+
Overridden = 2
|
|
37
37
|
}
|
|
38
38
|
export declare enum ParameterState {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Irrelevant =
|
|
39
|
+
Enabled = 0,
|
|
40
|
+
Disabled = 1,
|
|
41
|
+
Irrelevant = 2
|
|
42
42
|
}
|
|
43
43
|
export declare class DeviceParameter extends Namespace<GettableProperties, TransformedProperties, SettableProperties, ObservableProperties> {
|
|
44
44
|
raw: RawDeviceParameter;
|
package/ns/device-parameter.js
CHANGED
|
@@ -19,15 +19,15 @@ exports.DeviceParameter = exports.ParameterState = exports.AutomationState = voi
|
|
|
19
19
|
var _1 = require(".");
|
|
20
20
|
var AutomationState;
|
|
21
21
|
(function (AutomationState) {
|
|
22
|
-
AutomationState["None"] = "
|
|
23
|
-
AutomationState["
|
|
24
|
-
AutomationState["
|
|
22
|
+
AutomationState[AutomationState["None"] = 0] = "None";
|
|
23
|
+
AutomationState[AutomationState["Playing"] = 1] = "Playing";
|
|
24
|
+
AutomationState[AutomationState["Overridden"] = 2] = "Overridden";
|
|
25
25
|
})(AutomationState = exports.AutomationState || (exports.AutomationState = {}));
|
|
26
26
|
var ParameterState;
|
|
27
27
|
(function (ParameterState) {
|
|
28
|
-
ParameterState["
|
|
29
|
-
ParameterState["
|
|
30
|
-
ParameterState["Irrelevant"] = "
|
|
28
|
+
ParameterState[ParameterState["Enabled"] = 0] = "Enabled";
|
|
29
|
+
ParameterState[ParameterState["Disabled"] = 1] = "Disabled";
|
|
30
|
+
ParameterState[ParameterState["Irrelevant"] = 2] = "Irrelevant";
|
|
31
31
|
})(ParameterState = exports.ParameterState || (exports.ParameterState = {}));
|
|
32
32
|
var DeviceParameter = /** @class */ (function (_super) {
|
|
33
33
|
__extends(DeviceParameter, _super);
|
package/ns/midi.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Namespace } from "./index";
|
|
2
|
+
import { Ableton } from "../index";
|
|
3
|
+
export declare enum MidiCommand {
|
|
4
|
+
NoteOn = 128,
|
|
5
|
+
NoteOff = 144,
|
|
6
|
+
AfterTouch = 160,
|
|
7
|
+
ControlChange = 176,
|
|
8
|
+
PatchChange = 192,
|
|
9
|
+
ChannelPressure = 208,
|
|
10
|
+
PitchBend = 224,
|
|
11
|
+
SysExStart = 240,
|
|
12
|
+
MidiTimeCodeQuarterFrame = 241,
|
|
13
|
+
SongPositionPointer = 242,
|
|
14
|
+
SongSelect = 243,
|
|
15
|
+
TuneRequest = 246,
|
|
16
|
+
SysExEnd = 247,
|
|
17
|
+
TimingClock = 248,
|
|
18
|
+
Start = 250,
|
|
19
|
+
Continue = 251,
|
|
20
|
+
Stop = 252,
|
|
21
|
+
ActiveSensing = 254,
|
|
22
|
+
SystemReset = 255
|
|
23
|
+
}
|
|
24
|
+
export interface MidiMapping {
|
|
25
|
+
type: "cc" | "note";
|
|
26
|
+
channel: number;
|
|
27
|
+
target: number;
|
|
28
|
+
}
|
|
29
|
+
export interface MidiNote {
|
|
30
|
+
command: MidiCommand.NoteOn | MidiCommand.NoteOff;
|
|
31
|
+
key: number;
|
|
32
|
+
velocity: number;
|
|
33
|
+
}
|
|
34
|
+
export interface MidiCC {
|
|
35
|
+
command: MidiCommand.ControlChange;
|
|
36
|
+
controller: number;
|
|
37
|
+
value: number;
|
|
38
|
+
}
|
|
39
|
+
export declare class MidiMessage {
|
|
40
|
+
command: MidiCommand;
|
|
41
|
+
parameter1: number | null;
|
|
42
|
+
parameter2: number | null;
|
|
43
|
+
constructor(raw: RawMidiMessage);
|
|
44
|
+
toCC(): MidiCC;
|
|
45
|
+
toNote(): MidiNote;
|
|
46
|
+
}
|
|
47
|
+
export interface RawMidiMessage {
|
|
48
|
+
bytes: number[];
|
|
49
|
+
}
|
|
50
|
+
export interface GettableProperties {
|
|
51
|
+
}
|
|
52
|
+
export interface TransformedProperties {
|
|
53
|
+
midi: MidiMessage;
|
|
54
|
+
}
|
|
55
|
+
export interface SettableProperties {
|
|
56
|
+
midi_outputs: MidiMapping[];
|
|
57
|
+
}
|
|
58
|
+
export interface ObservableProperties {
|
|
59
|
+
midi: RawMidiMessage;
|
|
60
|
+
}
|
|
61
|
+
export declare class Midi extends Namespace<GettableProperties, TransformedProperties, SettableProperties, ObservableProperties> {
|
|
62
|
+
constructor(ableton: Ableton);
|
|
63
|
+
}
|
package/ns/midi.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.Midi = exports.MidiMessage = exports.MidiCommand = void 0;
|
|
19
|
+
var index_1 = require("./index");
|
|
20
|
+
var MidiCommand;
|
|
21
|
+
(function (MidiCommand) {
|
|
22
|
+
MidiCommand[MidiCommand["NoteOn"] = 128] = "NoteOn";
|
|
23
|
+
MidiCommand[MidiCommand["NoteOff"] = 144] = "NoteOff";
|
|
24
|
+
MidiCommand[MidiCommand["AfterTouch"] = 160] = "AfterTouch";
|
|
25
|
+
MidiCommand[MidiCommand["ControlChange"] = 176] = "ControlChange";
|
|
26
|
+
MidiCommand[MidiCommand["PatchChange"] = 192] = "PatchChange";
|
|
27
|
+
MidiCommand[MidiCommand["ChannelPressure"] = 208] = "ChannelPressure";
|
|
28
|
+
MidiCommand[MidiCommand["PitchBend"] = 224] = "PitchBend";
|
|
29
|
+
MidiCommand[MidiCommand["SysExStart"] = 240] = "SysExStart";
|
|
30
|
+
MidiCommand[MidiCommand["MidiTimeCodeQuarterFrame"] = 241] = "MidiTimeCodeQuarterFrame";
|
|
31
|
+
MidiCommand[MidiCommand["SongPositionPointer"] = 242] = "SongPositionPointer";
|
|
32
|
+
MidiCommand[MidiCommand["SongSelect"] = 243] = "SongSelect";
|
|
33
|
+
MidiCommand[MidiCommand["TuneRequest"] = 246] = "TuneRequest";
|
|
34
|
+
MidiCommand[MidiCommand["SysExEnd"] = 247] = "SysExEnd";
|
|
35
|
+
MidiCommand[MidiCommand["TimingClock"] = 248] = "TimingClock";
|
|
36
|
+
MidiCommand[MidiCommand["Start"] = 250] = "Start";
|
|
37
|
+
MidiCommand[MidiCommand["Continue"] = 251] = "Continue";
|
|
38
|
+
MidiCommand[MidiCommand["Stop"] = 252] = "Stop";
|
|
39
|
+
MidiCommand[MidiCommand["ActiveSensing"] = 254] = "ActiveSensing";
|
|
40
|
+
MidiCommand[MidiCommand["SystemReset"] = 255] = "SystemReset";
|
|
41
|
+
})(MidiCommand = exports.MidiCommand || (exports.MidiCommand = {}));
|
|
42
|
+
var MidiMessage = /** @class */ (function () {
|
|
43
|
+
function MidiMessage(raw) {
|
|
44
|
+
this.parameter1 = null;
|
|
45
|
+
this.parameter2 = null;
|
|
46
|
+
switch (raw.bytes.length) {
|
|
47
|
+
case 0:
|
|
48
|
+
throw "bytes missing from midi message";
|
|
49
|
+
case 3:
|
|
50
|
+
this.parameter1 = raw.bytes[1];
|
|
51
|
+
this.parameter2 = raw.bytes[2];
|
|
52
|
+
break;
|
|
53
|
+
case 2:
|
|
54
|
+
this.parameter1 = raw.bytes[1];
|
|
55
|
+
break;
|
|
56
|
+
case 1:
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
throw "invalid midi message length: " + raw.bytes.length;
|
|
60
|
+
}
|
|
61
|
+
if (!(raw.bytes[0] in MidiCommand)) {
|
|
62
|
+
throw "invalid midi command: " + raw.bytes[0];
|
|
63
|
+
}
|
|
64
|
+
this.command = raw.bytes[0];
|
|
65
|
+
}
|
|
66
|
+
MidiMessage.prototype.toCC = function () {
|
|
67
|
+
if (this.command !== MidiCommand.ControlChange) {
|
|
68
|
+
throw "not a midi CC message";
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
command: this.command,
|
|
72
|
+
controller: this.parameter1,
|
|
73
|
+
value: this.parameter2
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
MidiMessage.prototype.toNote = function () {
|
|
77
|
+
if (this.command !== MidiCommand.NoteOn && this.command !== MidiCommand.NoteOff) {
|
|
78
|
+
throw "not a midi note message";
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
command: this.command,
|
|
82
|
+
key: this.parameter1,
|
|
83
|
+
velocity: this.parameter2
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
return MidiMessage;
|
|
87
|
+
}());
|
|
88
|
+
exports.MidiMessage = MidiMessage;
|
|
89
|
+
var Midi = /** @class */ (function (_super) {
|
|
90
|
+
__extends(Midi, _super);
|
|
91
|
+
function Midi(ableton) {
|
|
92
|
+
var _this = _super.call(this, ableton, "midi") || this;
|
|
93
|
+
_this.transformers = {
|
|
94
|
+
midi: function (msg) { return new MidiMessage(msg); }
|
|
95
|
+
};
|
|
96
|
+
return _this;
|
|
97
|
+
}
|
|
98
|
+
return Midi;
|
|
99
|
+
}(index_1.Namespace));
|
|
100
|
+
exports.Midi = Midi;
|
package/ns/track.d.ts
CHANGED
|
@@ -120,4 +120,5 @@ export interface RawTrack {
|
|
|
120
120
|
export declare class Track extends Namespace<GettableProperties, TransformedProperties, SettableProperties, ObservableProperties> {
|
|
121
121
|
raw: RawTrack;
|
|
122
122
|
constructor(ableton: Ableton, raw: RawTrack);
|
|
123
|
+
duplicateClipToArrangement(clipID: number, time: number): Promise<any>;
|
|
123
124
|
}
|
package/ns/track.js
CHANGED
|
@@ -38,6 +38,12 @@ var Track = /** @class */ (function (_super) {
|
|
|
38
38
|
};
|
|
39
39
|
return _this;
|
|
40
40
|
}
|
|
41
|
+
Track.prototype.duplicateClipToArrangement = function (clipID, time) {
|
|
42
|
+
return this.sendCommand("duplicate_clip_to_arrangement", {
|
|
43
|
+
clip_id: clipID,
|
|
44
|
+
time: time
|
|
45
|
+
});
|
|
46
|
+
};
|
|
41
47
|
return Track;
|
|
42
48
|
}(_1.Namespace));
|
|
43
49
|
exports.Track = Track;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ableton-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "Control Ableton Live from Node",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Leo Bernard <admin@leolabs.org>",
|
|
@@ -32,12 +32,6 @@
|
|
|
32
32
|
"test": "jest --runInBand"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@babel/cli": "^7.14.3",
|
|
36
|
-
"@babel/core": "^7.14.3",
|
|
37
|
-
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
38
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.14.4",
|
|
39
|
-
"@babel/preset-env": "^7.14.4",
|
|
40
|
-
"@babel/preset-typescript": "^7.13.0",
|
|
41
35
|
"@types/jest": "^26.0.23",
|
|
42
36
|
"@types/node": "^15.6.1",
|
|
43
37
|
"@types/node-uuid": "^0.0.28",
|
|
@@ -46,8 +40,7 @@
|
|
|
46
40
|
"auto-changelog": "^2.3.0",
|
|
47
41
|
"jest": "^27.0.3",
|
|
48
42
|
"jest-extended": "^0.11.5",
|
|
49
|
-
"
|
|
50
|
-
"jsdoc-to-markdown": "^7.0.1",
|
|
43
|
+
"p-all": "^3",
|
|
51
44
|
"ts-jest": "^27.0.1",
|
|
52
45
|
"ts-node": "^10.0.0",
|
|
53
46
|
"typescript": "^4.3.2"
|