Skip to content

Instantly share code, notes, and snippets.

View cfillion's full-sized avatar

Christian Fillion cfillion

View GitHub Profile
-- @version 1.0beta
-- @author cfillion
local EXT_SECTION = 'cfillion_project_list'
local function makeKey(i)
return string.format('project%d', i)
end
local function enumOpenedProjects()
@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
@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_square.cpp
Last active December 19, 2024 15:43
A REAPER extension that draws a red square on the arrange view.
#include <memory>
#ifdef _WIN32
# include <windows.h>
#else
# include <swell/swell.h>
# include <wdltypes.h> // GWLP_WNDPROC
#endif
#define REAPERAPI_IMPLEMENT
// Demo REAPER extension to intercept keyboard input
// https://i.imgur.com/xMSrqRr.gif
#include <cstdio>
#include <reaper_plugin.h>
static int (*plugin_register)(const char *name, void *infostruct);
static int HandleKey(MSG *, accelerator_register_t *);
static accelerator_register_t g_accel{HandleKey, true};
function checkJSAPI(requiredVersion)
if reaper.JS_ReaScriptAPI_Version and reaper.JS_ReaScriptAPI_Version() >= requiredVersion then
return true
end
local button = reaper.MB(string.format([[
This script requires js_ReaScriptAPI %s or newer. Do you want to install it now?
Choose [Yes] to open ReaPack's package browser.
]], requiredVersion), "js_ReaScriptAPI not found", 4)
@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 / fctest.cpp
Last active August 16, 2018 01:14
Font family matching with FontConfig demo
// c++ -lfontconfig fctest.cpp
// ./a.out 'DejaVu Sans Mono' monospace 'Andale Mono' 'Ubuntu Mono' Lato
#include <cstdio>
#include <fontconfig/fontconfig.h>
class FontConfig {
public:
FontConfig() : m_config(FcInitLoadConfigAndFonts()) {}
FontConfig(const FontConfig &) = delete;
require 'json'
files = {}
d = File.open "test", &JSON.method(:load)
d.each {|r|
r['assets'].each {|a|
files[a['name']] ||= 0
files[a['name']] += a['download_count']
}
-- https://forum.cockos.com/showthread.php?t=200086
function solo(trackIndex)
local track = reaper.GetTrack(0, trackIndex)
if not track then return false end
reaper.PreventUIRefresh(1)
reaper.SoloAllTracks(0)
reaper.SetMediaTrackInfo_Value(track, 'I_SOLO', 1)