ableton-js 2.5.3 → 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,16 @@ 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
+
7
13
  #### [v2.5.3](https://github.com/leolabs/ableton.js/compare/v2.5.2...v2.5.3)
8
14
 
15
+ > 30 August 2022
16
+
9
17
  - :memo: Fix some typos in the readme [`10c8566`](https://github.com/leolabs/ableton.js/commit/10c8566758bc1a7e7ab6bc20fa269d38474e1d96)
10
18
  - :sparkles: Add support for observing the `muted` prop of clips [`ecb604a`](https://github.com/leolabs/ableton.js/commit/ecb604a2b25aa3a064ffe5d199d44cfca0c12144)
11
19
 
package/README.md CHANGED
@@ -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"])
@@ -10,4 +10,4 @@ class Internal(Interface):
10
10
  return self
11
11
 
12
12
  def get_version(self, ns):
13
- return "2.5.3"
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ableton-js",
3
- "version": "2.5.3",
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>",