ableton-js 2.5.2 → 2.5.4

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
+ #### [v2.5.4](https://github.com/leolabs/ableton.js/compare/v2.5.3...v2.5.4)
8
+
9
+ - :sparkles: Restart the socket when a message can't be sent due to a socket error [`91294c3`](https://github.com/leolabs/ableton.js/commit/91294c3cf195afacd22cbf1863e244bc231c9a33)
10
+ - :sparkles: Send the UUID back with the error if a requested namespace handler doesn't exist [`8a96a99`](https://github.com/leolabs/ableton.js/commit/8a96a996b8b65c8485d90ac98293ccd605497784)
11
+ - :memo: Add an example for setting a value [`f334983`](https://github.com/leolabs/ableton.js/commit/f334983a8755eab8415383aae7aff1ecff6e23e2)
12
+
13
+ #### [v2.5.3](https://github.com/leolabs/ableton.js/compare/v2.5.2...v2.5.3)
14
+
15
+ > 30 August 2022
16
+
17
+ - :memo: Fix some typos in the readme [`10c8566`](https://github.com/leolabs/ableton.js/commit/10c8566758bc1a7e7ab6bc20fa269d38474e1d96)
18
+ - :sparkles: Add support for observing the `muted` prop of clips [`ecb604a`](https://github.com/leolabs/ableton.js/commit/ecb604a2b25aa3a064ffe5d199d44cfca0c12144)
19
+
7
20
  #### [v2.5.2](https://github.com/leolabs/ableton.js/compare/v2.5.1...v2.5.2)
8
21
 
22
+ > 26 August 2022
23
+
9
24
  - :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
25
 
11
26
  #### [v2.5.1](https://github.com/leolabs/ableton.js/compare/v2.5.0...v2.5.1)
package/README.md CHANGED
@@ -14,16 +14,16 @@ functions to TypeScript. If you'd like to contribute, please feel free to do so.
14
14
  I've used Ableton.js to build a setlist manager called
15
15
  [AbleSet](https://ableset.app). AbleSet allows you to easily manage and control
16
16
  your Ableton setlists from any device, re-order songs and add notes to them, and
17
- get an overview of the current of your set.
17
+ get an overview of the current state of your set.
18
18
 
19
- [![AbleSet Header](https://public-files.gumroad.com/variants/oplxt68bsgq1hu61t8bydfkgppr5/baaca0eb0e33dc4f9d45910b8c86623f0144cea0fe0c2093c546d17d535752eb)](https://ableset.app)
19
+ [![AbleSet Header](https://public-files.gumroad.com/variants/oplxt68bsgq1hu61t8bydfkgppr5/baaca0eb0e33dc4f9d45910b8c86623f0144cea0fe0c2093c546d17d535752eb)](https://ableset.app/?utm_campaign=ableton-js)
20
20
 
21
21
  ## Prerequisites
22
22
 
23
23
  To use this library, you'll need to install and activate the MIDI Remote Script
24
24
  in Ableton.js. To do that, copy the `midi-script` folder of this repo to
25
- Ableton's Remote Scripts folder and rename it to `AbletonJS`. The MIDI Remote Scripts folder is
26
- usually located at:
25
+ Ableton's Remote Scripts folder and rename it to `AbletonJS`. The MIDI Remote
26
+ Scripts folder is usually located at:
27
27
 
28
28
  - **Windows:** {path to Ableton}\Resources\MIDI\Remote Scripts
29
29
  - **macOS:** /Applications/Ableton Live {version}/Contents/App-Resources/MIDI
@@ -51,11 +51,16 @@ import { Ableton } from "ableton-js";
51
51
  const ableton = new Ableton();
52
52
 
53
53
  const test = async () => {
54
+ // Observe the current playback state and tempo
54
55
  ableton.song.addListener("is_playing", (p) => console.log("Playing:", p));
55
56
  ableton.song.addListener("tempo", (t) => console.log("Tempo:", t));
56
57
 
58
+ // Get the current tempo
57
59
  const tempo = await ableton.song.get("tempo");
58
60
  console.log(tempo);
61
+
62
+ // Set the tempo
63
+ await ableton.song.set("tempo", 85);
59
64
  };
60
65
 
61
66
  test();
@@ -54,9 +54,11 @@ class AbletonJS(ControlSurface):
54
54
  script_handle = self._c_instance.handle()
55
55
  for midi in self.tracked_midi:
56
56
  if midi[0] == "cc":
57
- Live.MidiMap.forward_midi_cc(script_handle, midi_map_handle, midi[1], midi[2])
57
+ Live.MidiMap.forward_midi_cc(
58
+ script_handle, midi_map_handle, midi[1], midi[2])
58
59
  elif midi[0] == "note":
59
- Live.MidiMap.forward_midi_note(script_handle, midi_map_handle, midi[1], midi[2])
60
+ Live.MidiMap.forward_midi_note(
61
+ script_handle, midi_map_handle, midi[1], midi[2])
60
62
 
61
63
  def receive_midi(self, midi_bytes):
62
64
  self.handlers["midi"].send_midi(midi_bytes)
@@ -77,4 +79,5 @@ class AbletonJS(ControlSurface):
77
79
  handler = self.handlers[namespace]
78
80
  handler.handle(payload)
79
81
  else:
80
- self.socket.send("error", "No handler for NS " + str(namespace))
82
+ self.socket.send("error", "No handler for namespace " +
83
+ str(namespace), payload["uuid"])
@@ -17,6 +17,7 @@ class Clip(Interface):
17
17
  "is_midi_clip": clip.is_midi_clip,
18
18
  "start_time": clip.start_time,
19
19
  "end_time": clip.end_time,
20
+ "muted": clip.muted
20
21
  }
21
22
 
22
23
  def __init__(self, c_instance, socket):
@@ -10,4 +10,4 @@ class Internal(Interface):
10
10
  return self
11
11
 
12
12
  def get_version(self, ns):
13
- return "2.5.2"
13
+ return "2.5.4"
@@ -24,16 +24,20 @@ class Socket(object):
24
24
 
25
25
  def __init__(self, handler, remotehost='127.0.0.1', remoteport=39031, localhost='127.0.0.1', localport=39041):
26
26
  self.input_handler = handler
27
+ self._local_addr = (localhost, localport)
28
+ self._remote_addr = (remotehost, remoteport)
29
+ self.init_socket()
27
30
 
31
+ def init_socket(self):
28
32
  self._socket = socket.socket(
29
33
  socket.AF_INET, socket.SOCK_DGRAM)
30
34
  self._socket.setblocking(0)
31
35
 
32
- self._local_addr = (localhost, localport)
33
- self._remote_addr = (remotehost, remoteport)
34
-
35
36
  self.bind()
36
37
 
38
+ def shutdown(self):
39
+ self._socket.close()
40
+
37
41
  def bind(self):
38
42
  try:
39
43
  self._socket.bind(self._local_addr)
@@ -70,15 +74,14 @@ class Socket(object):
70
74
  try:
71
75
  self._sendto(json.dumps(
72
76
  {"event": name, "data": obj, "uuid": uuid}, default=jsonReplace, ensure_ascii=False))
77
+ except socket.error as e:
78
+ self.log_message("Socket error: " + str(e.args))
79
+ self.log_message("Restarting socket...")
80
+ self.shutdown()
81
+ self.init_socket()
73
82
  except Exception as e:
74
83
  error = str(type(e).__name__) + ': ' + str(e.args)
75
- self._sendto(json.dumps(
76
- {"event": "error", "data": error, "uuid": uuid}, default=jsonReplace, ensure_ascii=False))
77
- self.log_message("Socket Error " + name +
78
- "(" + str(uuid) + "): " + str(e))
79
-
80
- def shutdown(self):
81
- self._socket.close()
84
+ self.log_message("Error " + name + "(" + str(uuid) + "): " + error)
82
85
 
83
86
  def process(self):
84
87
  try:
@@ -91,12 +94,9 @@ class Socket(object):
91
94
  num_messages += 1
92
95
 
93
96
  # \xFF for Live 10 (Python2) and 255 for Live 11 (Python3)
94
- if(data[0] == b'\xFF' or data[0] == 255):
97
+ if (data[0] == b'\xFF' or data[0] == 255):
95
98
  unzipped = zlib.decompress(buffer)
96
99
  payload = json.loads(unzipped)
97
-
98
- self.log_message(
99
- "Receiving from " + str(num_messages) + " messages, " + str(len(buffer)) + " bytes: " + str(payload))
100
100
  self.input_handler(payload)
101
101
  buffer = bytes()
102
102
  num_messages = 0
package/ns/clip.d.ts CHANGED
@@ -115,6 +115,7 @@ export interface ObservableProperties {
115
115
  is_recording: boolean;
116
116
  loop_end: number;
117
117
  loop_start: number;
118
+ muted: boolean;
118
119
  name: string;
119
120
  pitch_coarse: number;
120
121
  pitch_fine: number;
@@ -134,6 +135,7 @@ export interface RawClip {
134
135
  is_midi_clip: boolean;
135
136
  start_time: number;
136
137
  end_time: number;
138
+ muted: boolean;
137
139
  }
138
140
  /**
139
141
  * This class represents an entry in Live's Session view matrix.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ableton-js",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
4
4
  "description": "Control Ableton Live from Node",
5
5
  "main": "index.js",
6
6
  "author": "Leo Bernard <admin@leolabs.org>",