ableton-js 3.3.3 → 3.3.5

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 CHANGED
@@ -4,8 +4,23 @@ 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
+ #### [v3.3.5](https://github.com/leolabs/ableton.js/compare/v3.3.4...v3.3.5)
8
+
9
+ - :sparkles: Properly create and return scenes and tracks [`dc550f1`](https://github.com/leolabs/ableton.js/commit/dc550f15a79360caf3b247f5373a1d255b2b3476)
10
+ - :bug: Fix `createScene` not working when no index is provided [`e6bf99b`](https://github.com/leolabs/ableton.js/commit/e6bf99b7bcbcc053a2cddd12b5a77d91f36b0430)
11
+
12
+ #### [v3.3.4](https://github.com/leolabs/ableton.js/compare/v3.3.3...v3.3.4)
13
+
14
+ > 26 October 2023
15
+
16
+ - :sparkles: Add support for the Track View class [`3ff5980`](https://github.com/leolabs/ableton.js/commit/3ff5980e5e5f407bc6b767a5329b54774ca10534)
17
+ - :sparkles: Add a `safeStopPlaying` function that only stops playback when Live is currently playing to prevent accidental jumps to the beginning of the timeline [`a7b84e2`](https://github.com/leolabs/ableton.js/commit/a7b84e2146a69ab00cc75f83a4eedd5d91495eda)
18
+ - :art: Fix formatting [`f06d3d0`](https://github.com/leolabs/ableton.js/commit/f06d3d0cde4632612b1db8ea04e85f1276eb8bb6)
19
+
7
20
  #### [v3.3.3](https://github.com/leolabs/ableton.js/compare/v3.3.2...v3.3.3)
8
21
 
22
+ > 10 September 2023
23
+
9
24
  - :mute: Fix every message being logged twice [`3a2571f`](https://github.com/leolabs/ableton.js/commit/3a2571f0a4ad61fdf751a0dfbb5da00b6def8508)
10
25
  - :wastebasket: Deprecate `removeNotes` and add `removeNotesExtended` as a replacement [`ac02271`](https://github.com/leolabs/ableton.js/commit/ac022718f0b16317d8fdf70ff1c8d77eaaa0f384)
11
26
  - :bug: Address a hang in newer versions of Live when the UDP port is already being used [`5caeaeb`](https://github.com/leolabs/ableton.js/commit/5caeaebc172fc819693c988643071c565e4dbcd3)
@@ -1,6 +1,7 @@
1
1
  from __future__ import absolute_import
2
2
  import time
3
3
 
4
+
4
5
  from .version import version
5
6
  from .Config import DEBUG, FAST_POLLING
6
7
  from .Logging import logger
@@ -18,6 +19,7 @@ from .Scene import Scene
18
19
  from .Song import Song
19
20
  from .SongView import SongView
20
21
  from .Track import Track
22
+ from .TrackView import TrackView
21
23
  from .Internal import Internal
22
24
  from .ClipSlot import ClipSlot
23
25
  from .Clip import Clip
@@ -52,6 +54,7 @@ class AbletonJS(ControlSurface):
52
54
  "song": Song(c_instance, self.socket),
53
55
  "song-view": SongView(c_instance, self.socket),
54
56
  "track": Track(c_instance, self.socket),
57
+ "track-view": TrackView(c_instance, self.socket),
55
58
  "clip_slot": ClipSlot(c_instance, self.socket),
56
59
  "clip": Clip(c_instance, self.socket),
57
60
  }
@@ -69,8 +72,8 @@ class AbletonJS(ControlSurface):
69
72
  tick_time = time.time() * 1000
70
73
 
71
74
  if tick_time - self._last_tick > 200:
72
- logger.warn("UDP tick is lagging, delta: " +
73
- str(round(tick_time - self._last_tick)) + "ms")
75
+ logger.warning("UDP tick is lagging, delta: " +
76
+ str(round(tick_time - self._last_tick)) + "ms")
74
77
 
75
78
  self._last_tick = tick_time
76
79
  self.socket.process()
@@ -78,8 +81,8 @@ class AbletonJS(ControlSurface):
78
81
  process_time = time.time() * 1000
79
82
 
80
83
  if process_time - tick_time > 100:
81
- logger.warn("UDP processing is taking long, delta: " +
82
- str(round(tick_time - process_time)) + "ms")
84
+ logger.warning("UDP processing is taking long, delta: " +
85
+ str(round(tick_time - process_time)) + "ms")
83
86
 
84
87
  self.schedule_message(1, self.tick)
85
88
 
@@ -40,10 +40,10 @@ class Midi(Interface):
40
40
  raise Exception("Listener " + str(prop) + " does not exist.")
41
41
 
42
42
  if self.event_id is not None:
43
- logger.warn("midi listener already exists")
43
+ logger.warning("MIDI listener already exists")
44
44
  return self.event_id
45
45
 
46
- logger.info("Attaching midi listener")
46
+ logger.info("Attaching MIDI listener")
47
47
 
48
48
  self.tracked_midi.clear()
49
49
  self.tracked_midi.update(self.outputs)
@@ -46,7 +46,7 @@ class Socket(object):
46
46
  logger.error(msg)
47
47
 
48
48
  def set_client_port(self, port):
49
- logger.info("Setting client port: ", str(port))
49
+ logger.info("Setting client port: " + str(port))
50
50
  self.show_message("Client connected on port " + str(port))
51
51
  self._client_addr = ("127.0.0.1", int(port))
52
52
 
@@ -4,17 +4,12 @@ from .CuePoint import CuePoint
4
4
  from .Device import Device
5
5
  from .Scene import Scene
6
6
  from .Track import Track
7
- import Live
8
7
 
9
- INSERT_MODES = {'default':Live.Track.DeviceInsertMode.default,
10
- 'left':Live.Track.DeviceInsertMode.selected_left,
11
- 'right':Live.Track.DeviceInsertMode.selected_right}
12
8
 
13
9
  class Song(Interface):
14
10
  def __init__(self, c_instance, socket):
15
11
  super(Song, self).__init__(c_instance, socket)
16
12
  self.song = self.ableton.song()
17
- self._insert_mode = INSERT_MODES['default']
18
13
 
19
14
  def get_ns(self, nsid):
20
15
  return self.song
@@ -28,6 +23,9 @@ class Song(Interface):
28
23
  def create_return_track(self, ns):
29
24
  return Track.serialize_track(ns.create_return_track())
30
25
 
26
+ def create_scene(self, ns, index):
27
+ return Scene.serialize_scene(ns.create_scene(index))
28
+
31
29
  def get_clip_trigger_quantization(self, ns):
32
30
  return str(ns.clip_trigger_quantization)
33
31
 
@@ -66,6 +64,9 @@ class Song(Interface):
66
64
  def set_appointed_device(self, ns, device_id):
67
65
  ns.appointed_device = Interface.get_obj(device_id)
68
66
 
69
- def set_insert_mode(self,ns, args):
70
- self._insert_mode = INSERT_MODES.get(str(args), INSERT_MODES['default'])
71
- self.song.view.selected_track.view.device_insert_mode = self._insert_mode
67
+ def safe_stop_playing(self, ns):
68
+ if self.song.is_playing:
69
+ self.song.stop_playing()
70
+ return True
71
+
72
+ return False
@@ -0,0 +1,24 @@
1
+ from __future__ import absolute_import
2
+ from .Interface import Interface
3
+ from .Device import Device
4
+
5
+ import Live
6
+
7
+ INSERT_MODES = {'default': Live.Track.DeviceInsertMode.default,
8
+ 'left': Live.Track.DeviceInsertMode.selected_left,
9
+ 'right': Live.Track.DeviceInsertMode.selected_right}
10
+
11
+
12
+ class TrackView(Interface):
13
+ def __init__(self, c_instance, socket):
14
+ super(TrackView, self).__init__(c_instance, socket)
15
+
16
+ def get_ns(self, nsid):
17
+ return Interface.obj_ids[nsid].view
18
+
19
+ def get_selected_device(self, ns):
20
+ return Device.serialize_device(ns.selected_device)
21
+
22
+ def set_device_insert_mode(self, ns, name):
23
+ mode = INSERT_MODES.get(str(name), INSERT_MODES['default'])
24
+ ns.device_insert_mode = mode
@@ -1 +1 @@
1
- version = "3.3.3"
1
+ version = "3.3.5"
package/ns/scene.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Ableton } from "..";
2
2
  import { Namespace } from ".";
3
3
  import { ClipSlot, RawClipSlot } from "./clip-slot";
4
+ import { Color } from "../util/color";
4
5
  export interface GettableProperties {
5
6
  clip_slots: RawClipSlot[];
6
7
  color: number;
@@ -11,6 +12,7 @@ export interface GettableProperties {
11
12
  tempo: number;
12
13
  }
13
14
  export interface TransformedProperties {
15
+ color: Color;
14
16
  clip_slots: ClipSlot[];
15
17
  }
16
18
  export interface SettableProperties {
package/ns/scene.js CHANGED
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Scene = void 0;
4
4
  const _1 = require(".");
5
5
  const clip_slot_1 = require("./clip-slot");
6
+ const color_1 = require("../util/color");
6
7
  class Scene extends _1.Namespace {
7
8
  raw;
8
9
  constructor(ableton, raw) {
9
10
  super(ableton, "scene", raw.id);
10
11
  this.raw = raw;
11
12
  this.transformers = {
13
+ color: (c) => new color_1.Color(c),
12
14
  clip_slots: (clip_slots) => clip_slots.map((c) => new clip_slot_1.ClipSlot(this.ableton, c)),
13
15
  };
14
16
  this.cachedProps = {
package/ns/song.d.ts CHANGED
@@ -61,11 +61,6 @@ export interface TransformedProperties {
61
61
  visible_tracks: Track[];
62
62
  scenes: Scene[];
63
63
  }
64
- export declare enum DeviceInsertMode {
65
- default = "default",
66
- left = "left",
67
- right = "right"
68
- }
69
64
  export interface SettableProperties {
70
65
  appointed_device: string;
71
66
  arrangement_overdub: boolean;
@@ -76,7 +71,6 @@ export interface SettableProperties {
76
71
  exclusive_arm: number;
77
72
  exclusive_solo: number;
78
73
  groove_amount: number;
79
- insert_mode: DeviceInsertMode;
80
74
  is_counting_in: boolean;
81
75
  is_playing: boolean;
82
76
  last_event_time: number;
@@ -193,10 +187,10 @@ export declare class Song extends Namespace<GettableProperties, TransformedPrope
193
187
  view: SongView;
194
188
  beginUndoStep(): Promise<any>;
195
189
  continuePlaying(): Promise<any>;
196
- createAudioTrack(index?: number): Promise<any>;
197
- createMidiTrack(index?: number): Promise<any>;
198
- createReturnTrack(): Promise<any>;
199
- createScene(index?: number): Promise<any>;
190
+ createAudioTrack(index?: number): Promise<Track>;
191
+ createMidiTrack(index?: number): Promise<Track>;
192
+ createReturnTrack(): Promise<Track>;
193
+ createScene(index?: number): Promise<Scene>;
200
194
  deleteReturnTrack(index: number): Promise<any>;
201
195
  deleteScene(index: number): Promise<any>;
202
196
  deleteTrack(index: number): Promise<any>;
@@ -217,7 +211,7 @@ export declare class Song extends Namespace<GettableProperties, TransformedPrope
217
211
  startPlaying(): Promise<any>;
218
212
  stopAllClips(): Promise<any>;
219
213
  stopPlaying(): Promise<any>;
214
+ safeStopPlaying(): Promise<any>;
220
215
  tapTempo(): Promise<any>;
221
216
  undo(): Promise<any>;
222
- set_insert_mode(args: DeviceInsertMode): Promise<any>;
223
217
  }
package/ns/song.js CHANGED
@@ -1,17 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Song = exports.RecordingQuantization = exports.Quantization = exports.TimeFormat = exports.DeviceInsertMode = void 0;
3
+ exports.Song = exports.RecordingQuantization = exports.Quantization = exports.TimeFormat = void 0;
4
4
  const _1 = require(".");
5
5
  const track_1 = require("./track");
6
6
  const cue_point_1 = require("./cue-point");
7
7
  const song_view_1 = require("./song-view");
8
8
  const scene_1 = require("./scene");
9
- var DeviceInsertMode;
10
- (function (DeviceInsertMode) {
11
- DeviceInsertMode["default"] = "default";
12
- DeviceInsertMode["left"] = "left";
13
- DeviceInsertMode["right"] = "right";
14
- })(DeviceInsertMode || (exports.DeviceInsertMode = DeviceInsertMode = {}));
15
9
  var TimeFormat;
16
10
  (function (TimeFormat) {
17
11
  TimeFormat[TimeFormat["MsTime"] = 0] = "MsTime";
@@ -77,17 +71,21 @@ class Song extends _1.Namespace {
77
71
  async continuePlaying() {
78
72
  return this.sendCommand("continue_playing");
79
73
  }
80
- async createAudioTrack(index) {
81
- return this.sendCommand("create_audio_track", { index });
74
+ async createAudioTrack(index = -1) {
75
+ const result = await this.sendCommand("create_audio_track", { index });
76
+ return new track_1.Track(this.ableton, result);
82
77
  }
83
- async createMidiTrack(index) {
84
- return this.sendCommand("create_midi_track", { index });
78
+ async createMidiTrack(index = -1) {
79
+ const result = await this.sendCommand("create_midi_track", { index });
80
+ return new track_1.Track(this.ableton, result);
85
81
  }
86
82
  async createReturnTrack() {
87
- return this.sendCommand("create_return_track");
83
+ const result = await this.sendCommand("create_return_track");
84
+ return new track_1.Track(this.ableton, result);
88
85
  }
89
- async createScene(index) {
90
- return this.sendCommand("create_scene", [index]);
86
+ async createScene(index = -1) {
87
+ const result = await this.sendCommand("create_scene", { index });
88
+ return new scene_1.Scene(this.ableton, result);
91
89
  }
92
90
  async deleteReturnTrack(index) {
93
91
  return this.sendCommand("delete_return_track", [index]);
@@ -149,14 +147,14 @@ class Song extends _1.Namespace {
149
147
  async stopPlaying() {
150
148
  return this.sendCommand("stop_playing");
151
149
  }
150
+ async safeStopPlaying() {
151
+ return this.sendCommand("safe_stop_playing");
152
+ }
152
153
  async tapTempo() {
153
154
  return this.sendCommand("tap_tempo");
154
155
  }
155
156
  async undo() {
156
157
  return this.sendCommand("undo");
157
158
  }
158
- async set_insert_mode(args) {
159
- return this.sendCommand("set_insert_mode", { args });
160
- }
161
159
  }
162
160
  exports.Song = Song;
@@ -0,0 +1,30 @@
1
+ import { Ableton } from "..";
2
+ import { Namespace } from ".";
3
+ import { Device, RawDevice } from "./device";
4
+ export declare enum DeviceInsertMode {
5
+ Default = "default",
6
+ Left = "left",
7
+ Right = "right"
8
+ }
9
+ export interface GettableProperties {
10
+ is_collapsed: boolean;
11
+ selected_device: RawDevice;
12
+ }
13
+ export interface TransformedProperties {
14
+ selected_device: Device;
15
+ }
16
+ export interface SettableProperties {
17
+ device_insert_mode: DeviceInsertMode;
18
+ is_collapsed: boolean;
19
+ }
20
+ export interface ObservableProperties {
21
+ is_collapsed: boolean;
22
+ selected_device: RawDevice;
23
+ }
24
+ export declare class TrackView extends Namespace<GettableProperties, TransformedProperties, SettableProperties, ObservableProperties> {
25
+ constructor(ableton: Ableton, nsid: string);
26
+ /**
27
+ * Selects the track's instrument if it has one.
28
+ */
29
+ selectInstrument(): Promise<any>;
30
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrackView = exports.DeviceInsertMode = void 0;
4
+ const _1 = require(".");
5
+ const device_1 = require("./device");
6
+ var DeviceInsertMode;
7
+ (function (DeviceInsertMode) {
8
+ DeviceInsertMode["Default"] = "default";
9
+ DeviceInsertMode["Left"] = "left";
10
+ DeviceInsertMode["Right"] = "right";
11
+ })(DeviceInsertMode || (exports.DeviceInsertMode = DeviceInsertMode = {}));
12
+ class TrackView extends _1.Namespace {
13
+ constructor(ableton, nsid) {
14
+ super(ableton, "track-view", nsid);
15
+ this.transformers = {
16
+ selected_device: (device) => new device_1.Device(ableton, device),
17
+ };
18
+ this.cachedProps = {
19
+ selected_device: true,
20
+ };
21
+ }
22
+ /**
23
+ * Selects the track's instrument if it has one.
24
+ */
25
+ async selectInstrument() {
26
+ return this.sendCommand("select_instrument");
27
+ }
28
+ }
29
+ exports.TrackView = TrackView;
package/ns/track.d.ts CHANGED
@@ -5,6 +5,7 @@ import { ClipSlot, RawClipSlot } from "./clip-slot";
5
5
  import { MixerDevice, RawMixerDevice } from "./mixer-device";
6
6
  import { Clip, RawClip } from "./clip";
7
7
  import { Color } from "../util/color";
8
+ import { TrackView } from "./track-view";
8
9
  export declare enum RoutingLayout {
9
10
  Mono = 1,
10
11
  Stereo = 2
@@ -149,6 +150,7 @@ export interface RawTrack {
149
150
  }
150
151
  export declare class Track extends Namespace<GettableProperties, TransformedProperties, SettableProperties, ObservableProperties> {
151
152
  raw: RawTrack;
153
+ view: TrackView;
152
154
  constructor(ableton: Ableton, raw: RawTrack);
153
155
  /**
154
156
  * Duplicates the given clip into the arrangement of this track at the provided destination time and returns it.
package/ns/track.js CHANGED
@@ -7,6 +7,7 @@ const clip_slot_1 = require("./clip-slot");
7
7
  const mixer_device_1 = require("./mixer-device");
8
8
  const clip_1 = require("./clip");
9
9
  const color_1 = require("../util/color");
10
+ const track_view_1 = require("./track-view");
10
11
  var RoutingLayout;
11
12
  (function (RoutingLayout) {
12
13
  RoutingLayout[RoutingLayout["Mono"] = 1] = "Mono";
@@ -25,9 +26,11 @@ var RoutingCategory;
25
26
  })(RoutingCategory || (exports.RoutingCategory = RoutingCategory = {}));
26
27
  class Track extends _1.Namespace {
27
28
  raw;
29
+ view;
28
30
  constructor(ableton, raw) {
29
31
  super(ableton, "track", raw.id);
30
32
  this.raw = raw;
33
+ this.view = new track_view_1.TrackView(this.ableton, raw.id);
31
34
  this.transformers = {
32
35
  arrangement_clips: (clips) => clips.map((clip) => new clip_1.Clip(ableton, clip)),
33
36
  color: (c) => new color_1.Color(c),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ableton-js",
3
- "version": "3.3.3",
3
+ "version": "3.3.5",
4
4
  "description": "Control Ableton Live from Node",
5
5
  "main": "index.js",
6
6
  "author": "Leo Bernard <admin@leolabs.org>",