Skip to content

Commit 96ea3cc

Browse files
committed
🔧 Increase the packet send burst and receive buffer
1 parent b0123d5 commit 96ea3cc

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

midi-script/Socket.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ def process(self):
201201
try:
202202
while 1:
203203
try:
204-
# Send 5 UDP packets at a time, to avoid
205-
for i in range(5):
204+
# Send 30 UDP packets at a time, to avoid
205+
# Node's receive buffer from overflowing
206+
for i in range(30):
206207
self._socket.sendto(
207208
self._send_buffer.pop(0), self._client_addr)
208209
except:

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ export class Ableton extends EventEmitter<EventMap> {
251251

252252
// The recvBufferSize is set to macOS' default value, so the
253253
// socket behaves the same on Windows and doesn't drop any packets
254-
this.client = dgram.createSocket({ type: "udp4", recvBufferSize: 786896 });
254+
this.client = dgram.createSocket({
255+
type: "udp4",
256+
// 4 MB receive buffer to avoid losing packets
257+
recvBufferSize: 4 * 1024 * 1024,
258+
});
259+
255260
this.client.addListener("message", this.handleIncoming.bind(this));
256261

257262
this.client.addListener("listening", async () => {
@@ -305,6 +310,8 @@ export class Ableton extends EventEmitter<EventMap> {
305310
});
306311
});
307312

313+
this.logger?.debug("Receive Buffer Size:", this.client.getRecvBufferSize());
314+
308315
// Send used port to Live in case the plugin is already started
309316
if (!sentPort) {
310317
try {

0 commit comments

Comments
 (0)