Decided to move the subtopic found within ‘Glitch’ Art Filters - again into a whole thread to keep it focused. Inviting @Joan_Rake1
The point is to create a filter that can replace audacity databending.
The reason being:
- It’s to explore algorithm used in sound and converting it into a g’mic-qt script.
- It’s better as a collaborative project since there’s quite a lot of algorithms out there pertaining to sound manipulation.
- Figure out some problems with the current code. (I know it’s for single image as this is experimental, and will do
repeat $! l[$>] endl done
. - Finally, figure out how to have several user-defined arguments as a vector and insert all of those arguments at once within the Insert Code block.
rep_auda cxzy
rep_auda:
('$1')
l.
s x
remove_duplicates
a x
if w#-1!=4
error !dups?==F
fi
endl
4,1,1,1,"begin(numid_xyzc=[120,121,122,99];);
numid_xyzc[find(#-1,numid_xyzc[x],0,1)];"
img2text. ,
unpermute_string=${}
rm[-2,-1]
permute $1
whds={[w,h,d,s]}
unroll x
#Insert Code Here#
f int(x/(w/3))%2?j(i*(5*x/(w-1)-int(5*x/(w-1)))):i
#End#
r $whds,-1
permute $unpermute_string
Allow me to explain what does this command does.
- Create 4x1x1x1 image with chars converted to numbers. 120,121,122,99 respectively for ‘xyzc’.
- On the local command, it checks if there are duplicates. I think it can be expanded to find invalid numbers, but I assume permute already does that even though I had not checked.
- After the local part of command is finished, what this does is to find the unpermute string. It does this by inserting number to corresponding numbers respectively for ‘xyzc’.
- img2text return numbers as series of characters.
- unpermute_string=${} insert the returned characters.
- Then once the strings are checked out, those images that are numberical representation of characters are no longer needed.
- permute swaps x,y,z,c id of image.
- unroll converts into 1D image. This makes it possible to stimulate audacity filters.
- This is where the user-defined processes go in.
- Then r $whds,-1 rolls it back basically.
- Finally, permute using the reverse-permute string.
The one problem: What if I wanted to define 3 variables instead, and leave 1 variable as appended and is it really necessary? I know that for xyzc case, you can split into 4 and append channel together after you unrolled.
The rest, I will try to explore sound algorithm to the best of my ability. Others are welcomed to add code used for 1D processing.
Functions found (Adding some meanwhile):
rep_linear_echo: repeat $1 f lerp(j(($2%*w)),i,x/$3-int(x/$3)) done
Example:
rep_washy_waves: f j(tan(x/(w/10))*(w/100)*.002*sin(x/10))
rep_crop_and_replace:
+crop 10%,20%
f.. x>(.5*(w-1))&&x<=(.65*(w-1))?i(#-1,50+x%(w#-1-1)):i
rm.
rep_stretch_and_replace:
f I(x/$1,0,0,$2,$3)
sx={$1%*w}
ex={$2%*w}
dx={$3%*w}
dg=1
dc=.2
edc={1/$4*$dc}
repeat $4
nsx={$sx+$dx}
nex={$ex+$dx}
+crop[0] $sx,$ex
+crop[0] $nsx,$nex
*. $dg
f. "
a=i(#-2);b=i;
mh=a+b;
lerp(a,b,b/(mh?mh:1));
"
j[0] .,$nsx
rm[-2,-1]
sx={$nsx}
ex={$nex}
dg-=$edc
done
Preview:
rep_fade:
ww={w-1}
ix={int($1%*$ww)}
ex={int($2%*$ww)}
+crop $ix,$ex
l.
s x,$3
ww={w-1}
if $4 f i*(1-(x/$ww)*.5)
else f i*x/$ww*.5
fi
a x
endl
j.. .,$ix
rm.
rep_shuffle:
ww={w-1}
pxa={$1%*$ww}
pxb={$2%*$ww}
+crop $pxa,$pxb
ww={w-1}
l.
repeat $3
m1={int(u(0,1)*$ww)}
m2={int(u(0,1)*$ww)}
m={min($m1,$m2)},{max($m1,$m2)}
n1={int(u(0,1)*$ww)}
n2={int(u(0,1)*$ww)}
n={min($m1,$m2)},{max($m1,$m2)}
+crop[0] $m
+crop[0] $n
j[0] .,{min($m1,$m2)}
j[0] ..,{min($n1,$n2)}
rm[-2,-1]
done
endl
j.. .,$pxa
rm.
rep_repeat_part:
+crop[0] 5%,10%
+crop[0] 12%,52%
f. i(#-2,x,0,0,0,1,2)
j[0] .,{15%*(w-1)}
rm[-2,-1]
rep_seawave_distort:
rw={(w-1)*50/100}
off={(w-1)*-.05/100}
f j(1-abs(((sqrt(1-((x%$rw-$rw)/$rw)^2))-.5))^5*$off,0,0,0,0,2)
_iain_low_pass_filter:
if $1>0 fill >i*$1+j(-1)*(1-$1)
else fill >i*abs($1)-j(-1)*(1-abs($1))
fi