diff --git a/vite/src/comps/numpad.jsx b/vite/src/comps/numpad.jsx index ba9ab5d..7cd8488 100644 --- a/vite/src/comps/numpad.jsx +++ b/vite/src/comps/numpad.jsx @@ -1,4 +1,5 @@ import { useEffect, useRef, useState } from "react"; +import { OSC_ADDRESS, sendOscStatus } from "../util/osc"; export const NUMPAD_TYPE={ @@ -20,7 +21,7 @@ const TMP_MAP_KEY={ 7:9,*/ } -export default function NumPad({onSend, disabled, type}){ +export default function NumPad({onSend, disabled, type, clientId}){ const [input, _setInput]=useState(); const refInput=useRef(); @@ -102,6 +103,12 @@ export default function NumPad({onSend, disabled, type}){ } + useEffect(()=>{ + + if(input?.length>0) + sendOscStatus(OSC_ADDRESS.CLIENT_INPUT, `${clientId}#${input}`); // Send current input via OSC + + },[input]); useEffect(() => { refType.current = type; // Update the type reference diff --git a/vite/src/comps/timer.jsx b/vite/src/comps/timer.jsx index 64a4970..9babc10 100644 --- a/vite/src/comps/timer.jsx +++ b/vite/src/comps/timer.jsx @@ -1,8 +1,9 @@ import { useEffect, useState, useRef, forwardRef, useImperativeHandle, } from "react" +import { OSC_ADDRESS, sendOscStatus } from "../util/osc"; const Update_Interval = 1000; // 1 second -export const Countdown=forwardRef(({time, callback, auto, ...props}, ref)=>{ +export const Countdown=forwardRef(({time, callback, auto,clientId, ...props}, ref)=>{ const refTime = useRef(time); @@ -35,6 +36,7 @@ export const Countdown=forwardRef(({time, callback, auto, ...props}, ref)=>{ } if(refDisplay.current) refDisplay.current.innerText = (refTime.current/1000).toFixed(0); + sendOscStatus(OSC_ADDRESS.CLIENT_DURATION, `${clientId}#${(refTime.current/1000).toFixed(0)}`); // send remaining time in seconds via OSC }, Update_Interval); diff --git a/vite/src/pages/flow_free.jsx b/vite/src/pages/flow_free.jsx index b4b2c11..31be7fa 100644 --- a/vite/src/pages/flow_free.jsx +++ b/vite/src/pages/flow_free.jsx @@ -69,6 +69,7 @@ export function FreeFlow(){ const refContainer=useRef(); const refCurrentCue= useRef(null); + const refData=useRef(data); const { history, status, reset, sendMessage, setStatus, audioOutput, setAudioOutput, stop:stopChat, audioUrl }=useChat(); @@ -95,15 +96,18 @@ export function FreeFlow(){ console.log('onOsc', payload); const address=payload.addr; const message=payload.args[0]; + const params=message.split('#'); switch(address){ - case '/playcue': - // playCue(cuelist.find(c => c.id === message)); - setNextCue(()=>message); + case OSC_ADDRESS.PLAY_CUE: + if(params[0]=='all' || params[0]==refData.current?.id) + setNextCue(()=>params[1]); break; - case '/stopcue': - onStop(); + case OSC_ADDRESS.STOP_CUE: + if(params[0]=='all' || params[0]==refData.current?.id) + onStop(); break; + } // Handle OSC messages here @@ -299,7 +303,7 @@ export function FreeFlow(){ sendOsc(OSC_ADDRESS.COUNTDOWN, '0'); // Reset countdown for non-chat cues } - sendOscStatus(`${data.id}#playcue#${cue.id}`); + sendOscStatus(OSC_ADDRESS.CLIENT_STATUS,`${data.id}#playcue#${cue.id}`); console.log('~~~~ clear pause timer'); if(refPauseTimer.current) clearTimeout(refPauseTimer.current); @@ -356,7 +360,7 @@ export function FreeFlow(){ resetTranscript(); // Reset transcript after cue ends - sendOscStatus(`${data.id}#endcue#${cue.id}`); + sendOscStatus(OSC_ADDRESS.CLIENT_STATUS, `${data.id}#endcue#${cue.id}`); if(cue.auto) { playCue(cuelist.find(c => c.id === cue.nextcue)); @@ -541,7 +545,9 @@ export function FreeFlow(){ if(refPauseTimer.current) clearTimeout(refPauseTimer.current); refSpeechPaused.current=false; } - } + + sendOscStatus(OSC_ADDRESS.CLIENT_INPUT, `${data.id}#${transcript}`); // Send current input via OSC + } },[transcript]); @@ -634,13 +640,14 @@ export function FreeFlow(){