Last active
December 2, 2021 20:32
-
-
Save rocktronica/2d6c59065fff809a182bde0d85a1869f to your computer and use it in GitHub Desktop.
audio_to_visual.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A script to make a trippy GIF of a RAW file | |
# Shared w/ Dogbotic's "Ear Re-Training" class | |
# REQUIREMENTS: imagemagick, command-line familiarity | |
{ | |
# Not all dimensions work well. I think depth can also be 16, 8, 4, etc | |
width="768" | |
height="1024" | |
depth="32" | |
input_slug="9" # the 9 in 9.raw, as renamed from "9 Audio Track.aiff" | |
# A function that takes a "modulus" and uses it to create a PNG of the RAW image | |
# IDK what it's actually doin! | |
# https://legacy.imagemagick.org/Usage/transform/#evaluate | |
function convert_with_modulus() { | |
printf -v modulus "%02d" $i | |
echo "$input_slug-$depth-${width}x${height}-$modulus.png" | |
convert \ | |
-size "${width}x${height}" \ | |
-depth "$depth" \ | |
uyvy:"$input_slug.raw" \ | |
-colorspace sRGB \ | |
-evaluate AddModulus "$modulus%" \ | |
-define quantum:format=signed \ | |
-auto-level \ | |
"$input_slug-$depth-${width}x${height}-$modulus.png" | |
echo | |
} | |
# Call the above function 100 times, passing 0 to 99 | |
# (Conveniently, 0 and 100 have identical outputs, so loop will be seamless) | |
modulus_start=0 | |
modulus_end=99 | |
for i in $(seq $modulus_start $modulus_end); do | |
convert_with_modulus $i | |
done | |
# I have another script that compiles all the PNGs generated in ^ | |
# and spits out a bunch of GIFs at different compressions and an MP4, but the | |
# crux of it is really a call to imagemagick's convert (25 is the framerate): | |
convert "*.png" -set delay "1x25" "track_9-RARE_NFT-poor_image-25.gif" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment