import xapi from 'xapi'; xapi.Config.Audio.Input.Microphone[1].Level.get().then((level) => { console.log("Setting text and slider to", level) let sliderVal = level/70*255 sliderVal = (Math.ceil(sliderVal)) xapi.Command.UserInterface.Extensions.Widget.SetValue({WidgetId: 'Text_Micro1', value: level}); xapi.Command.UserInterface.Extensions.Widget.SetValue({WidgetId: 'Slider_Micro1', value: sliderVal}); }) function guiEvent(event) { if (event.WidgetId === 'Slider_Micro1' && event.Type === 'released'){ console.log(event.WidgetId, event.Value) let micVolVal = event.Value/255*70 micVolVal = (Math.ceil(micVolVal)) console.log('Slider output transformed to range of microphone level and rounded up:', micVolVal) xapi.Config.Audio.Input.Microphone[event.WidgetId.slice(-1)].Level.set(micVolVal) xapi.Command.UserInterface.Extensions.Widget.SetValue({WidgetId: 'Text_Micro'+event.WidgetId.slice(-1), value: micVolVal}) } } xapi.Event.UserInterface.Extensions.Widget.Action.on(guiEvent);