Skip to content

Instantly share code, notes, and snippets.

-- @version 1.0
-- @author cfillion
package.path = reaper.ImGui_GetBuiltinPath() .. '/?.lua'
local ImGui = require 'imgui' '0.9'
local SCRIPT_NAME = 'imgui.lua 0.9 upgrader'
local FLT_MIN, FLT_MAX = ImGui.NumericLimits_Float()
local ctx = ImGui.CreateContext(SCRIPT_NAME)
local code
@cfillion
cfillion / syntax-highlighting.user.js
Last active April 13, 2024 11:11
Syntax highlighting on the REAPER forum
// ==UserScript==
// @name Syntax highlighting
// @namespace https://cfillion.ca
// @version 1.0.3
// @author cfillion
// @include https://forum.cockos.com/showthread.php*
// @include https://forum.cockos.com/showpost.php*
// @include https://forum.cockos.com/editpost.php*
// @include https://forum.cockos.com/newreply.php*
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.3/highlight.min.js
@cfillion
cfillion / sws_preview_test.lua
Last active March 21, 2024 05:51
SWS preview API test
-- ARCHIVED VERSION
-- latest maintained version is on the ReaTeam Reascripts repository
package.path = reaper.ImGui_GetBuiltinPath() .. '/?.lua'
local ImGui = require 'imgui' '0.9'
local SCRIPT_NAME = 'SWS CF_Preview API demo'
local FLT_MIN, FLT_MAX = ImGui.NumericLimits_Float()
local ctx = ImGui.CreateContext(SCRIPT_NAME)
local sans_serif = ImGui.CreateFont('sans-serif', 13)
@cfillion
cfillion / wav-parser.lua
Last active March 15, 2024 01:22
Lua WAV file reader (chunk parser)
-- http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
-- usage example at the end
local WavReader = {}
WavReader.__index = WavReader
function WavReader.new(fn)
local self = setmetatable({}, WavReader)
self.file, err = io.open(fn)
@cfillion
cfillion / ja_JP.UTF-8.md
Last active February 26, 2024 14:09
Solution for locale and character encoding issues in Japanese games on Steam Deck

Problem 1

Cannot access filenames containing non-ASCII characters.

Steam Deck's SteamOS 3 provides only one locale named en_US.utf8 (as configured in /etc/locale.gen) but /etc/locale.conf sets LANG to en_US.UTF-8. They don't match, so the effective locale for programs is C and the character set becomes limited to ASCII.

Set the game's launch options in Steam to LANG=en_US.utf8 %command% to solve this.

To fix this for all applications running in desktop mode (eg. to correctly extract games), create a file named ~/.config/plasma-workspace/env/utf8.sh containing (restart desktop mode to apply):

@cfillion
cfillion / gfx-replay.lua
Last active January 23, 2024 22:01
Record and replay gfx code
-- GFXREPLAY_RECORD = true
-- gfx = dofile('/path/to/gfx-replay.lua')
GFX2IMGUI_DEBUG = GFX2IMGUI_DEBUG or false
GFX2IMGUI_MAX_DRAW_CALLS = GFX2IMGUI_MAX_DRAW_CALLS or 1<<13
GFX2IMGUI_NO_BLIT_PREMULTIPLY = GFX2IMGUI_NO_BLIT_PREMULTIPLY or false
GFX2IMGUI_NO_LOG = GFX2IMGUI_NO_LOG or false
local ImGui = {}
for name, func in pairs(reaper) do
@cfillion
cfillion / reascript_vararg.hpp
Last active December 27, 2023 19:38
Compile-time ReaScript API vararg wrapper generator for REAPER extensions (C++17)
// Extracted from ReaPack's and ReaImGui's source code (LGPL v3)
/* Usage example:
static int HelloWorld(int foo, int bar) { return foo * bar; }
extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT(
REAPER_PLUGIN_HINSTANCE instance, reaper_plugin_info_t *rec)
{
// ...
// API_HelloWorld and APIdef_HelloWorld must also be registered as usual
@cfillion
cfillion / reaper_60fps.cpp
Last active December 27, 2023 19:38
Make REAPER scripts go brrr
// Set REAPER misc timer interval to 60 Hz
//
// 1. Grab reaper_plugin.h from https://github.com/justinfrankel/reaper-sdk/raw/main/sdk/reaper_plugin.h
// 2. Grab reaper_plugin_functions.h by running the REAPER action "[developer] Write C++ API functions header"
// 3. Grab WDL: git clone https://github.com/justinfrankel/WDL.git
// 4. Build then copy or link the binary file into <REAPER resource directory>/UserPlugins
//
// Linux
// =====
//
@cfillion
cfillion / openocd-LPC546xx.cfg
Last active December 12, 2023 22:09
OpenOCD script for LPC546xx via MCU-Link2 (w/o flash support)
set CHIPNAME LPC546xx
set CPUTAPID 0x10CAA02B
adapter driver cmsis-dap
transport select swd
adapter speed 3000
# gdb_memory_map enable
# gdb_flash_program enable
@cfillion
cfillion / orignal-poster.user.js
Last active May 11, 2023 21:22
Show an indicator beside an original poster's post on the REAPER forums https://i.imgur.com/oxUj5Ws.png
// ==UserScript==
// @name Original poster indicator
// @namespace https://cfillion.ca
// @version 1.2
// @author cfillion
// @include https://forum.cockos.com/showthread.php*
// ==/UserScript==
// See also: syntax-highlighting.user.js https://gist.github.com/cfillion/7fd2bfe13465a8a37d28a9f0fd60b13b