Skip to content

Instantly share code, notes, and snippets.

@snakecase
Forked from upgradeQ/beep.lua
Last active May 27, 2026 03:55
Show Gist options
  • Select an option

  • Save snakecase/e816384a071cec31efbb4b9e429c108d to your computer and use it in GitHub Desktop.

Select an option

Save snakecase/e816384a071cec31efbb4b9e429c108d to your computer and use it in GitHub Desktop.
OBS Lua: Sound notification on replay buffer save [Windows]

A simple Lua script which plays a .wav sound whenever replay buffer is saved.

Installation

  1. Download Half-Life 2 City Scanner NPC's camera shutter sound: https://github.com/sourcesounds/hl2/blob/master/sound/npc/scanner/scanner_photo1.wav

    • Or use any .wav sound but make sure to match its name either in "Beep on replay buffer save.lua" (edit with any text editor) or rename your .wav file to "sound_npc_scanner_scanner_photo1.wav".
  2. Put it in the same location with "Beep on replay buffer save.lua"

    • A good way is to create a separate "scripts" folder in %AppData%\obs-studio\ and keep all your scripts there in case you need to backup your OBS Settings.
  3. OBS → Tools → Scripts → +

This Lua script was downloaded from https://gist.github.com/snakecase/e816384a071cec31efbb4b9e429c108d

Credits:

Thank you guys!

local obs = obslua
local ffi = require("ffi")
local winmm = ffi.load("Winmm")
-- Put a sound of your choosing next to "Beep on replay save.lua" and don't forget to match its name either in code below or rename your file.
PROP_AUDIO_FILEPATH = script_path() .. "sound_npc_scanner_scanner_photo1.wav"
ffi.cdef[[
bool PlaySound(const char *pszSound, void *hmod, uint32_t fdwSound);
]]
function playsound(filepath)
winmm.PlaySound(filepath, nil, 0x00020000)
end
function on_event(event)
if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED
then playsound(PROP_AUDIO_FILEPATH)
end
end
function script_load(settings)
obs.obs_frontend_add_event_callback(on_event)
end
-- This Lua script was downloaded from https://gist.github.com/snakecase/e816384a071cec31efbb4b9e429c108d
-- Credits: upgradeQ (https://gist.github.com/upgradeQ/b2412242d76790d7618d6b0996c4562f), gima (https://gitlab.com/gima/obsnotification)
-- Thank you guys!
@snakecase

Copy link
Copy Markdown
Author

It's already set to 0x00020000 in the sctipt. 🤔

@sutex

sutex commented May 11, 2024

Copy link
Copy Markdown

Hello!

Ha, I enjoyed this script, so I made some additions to it. I made some sounds based off on the Black Mesa's turret sounds (we're still using Half Life related effects, right?). As I toggle buffer on and off, I wanted a way to know whether it was toggled on or off.

here's how the script would be

local obs = obslua
local ffi = require("ffi")
local winmm = ffi.load("Winmm")

-- Put a sound of your choosing next to "Beep on replay save.lua" and don't forget to match its name either in code below or rename your file.
PROP_AUDIO_SAVE = script_path() .. "Cam_SAVE.wav"
PROP_AUDIO_START = script_path() .. "Cam_ON.wav"
PROP_AUDIO_SHUTDOWN = script_path() .. "Cam_OFF.wav"

ffi.cdef[[
    bool PlaySound(const char *pszSound, void *hmod, uint32_t fdwSound);
]]

function playsound(filepath)
    winmm.PlaySound(filepath, nil, 0x00020000)
end

function on_event(event) 
  if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED 
    then playsound(PROP_AUDIO_START) 
  end 
  if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED 
    then playsound(PROP_AUDIO_SAVE) 
  end 
  if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED
    then playsound(PROP_AUDIO_SHUTDOWN) 
  end 
end

function script_load(settings)
  obs.obs_frontend_add_event_callback(on_event)
end

-- This Lua script was downloaded from https://gist.github.com/snakecase/e816384a071cec31efbb4b9e429c108d

-- Credits: upgradeQ (https://gist.github.com/upgradeQ/b2412242d76790d7618d6b0996c4562f), gima (https://gitlab.com/gima/obsnotification)
-- Thank you guys!

bear in mind I'm no programmer, but I think I heard something about case switch or something that would be better here? idk, it's just basic code. It works.

These are the wav files click here

Same installation procedure as the original script. I used the lowered volume WAV files that someone supplied here (with I guess 75% lower volume?) File was also actually an MP3, but I'm sending it over as a correct .wav file anyway.

And there you have it. Volume is pretty quiet, I guess. Sounds OK from the TV speakers, which is what I'm listening from.

Hi when I use this script and turn on the replay buffer, it turns off seconds later. In the original, this didn't happen.

@ipsusu

ipsusu commented Jun 8, 2024

Copy link
Copy Markdown

Hello!

Ha, I enjoyed this script, so I made some additions to it. I made some sounds based off on the Black Mesa's turret sounds (we're still using Half Life related effects, right?). As I toggle buffer on and off, I wanted a way to know whether it was toggled on or off.

