Skip to content

Instantly share code, notes, and snippets.

@cfillion
cfillion / lane_sizes.csv
Last active November 17, 2019 12:47
Test script of my new dynamic ruler lane height logic for SWS https://i.imgur.com/sR44czh.png
Ruler Height Regions Markers Tempo
66 14 14 11
69 15 15 12
75 16 16 13
80 17 17 14
85 18 18 15
90 19 19 16
96 20 20 17
@cfillion
cfillion / reaper_barebone.cpp
Last active May 20, 2024 07:19
Bare-bone REAPER extension (prints Hello World! using the API)
// Bare-bone REAPER extension
//
// 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 / load-reaper-api.cpp
Last active July 3, 2020 17:18
Loader for the REAPER C++ API
// Usage:
// if(rec->caller_version != REAPER_PLUGIN_VERSION || !loadAPI(rec->GetFunc))
// return 0;
// See also (bare-bone REAPER extension):
// https://gist.github.com/cfillion/f32b04e75e84e03cc463abb1eda41400
#define REQUIRED_API(name) {(void **)&name, #name, true}
#define OPTIONAL_API(name) {(void **)&name, #name, false}
static bool loadAPI(void *(*getFunc)(const char *))
-- 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)
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']
}
@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;
@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)
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)
// 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};
@cfillion
cfillion / reaper_square.cpp
Last active March 18, 2019 20:06
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