@@ -273,48 +273,7 @@ impl OscServer {
273273 }
274274
275275 // INDEPENDENT CHECK: Cue Events (Update State even if mapped)
276- if msg. addr == "/eos/out/event/cue/1/0/stop" {
277- let mut m = midi. lock ( ) . unwrap ( ) ;
278- if m. crossfade_state == CrossfadeState :: Go
279- || m. crossfade_state == CrossfadeState :: GoBack
280- {
281- m. crossfade_state = CrossfadeState :: Pause ;
282- let profiles_to_process: Vec < ( String , crate :: controller:: ControllerProfile ) > =
283- m. device_profiles
284- . iter ( )
285- . map ( |( k, v) | ( k. clone ( ) , v. clone ( ) ) )
286- . collect ( ) ;
287- for ( d_name, p) in profiles_to_process {
288- if let Some ( ( note, chan, _) ) =
289- p. get_midi_output_for_action ( crate :: controller:: LogicalAction :: Stop )
290- {
291- m. enqueue ( & d_name, vec ! [ 0x90 | chan, note, 127 ] ) ;
292- }
293- }
294- }
295- } else if msg. addr == "/eos/out/event/cue/1/0/resume" {
296- let mut m = midi. lock ( ) . unwrap ( ) ;
297- if m. crossfade_state == CrossfadeState :: Pause {
298- m. crossfade_state = CrossfadeState :: Go ;
299- let profiles_to_process: Vec < ( String , crate :: controller:: ControllerProfile ) > =
300- m. device_profiles
301- . iter ( )
302- . map ( |( k, v) | ( k. clone ( ) , v. clone ( ) ) )
303- . collect ( ) ;
304- for ( d_name, p) in profiles_to_process {
305- if let Some ( ( s_note, s_chan, _) ) =
306- p. get_midi_output_for_action ( crate :: controller:: LogicalAction :: Stop )
307- {
308- m. enqueue ( & d_name, vec ! [ 0x90 | s_chan, s_note, 0 ] ) ;
309- }
310- if let Some ( ( g_note, g_chan, _) ) =
311- p. get_midi_output_for_action ( crate :: controller:: LogicalAction :: Go )
312- {
313- m. enqueue ( & d_name, vec ! [ 0x90 | g_chan, g_note, 127 ] ) ;
314- }
315- }
316- }
317- } else if msg. addr == "/eos/out/active/cue/text" {
276+ if msg. addr == "/eos/out/active/cue/text" {
318277 if let Some ( OscType :: String ( text) ) = msg. args . first ( ) {
319278 // Extract the cue number part
320279 if let Some ( new_cue_num) = crate :: parse_cue_number ( text) {
@@ -327,10 +286,32 @@ impl OscServer {
327286 new_cue_num,
328287 current_state,
329288 ) {
330- m. intended_dir = direction;
289+ m. intended_dir = Some ( direction) ;
290+
291+ // IMMEDIATE TRIGGER CHECK
292+ // If the text contains progress (e.g. "7%"), we should try to apply state NOW
293+ // because the float packet might have been lost or arrived earlier (when dir was None).
294+ if let Some ( p) = crate :: parse_cue_progress ( text) {
295+ if p < 1.0 {
296+ let last = m. last_applied_dir ;
297+ let current = m. crossfade_state ;
298+
299+ if direction != last {
300+ m. set_crossfade_state ( direction, false ) ;
301+ m. last_applied_dir = direction;
302+ } else if current == CrossfadeState :: Inactive {
303+ m. set_crossfade_state ( direction, false ) ;
304+ m. last_applied_dir = direction;
305+ }
306+ }
307+ }
308+ } else {
309+ // no log
331310 }
332311
333312 m. current_cue = Some ( new_cue_num) ;
313+ } else {
314+ // no log
334315 }
335316 }
336317 } else if msg. addr == "/eos/out/ping" {
@@ -380,22 +361,24 @@ impl OscServer {
380361
381362 if * progress < 1.0 {
382363 // Activate the intended direction if we are not already in it (or if overriding something other than Pause)
383- let intended = m. intended_dir ;
384- let last = m. last_applied_dir ;
385- let current = m. crossfade_state ;
386-
387- // Only apply change if direction is new OR if we are Inactive
388- // Respect Pause: If Paused, do not switch unless the intended direction actually changed (e.g. Go -> Back)
389- if intended != last {
390- m. set_crossfade_state ( intended, false ) ;
391- m. last_applied_dir = intended;
392- } else if current == CrossfadeState :: Inactive {
393- // Starting a fade from Inactive
394- m. set_crossfade_state ( intended, false ) ;
395- m. last_applied_dir = intended;
364+ if let Some ( intended) = m. intended_dir {
365+ let last = m. last_applied_dir ;
366+ let current = m. crossfade_state ;
367+
368+ // Only apply change if direction is new OR if we are Inactive
369+ // Respect Pause: If Paused, do not switch unless the intended direction actually changed (e.g. Go -> Back)
370+ if intended != last {
371+ m. set_crossfade_state ( intended, false ) ;
372+ m. last_applied_dir = intended;
373+ } else if current == CrossfadeState :: Inactive {
374+ // Starting a fade from Inactive
375+ m. set_crossfade_state ( intended, false ) ;
376+ m. last_applied_dir = intended;
377+ }
396378 }
397379 } else {
398380 m. set_crossfade_state ( CrossfadeState :: Inactive , false ) ;
381+ m. intended_dir = None ;
399382 }
400383 }
401384 }
0 commit comments