Skip to content

Instantly share code, notes, and snippets.

View coderofsalvation's full-sized avatar

Coder of Salvation / Leon van Kammen coderofsalvation

View GitHub Profile
@coderofsalvation
coderofsalvation / MANIFESTO.md
Last active June 30, 2022 08:46
unix dsp's (UD's) as offline alternative to VST/LV2 plugins)

Unix DSP processors (UDSP's)

Let's face it, non-realtime audio is as important as realtime audio.
UDSP's are a great offline alternative to realtime plugins, which allow for polyglot-scriptable synth & fx-chains.

crossplatform example UD

$ ./myudsp[.exe] [-o out.wav] [-n 60] [in1.wav in2.wav ..] # on unix/mac/linux
@coderofsalvation
coderofsalvation / startpods
Last active May 26, 2022 10:35
start pods on boot
#!/bin/sh
# usage:
# 1. put podi project;s in /home/foo/projectname
# 2. to disable podboot create /home/foo/projectname/podi.stop
# 3. install service using './startpods install'
start(){
apps="$(find /home/*/*/podi)"
for app in $apps; do
test -f $app".noboot" && continue
user=$(echo $app | awk -F'/' '{ print $3 }')
@coderofsalvation
coderofsalvation / test.c
Created May 5, 2022 15:35
scaling limiter attempt
// problem: it's bad
if( treshold > 0.0f ){
float avg = srcL + srcR;
if( avg > peak ) peak = avg;
buffer[i] = (mp_sint32)( tanh(srcL*1.2) * 1.31 * max); // compand once
buffer[i+1] = (mp_sint32)( tanh(srcR*1.2) * 1.31 * max); // compand once
if( ZEROCROSSING(srcL+srcR,lastL) ){
for( ; offset <= i; offset+=2 ){
float L = (float)buffer[offset]*(1.0/max);
float R = (float)buffer[offset+1]*(1.0/max);
@coderofsalvation
coderofsalvation / fft.sh
Created May 1, 2022 17:17
ffmpeg example template for audio fft processing #filtergraph #batch
#!/bin/bash
# the following mixes 2 FFT-expressions into a dry (FFT) signal
set -e
in=/tmp/somefile.wav
out="$in.ffmpeg.wav"
winsize=1024
fft_a_r="real='0'"
fft_a_i="imag='tanh(re / 8) * lt(b,4)" # bins 0-4
fft_b_r="real='0'"
fft_b_i="imag='tanh(re * 1.8) * gt(b,150) * lt(b,512)'" # bins 150-512
@coderofsalvation
coderofsalvation / renderall
Last active March 12, 2022 14:21
convert cardboard camera vr files to oculus quest stereo mp4 using ffmpsg
#!/bin/bash
# usage:
# * put this script in a folder (`./renderall` e.g.)
# * chmod 755 renderall
# * convert carboard camera pictures to same folder using this tool: https://github.com/AbosaSzakal/CarboardCamera-Converter
# * run ./renderall
# * voila..mp4 files are now in directory /out
fps=25
test -d out && rm -rf out
mkdir out
@coderofsalvation
coderofsalvation / eco-friendly-tiny-server-patterns.md
Last active November 3, 2022 10:25
My favorite (awesome) eco-friendly server patterns

tiny servers: the serverpark killers

auto-suspend-wakeup webservices

stop wasting cpu/mem-resources on idling services:

#!/bin/sh
while sleep 1s; do
 set +e
@coderofsalvation
coderofsalvation / myscript.sh
Created February 7, 2022 17:30
decorators / monkeypatching in bourne shell / bash
#!/bin/sh
# usage:
# ./myscript.sh foo bar
# handler called: foo bar
# i am foo
call(){ type on_$1 1>/dev/null 2>/dev/null && on_$1 "$@" || "$@"; }
on_foo(){
echo before handler called: "$@"
@coderofsalvation
coderofsalvation / equi2lovr.sh
Last active January 5, 2022 09:23
equirectangular map to plain-mipmapped cubemap (lovr) converter (using ffmpeg)
#!/bin/sh
# usage: ./equi2lovr.sh equi.png
mkdir env 2>/dev/null
ffmpeg -i $1 -vf "v360=input=equirect:output=c6x1" -y -vframes 1 $1.map.jpg
i=0
for face in px nx py ny pz nz; do
ffmpeg -i $1.map.jpg -filter_complex '[0:v] crop=(iw/6):ih:((iw/6)*'$i'):0,split=10[m][m0][m1][m2][m3][m4][m5][m6][m7][m8]' \
-map '[m]' -s 1024x1024 env/$face.png \
-map '[m0]' -s 256x256 env/m0_$face.png \
-map '[m1]' -s 128x128 env/m1_$face.png \
@coderofsalvation
coderofsalvation / cheap_3d_animation.md
Last active January 11, 2022 15:46
cheap 3d tricks

Useful cheap 3D animation tricks

water / fluids

  • create a rotating plane
  • create material with low roughness and high metallic
  • assign a heightmap to the normals
  • adjust the uv coordinates so that the heightmap is very zoomed in
@coderofsalvation
coderofsalvation / useful-lua-patterns.md
Last active October 21, 2022 06:26
My favorite lua patterns

Useful Lua Patterns/Functions

NOTE: for JS patterns see my JS patterns-page

Simple javascript-like template function

-- print( tpl("${name} is ${value}", {name = "foo", value = "bar"}) )
-- "foo is bar"
function tpl(s,tab)