here's how the script would be

local obs = obslua
local ffi = require("ffi")
local winmm = ffi.load("Winmm")

-- Put a sound of your choosing next to "Beep on replay save.lua" and don't forget to match its name either in code below or rename your file.
PROP_AUDIO_SAVE = script_path() .. "Cam_SAVE.wav"
PROP_AUDIO_START = script_path() .. "Cam_ON.wav"
PROP_AUDIO_SHUTDOWN = script_path() .. "Cam_OFF.wav"

ffi.cdef[[
    bool PlaySound(const char *pszSound, void *hmod, uint32_t fdwSound);
]]

function playsound(filepath)
    winmm.PlaySound(filepath, nil, 0x00020000)
end

function on_event(event) 
  if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED 
    then playsound(PROP_AUDIO_START) 
  end 
  if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED 
    then playsound(PROP_AUDIO_SAVE) 
  end 
  if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED
    then playsound(PROP_AUDIO_SHUTDOWN) 
  end 
end

function script_load(settings)
  obs.obs_frontend_add_event_callback(on_event)
end

-- This Lua script was downloaded from https://gist.github.com/snakecase/e816384a071cec31efbb4b9e429c108d

-- Credits: upgradeQ (https://gist.github.com/upgradeQ/b2412242d76790d7618d6b0996c4562f), gima (https://gitlab.com/gima/obsnotification)
-- Thank you guys!

bear in mind I'm no programmer, but I think I heard something about case switch or something that would be better here? idk, it's just basic code. It works.

These are the wav files click here

Same installation procedure as the original script. I used the lowered volume WAV files that someone supplied here (with I guess 75% lower volume?) File was also actually an MP3, but I'm sending it over as a correct .wav file anyway.

And there you have it. Volume is pretty quiet, I guess. Sounds OK from the TV speakers, which is what I'm listening from.

This worked for me, where the original script didn't. Thank you! It might have been a problem with my WAV file tbh...

@kuzante

kuzante commented Jun 15, 2024

Copy link
Copy Markdown

wasnt working until i corrected to 0x00020000 but now its does the windows background sound instead of the wav sound idk why

Yeah I'm having the same issue now as well. I am on OBS 30.1.2 if that might affect things.

@geenaxion

Copy link
Copy Markdown

Thanks for this.
It works as intended.

Got a question though.
How can I mute the sound notifcation on the recording itself? Like it will activate the sound notifcation but on the recording it wont capture the sound?

@ccyannc

ccyannc commented Jul 4, 2024

Copy link
Copy Markdown

For those getting the default windows background sound, make sure your WAV file is uncompressed.

Windows seems to have issue playing compressed WAV files. Spent too much time googling before I stumbled upon this.

@erasene

erasene commented Aug 9, 2024

Copy link
Copy Markdown

Just getting the default windows background sound as well

@S4adam

S4adam commented Oct 2, 2024

Copy link
Copy Markdown

How can I mute the sound notifcation on the recording itself? Like it will activate the sound notifcation but on the recording it wont capture the sound?

you found a workaround yet?

@snakecase

Copy link
Copy Markdown
Author

Sorry for the late reply. To stop this sound from showing up in recordings you either have to:
A. Reroute playback of this sound to some other device/software channel (not sure it's possible) via code which I have no clue how to implement
B. Record audio only from applications of your preference which can be done via OBS → Sources → Add → Application Audio Capture (BETA). This should work but will require setup each time you change applications (e.g. playing different games)

Regarding issues with playback, I have now tested this script in Win 11 Pro, and it works just fine, as well as in Win 10.

@S4adam

S4adam commented Jan 28, 2025

Copy link
Copy Markdown

@khezuu which most likely means it can't find the audio file. Make sure you put it next to the script (where the OBS stores it):
Windows: C:\Users\<user>\AppData\Roaming\obs-studio

@iAxed

iAxed commented Apr 17, 2025

Copy link
Copy Markdown

how do I make the audio quieter?

@NateLapT

Copy link
Copy Markdown

how do I make the audio quieter?

use audacity

@schniti269

Copy link
Copy Markdown

oh that makes sense! It does sound familiar. I don't use SteamVR but it might even be Steam's default screenshot sound effect, now that I think about it...

it is the steam screenshot sound by default

@superspeed500

Copy link
Copy Markdown

Thanks for providing this code! This code also works on Fedora linux (Gnome) if its modified as following.

local obs = obslua
local ffi = require("ffi")

-- Put a sound of your choosing next to "Beep on replay save.lua" and don't forget to match its name either in code below or rename your file.
PROP_AUDIO_FILEPATH = script_path() .. "sound_npc_scanner_scanner_photo1.wav"

ffi.cdef[[
    bool PlaySound(const char *pszSound, void *hmod, uint32_t fdwSound);
]]

function playsound(filepath)
    os.execute("/usr/bin/play " .. filepath)
end

function on_event(event) 
  if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED 
    then playsound(PROP_AUDIO_FILEPATH) 
  end 
end

function script_load(settings)
  obs.obs_frontend_add_event_callback(on_event)
end

-- This Lua script was downloaded from https://gist.github.com/snakecase/e816384a071cec31efbb4b9e429c108d

-- Credits: upgradeQ (https://gist.github.com/upgradeQ/b2412242d76790d7618d6b0996c4562f), gima (https://gitlab.com/gima/obsnotification)
-- Thank you guys!
-- Modified by Superspeed500 to work on Linux. Requires the package sox.

The package sox is required for the play command to work.
sudo dnf install sox

Will probably work on other distros also, but I only have Fedora, so thats what I have tested :)

@kvnmtz

kvnmtz commented Sep 25, 2025

Copy link
Copy Markdown

Thanks!
For anyone looking for another good sound, I used this one:
https://github.com/aosp-mirror/platform_frameworks_base/blob/main/data/sounds/effects/material/ogg/VideoRecord.ogg
To convert it to .wav and make it a bit quieter i just used this ffmpeg command:

ffmpeg -i VideoRecord.ogg -af 'volume=0.33' VideoRecord.wav

@Kat299

Kat299 commented Nov 30, 2025

Copy link
Copy Markdown

Thanks for providing this code! This code also works on Fedora linux (Gnome) if its modified as following.

local obs = obslua
local ffi = require("ffi")

-- Put a sound of your choosing next to "Beep on replay save.lua" and don't forget to match its name either in code below or rename your file.
PROP_AUDIO_FILEPATH = script_path() .. "sound_npc_scanner_scanner_photo1.wav"

ffi.cdef[[
    bool PlaySound(const char *pszSound, void *hmod, uint32_t fdwSound);
]]

function playsound(filepath)
    os.execute("/usr/bin/play " .. filepath)
end

function on_event(event) 
  if event == obs.OBS_FRONTEND_EVENT_REPLAY_BUFFER_SAVED 
    then playsound(PROP_AUDIO_FILEPATH) 
  end 
end

function script_load(settings)
  obs.obs_frontend_add_event_callback(on_event)
end

-- This Lua script was downloaded from https://gist.github.com/snakecase/e816384a071cec31efbb4b9e429c108d

-- Credits: upgradeQ (https://gist.github.com/upgradeQ/b2412242d76790d7618d6b0996c4562f), gima (https://gitlab.com/gima/obsnotification)
-- Thank you guys!
-- Modified by Superspeed500 to work on Linux. Requires the package sox.

The package sox is required for the play command to work. sudo dnf install sox

Will probably work on other distros also, but I only have Fedora, so thats what I have tested :)

Worked for me too on Arch, thanks!

@everydayrice

Copy link
Copy Markdown

For anyone having issues with getting the default windows background sound I used CloudConvert on my .mp3 and converted it to .wav

This fixed it for me for some reason.

@vd4z

vd4z commented Dec 20, 2025

Copy link
Copy Markdown

am i the only one that the .wav file instantly gets deleted when cueing it

@MIDNI6HT

Copy link
Copy Markdown

By the way, if you're reading this and you use Replay Buffer on Linux, I made a quick write up on the tips and tricks I've discovered along the way as I setup my OBS Studio to work like Shadowplay, You can read more here.

@WaavvyyD

WaavvyyD commented May 27, 2026

Copy link
Copy Markdown

For anyone that is getting a Windows background noise, I may have figured out why:

When trying to download a sound effect online, the first one I choose was so quick that it was under 1 second. Would literally be so quick it would stay at 0:00 once playing it. I then got a sound effect that was slightly longer, and that seemed to play the sound effect normally. Try getting a sound that is closer to 0.5-1 second and it may give the script time to actually run it instead of blazing through it so fast it doesn't get registered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment