Skip to content

Instantly share code, notes, and snippets.

@autotel
Created March 28, 2021 16:16
Show Gist options
  • Save autotel/720ca740654bd2196cd6f1e4b41724d3 to your computer and use it in GitHub Desktop.
Save autotel/720ca740654bd2196cd6f1e4b41724d3 to your computer and use it in GitHub Desktop.
touch "sounds.js";
echo "module.exports={" > sounds.js;
for f in ./*.mp3; do
echo "base64 \"$f\" > \"$f.b64\"";
base64 "$f" > "$f.b64"
echo " \"$f\":\`$(base64 "$f")\`," >> "sounds.js"
done
echo "}" >> "sounds.js"
@autotel
Copy link
Author

autotel commented Mar 28, 2021

convert a bunch of mp3 files into a js file that you could bundle in your js code. This has the effect of letting you bundle sounds into a single js file

Place it in the same folder where your mp3 files are and call it from console.

You can customize it to encode other types of too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment