Skip to content

Instantly share code, notes, and snippets.

View cfillion's full-sized avatar

Christian Fillion cfillion

View GitHub Profile
// c++ -fPIC -O2 -std=c++14 -DSWELL_PROVIDED_BY_APP -IWDL -IWDL/WDL -dynamiclib reaper_idenoreload.cpp WDL/WDL/swell/swell-modstub.mm -lc++ -framework AppKit -o reaper_ideautoreload.dylib
//
// cl /nologo /O2 reaper_idenoreload.cpp User32.lib /link /OPT:REF /PDBALTPATH:%_PDB% /DLL /OUT:reaper_ideautoreload.dll
#ifndef _WIN32
# include <sys/mman.h>
# include <WDL/wdltypes.h>
#endif
#include <cstdint>
// equivalent to __builtin_return_address(1);
uintptr_t rbp {};
asm("mov %%rbp, %0" : "=r"(rbp));
rbp = *reinterpret_cast<uintptr_t *>(rbp); // dig one level
intptr_t *ret { reinterpret_cast<uintptr_t *>(rbp + 8) };
*ret = s_current->m_redirect;
@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
// =====
//
// ConfigVar Layout
//
// 1. Grab reaper_plugin.h from https://landoleet.org/dev/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
// =====
//
-- @version 0.2beta
-- @author cfillion
local RECURSIVE = false
local NESTED_RULES = {
['folder level 1'] = {
['folder level 2'] = {
'track to select',
},
},
@cfillion
cfillion / main.cpp
Last active October 12, 2022 02:43
Proof of concept: Add prevent UI refresh to REAPER native custom actions
#include <cstring>
#define REAPERAPI_IMPLEMENT
#include <reaper_plugin_functions.h>
const char *(*__localizeFunc)(const char *str, const char *subctx, int flags);
static bool IsCustomAction(KbdSectionInfo *section, const int id)
{
// logic from SWS's IsMacroOrScript
@cfillion
cfillion / reaper_gmem.cpp
Last active May 2, 2023 21:35
Proof of concept for accessing gmem data from REAPER extensions using eel_gmem_attach
#include "reaper_plugin.h"
#define EEL_F_SIZE WDL_FFT_REALSIZE
#include "WDL/WDL/eel2/nseel-ram.c"
EEL_F *** (*eel_gmem_attach)(const char *nm, bool is_alloc);
void (*eel_enter_mutex)();
void (*eel_leave_mutex)();
void NSEEL_HOSTSTUB_EnterMutex() { eel_enter_mutex(); }
@cfillion
cfillion / index.php
Last active December 3, 2019 02:07
File listing script for SWS bleeding edge builds
<?php
function file_info($file)
{
$icons = [
'dmg' => 'apple',
'exe' => 'windows',
'xz' => 'linux',
];
return [
@cfillion
cfillion / TLC591x_R-EXT.rb
Last active September 24, 2019 03:12
Calculate valid output current ranges for given R-EXT values [TLC5916/TLC5917 8-Channel Constant-Current LED Sink Driver]
#!/bin/env ruby
#
# TLC5916/TLC5917 8-Channel Constant-Current LED Sink Driver
# Calculate valid output current ranges for given R-EXT values
#
# Run with no arguments to print all valid ranges for common E12 and E96 values
# See ./TLC591x_R-EXT.rb --help for usage instructions and supported options.
#
# Example 1: ./TLC591x_R-EXT.rb 360 720
# Rext= 360Ω Imin= 4.375mA Imax= 52.090mA IΔ= 47.715mA
@cfillion
cfillion / mpasmx
Created September 21, 2019 21:59
Wrapper to make mpasmx output errors to stderr and fail with a proper exit code
#!/bin/sh
errfile="$(mktemp)"
exit=0
/opt/microchip/mplabx/v*.*/mpasmx/mpasmx -e"$errfile" "$@"
if [ -s "$errfile" ]; then
cat "$errfile" >&2
exit=1