Skip to content

Commit c5aa3b7

Browse files
authored
Update MIDI Multi Channel Pre-Delay v0.6 > v0.7 (#434)
1 parent 90be7ec commit c5aa3b7

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

MIDI/talagan_MIDI Multi Channel Pre-Delay Live Flagger.jsfx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
noindex: true
22
desc: MIDI Multi Channel Pre-Delay Live Flagger
3-
version: 0.6
3+
version: 0.7
44
author: Ben 'Talagan' Babut
55

66
options:gmem=MIDIMultiChannelPredelay
@@ -64,6 +64,7 @@ function cleanupMemory()
6464
local(last)
6565
(
6666
last = b_cursor;
67+
6768
// Advance till we meet something which is not a slot
6869
while(gmem[b_cursor] == MAGIC_NUMBER) (
6970
last = b_cursor;
@@ -80,6 +81,18 @@ function cleanupMemory()
8081
gmem[last+5] = 0;
8182
last -= STORED_EVENT_SIZE;
8283
);
84+
85+
// Only invalidate events in the rest of the queue if they belong to us and are not valid anymore.
86+
while(last >= 0) (
87+
88+
id = gmem[last+1];
89+
bn = gmem[last+3];
90+
91+
((id == UID) && (bn != g_block_num))?(
92+
gmem[last+3] = -1;
93+
);
94+
last -= STORED_EVENT_SIZE;
95+
);
8396
);
8497

8598
function findNextFreeSlotAddress()

MIDI/talagan_MIDI Multi Channel Pre-Delay.jsfx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
desc:MIDI Multi Channel Pre-Delay
22
author: Ben 'Talagan' Babut
3-
version: 0.6
3+
version: 0.7
44
donation:
55
https://www.paypal.com/donate/?business=3YEZMY9D6U8NC&no_recurring=1&currency_code=EUR
66
license:
77
MIT (Do whatever you like with this code).
88
changelog:
9-
- [Feature] Added "Max Delay" option, in case 1 second is not sufficient
10-
- [Feature] Added "Don't delay live events" option, using companion JSFX
11-
- [Prereq] Added companion JSFX for option above
9+
- [Bug Fix] Live Flagger cleanup was not invalidating all obsolete events if multiple instances were active
1210
provides:
1311
talagan_MIDI Multi Channel Pre-Delay Live Flagger.jsfx
1412
about:
@@ -109,6 +107,7 @@ g_buf_r = 0;
109107
g_max_pre_delay = 0;
110108
g_last_srate = srate;
111109

110+
112111
//-----------------------
113112

114113
function iround(f) (
@@ -173,8 +172,8 @@ function isLiveEvent(offset, msg1, msg2, msg3)
173172

174173
while( (gmem[cursor] == MAGIC_NUMBER) && !found) (
175174

176-
// UID and Offset should match
177-
( (gmem[cursor+1] == UID) && (gmem[cursor+5] == offset) )?(
175+
// UID and Offset should match and even should not be invalidated
176+
( (gmem[cursor+1] == UID) && (gmem[cursor+5] == offset) && (gmem[cursor+3] != -1))?(
178177
// Test message content
179178
_msg = gmem[cursor+4];
180179

@@ -208,7 +207,7 @@ onSliderChange();
208207
//////////////////////////////////////////////////
209208

210209
function processEvents()
211-
local(delay_samples, delay_sc, delay_isc, msg1, msg2, msg3, is_recording,
210+
local(delay_samples, delay_sc, delay_isc, msg1, msg2, msg3,
212211
msg_len, msg_chan, msg_type, msg_has_channel, msg_pos, msg_emitted,
213212
is_candidate, packet)
214213
(
@@ -251,7 +250,6 @@ function processEvents()
251250

252251
msg_chan = (msg1 & 0x0F);
253252
msg_type = ((msg1 & 0xF0) >> 4);
254-
is_recording = (play_state == 5);
255253

256254
// If plugin evolves, add some conditions here
257255
is_candidate = 0;
@@ -274,7 +272,6 @@ function processEvents()
274272
g_buf_r[2] = midi_bus | 0; // Bus and re-emitted status
275273

276274
g_buf_r += HEADER_SIZE + msg_len; // Advance by total packet length
277-
278275
) : (
279276
midisend_buf(msg_pos, g_buf_r + HEADER_SIZE, msg_len);
280277
);

0 commit comments

Comments
 (0)