Monday, 3 July 2023

Gmic and sox script redux.




 I started using Windows 10 again recently (22h2 with all relevant updates) because I'm doing more online stuff again with Format C and pragmatically when talking to  people who are trying to learn glitch art  techniques for the first time most will be using windows ( mac os people you are on your own I just cant be bothered ), I needed to relearn stuff myself so fresh install of Windows 10 , deal with the usual frustrations and on I go.

 Sooooo long story short I discovered that having used gmic cli in Windows 10 previously , installing it via chocolatey so it was available for use via scripts in git-bash that that option was no longer there , no gmic in chocolatey ( to avoid messing around with path) and worse the gmic add on for gimp was now being identified by windows security as a pup plus the cli version I wanted to use couldnt be added to path or even function within git-bash - oh yea I could use cmd , but who wants to go back to the dark ages of dos cli ( unless im using dos but thats a different post altogether - freedos rocks) 

So whats the solution, and I have to admit this post is mainly for me when I next have to use windows 10 ( god I really hope not - its illogical and ridiculous - where is everything stored why cant I use techniques i use on linux in windows the ridiculous cr lf v's lf - why arent we using utf 8 ? why why why - but I digress) 

The solution is simple , download the gmic cli zip file for windows 10, unzip it then go into the folder copy everything then paste all of that into the git bash folder at C:\Program Files\Git\usr\bin , which then allows me to use this shiny new script which is a work in progress so use at your own risk ( oh yes you need to install sox portable via chocolatey for it to work)- what does it do - it sonifies images and optionally applies a gmic xor blend to your images if you want - it can apply sonification or not ( the none option) and gmic or not - the y/n option or neither !! Its a work in progress so if you enter wrong values it prolly wont work as intended - I may or may  not add more features . Inspired by Vedran Gligo's Megaglitchatron script ( find that here - https://gitlab.com/hacklab01/MegaGlitchATron) copy it and post it into notepad++ or similar  save it as whatever name you want to give it with the .sh extension then run it as 'bash whateveryounameit.sh' via git-bash :

#! /bin/bash
#make directory to hold output
h=$(pwd)
echo $h
mkdir $h/frames
mkdir $h/originals
#get input formats
echo -n "Source image format ? : "
read f
#get destination format
echo -n "Image format to use ? : "
read t
#get effect
echo -n "Effect to use ? : "
read fx
#are we using gmic ( after downloading gmic cli zip and placing that in  C:\Program Files\Git\usr\bin )
echo -n "Use gmic y/n ? : "
read yn
cp *.$f $h/originals

find . -maxdepth 1 -name '*.'$f''|while read filename; do echo ${filename};
#get date to rename file
d=$(date +%Y-%m-%d_%H%M%S)

mv ${filename} test.$f
magick mogrify -format $t test.$f
#rm test.$f
#strip header section for windows
#get header
  head -n 3 test.$t > head.$t;
#strip header ( to avoid damaging it)
  sed -b '1d'  test.$t > swap.$t
 
  #copy that to raw file so we can use sox
cp swap.$t frame.raw
 
#apply effect specified by fx variable
 if [ $fx == "echo" ] || [ $fx == "null" ]
          then
           effect="echos 0.8 0.7 700 0.25 900 0.3 norm"
        elif [ $fx == "reverb" ]
          then
           effect="gain -3 pad 2 8 reverb"
        elif [ $fx == "hilbert" ]
          then
           effect="hilbert -n 5001"
        elif [ $fx == "phaser" ]
          then
           effect="phaser 0.8 0.74 3 0.7 0.5"
        elif [ $fx == "flanger" ]
          then
           effect="flanger 0 2 0 71 0.5 25 lin"
        elif [ $fx == "overdrive" ]
          then
           effect="overdrive 17"   
        elif [ $fx == "none" ]
          then
           effect=""
        fi
#add the effect

sox -r 482170 -e u-law frame.raw frame2.raw $effect
    #try or add these
    #"bass 5"
    #"echo 0.8 0.88 60 0.4"
    #"flanger 0 2 0 71 0.5 25 lin"
    #"hilbert -n 5001"
    #"loudness 6"
    #"norm 90"
    #"overdrive 17"
    #"phaser 0.8 0.74 3 0.7 0.5"
    #"phaser 0.8 0.74 3 0.4 0.5"
    #"pitch 2"
    #"riaa"
    #"sinc 20-4k"
    #"vol 10"

cp frame2.raw swap.$t;
cat head.$t swap.$t > test.$t;

if [ $yn == "n" ] || [ $yn == "null" ]
          then
              magick convert test.$t  $h/frames/$d.$f
           elif [ $yn == "y" ]
          then
            gmic test.$f  test.$t -blend xor -o $h/frames/$d.$f;
        rm test.$f
        fi
#if using displacement comment out line below
#cat head.$t swap.$t > test.$t;
#magick convert test.$t  $h/frames/$d.$f
#mv test.$t $h/frames/$d.$t

rm head.$t
rm test.$f
rm test.$t
rm swap.$t
rm frame.raw
rm frame2.raw

done




 


Mark Fisher – ‘Ghosts of my life’, Fukuyama’s ‘End of history’ and rebooting the future with glitch art.

Note- this was the introduction I gave during a recent online discussion with Verena Voigt ( https://www.verena-voigt-pr.de/ ) a...