Feb
15
2020

Encode/Decode Audio To/From PNG Alpha Channel

Small test on embedding Audio data into PNG alpha channel.
With added option to shuffle pixels to hide/”encrypt” original image and sound.

To make sound file small enough, use this option to set low hz.

Ideas for later:
– Compress audio (tested RLE but didn’t do much with audio)
– Use full texture size automatically (currently just fills as long as have data)
– Resample audio in script, instead setting sample rate in audio importer
– Option to encode seed and/or hz value into texture

Sources: (take both scripts)
https://gist.github.com/unitycoder/6fece768157c038fb4c28d4b59931625

full mp3 (at 1000hz quality) embedded into 512×512 PNG Alpha channel
(note the alpha channel values starting from bottom)
Same image and mp3 as above, but Shuffle pixels is enabled
(seed=123 and samplerate=1000 if you want to decode)

Example results


2 Comments + Add Comment

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Youtube Join Discord Twitch Instagram

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.