From 5d88cf3ea456117a71fa80f9f77b5c6b085d3eff Mon Sep 17 00:00:00 2001 From: Vermoot Date: Sun, 17 Dec 2023 12:23:09 +0100 Subject: [PATCH 1/2] feature/add a framerate dropdown with common framerates and a custom option --- src/XJadeo Video Sync.control.js | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/XJadeo Video Sync.control.js b/src/XJadeo Video Sync.control.js index 17dfe25..d6e9e6b 100644 --- a/src/XJadeo Video Sync.control.js +++ b/src/XJadeo Video Sync.control.js @@ -120,7 +120,9 @@ function invalidateAll() { var onTopSetting; var timeDisplayModeSetting; var pathSetting; +var commonFrameRates = ["23.976", "24", "25", "29.97", "30", "50", "59.94", "60", "Custom"]; // Add more as needed var frameRateSetting; +var customFrameRateSetting; var offsetHoursSetting; var offsetMinutesSetting; var offsetSecondsSetting; @@ -142,9 +144,20 @@ function init() { pathSetting = docState.getStringSetting("Path", "File", 256, ""); pathSetting.markInterested(); - frameRateSetting = docState.getNumberSetting("FPS", "File", 24, 60, 0.01, "", 24); + frameRateSetting = docState.getEnumSetting("Frame Rate", "Video", commonFrameRates, "24"); frameRateSetting.markInterested(); + customFrameRateSetting = docState.getNumberSetting("Custom Frame Rate", "Video", 1, 120, 0.01, "", 24); + customFrameRateSetting.markInterested(); + + frameRateSetting.addValueObserver(function (value) { + if (value === "Custom") { + customFrameRateSetting.show(); + } else { + customFrameRateSetting.hide(); + } + }); + offsetHoursSetting = docState.getNumberSetting("Offset (h)", "Time", -24, 24, 1, "", 0.0); offsetHoursSetting.markInterested(); offsetMinutesSetting = docState.getNumberSetting("Offset (min)", "Time", -60, 60, 1, "", 0.0); @@ -172,18 +185,25 @@ function init() { println("XJadeo Video Sync initialized!"); } +// Modify the flush function function flush() { updateOnTop(onTopSetting.get()); updateTextDisplaySettings(timeDisplayModeSetting.get()); + + frameRate = frameRateSetting.get() === "Custom" ? customFrameRateSetting.getRaw() : frameRateSetting.get(); + oscConnection.sendMessage("/jadeo/frame_rate", frameRate); + if (updateVideo(pathSetting.get())) { invalidateLastFrame(); invalidateLastFrameOffset(); } - let offsetSeconds = offsetSecondsSetting.getRaw() + 60 * offsetMinutesSetting.getRaw() + 3600 * offsetHoursSetting.getRaw(); - updateFrameOffset(Math.floor(offsetSeconds * frameRateSetting.getRaw())); - updateFrame(Math.floor(pos.get() * frameRateSetting.getRaw())); - // updateLoop(loopSetting.get()); // seemingly a bug in Bitwig Studio 4.4.8: Boolean settings not displayed in documentState, sent to support - updateLoop(loopSetting.get() === "On"); // workaround: enum setting + + var offsetSeconds = offsetSecondsSetting.getRaw() + 60 * offsetMinutesSetting.getRaw() + 3600 * offsetHoursSetting.getRaw(); + updateFrameOffset(Math.floor(offsetSeconds * frameRate)); + updateFrame(Math.floor(pos.get() * frameRate)); + updateLoop(loopSetting.get() === "On"); + + // Other flush actions as needed } function exit() { From c381a64a5e91c6bfc5d3349bd48297fa6c616196 Mon Sep 17 00:00:00 2001 From: Vermoot Date: Sun, 17 Dec 2023 12:34:42 +0100 Subject: [PATCH 2/2] fix/remove comments giving away that ChatGPT helped me do this, no one must know --- src/XJadeo Video Sync.control.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/XJadeo Video Sync.control.js b/src/XJadeo Video Sync.control.js index d6e9e6b..970377a 100644 --- a/src/XJadeo Video Sync.control.js +++ b/src/XJadeo Video Sync.control.js @@ -185,7 +185,6 @@ function init() { println("XJadeo Video Sync initialized!"); } -// Modify the flush function function flush() { updateOnTop(onTopSetting.get()); updateTextDisplaySettings(timeDisplayModeSetting.get()); @@ -202,8 +201,6 @@ function flush() { updateFrameOffset(Math.floor(offsetSeconds * frameRate)); updateFrame(Math.floor(pos.get() * frameRate)); updateLoop(loopSetting.get() === "On"); - - // Other flush actions as needed } function exit() {