local obs = obslua local ffi = require("ffi") local winmm = ffi.load("Winmm") local bit = require("bit") AUDIO_FILE = script_path() .. "replay buffer save sound.wav" -- Name of audio file AUDIO_VOLUME = 0.2 -- Volume is a float between 0.0 and 1.0 ffi.cdef[[ bool PlaySound(const char *pszSound, void *hmod, uint32_t fdwSound); int waveOutSetVolume(void *hwo, uint32_t dwVolume); ]] function set_volume(volume) local left = math.floor(volume * 0xFFFF) local right = left local combined = bit.bor(bit.lshift(right, 16), left) winmm.waveOutSetVolume(nil, combined) end function playsound(filepath) set_volume(AUDIO_VOLUME) winmm.PlaySound(filepath, nil, 0x00020000) end function on_event(event) if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED then playsound(AUDIO_FILE) end end function script_load(settings) obs.obs_frontend_add_event_callback(on_event) end -- Original script downloaded from https://gist.github.com/snakecase/e816384a071cec31efbb4b9e429c108d -- Original authors: upgradeQ (https://gist.github.com/upgradeQ/b2412242d76790d7618d6b0996c4562f) & gima (https://gitlab.com/gima/obsnotification)