{"id":5171,"date":"2020-02-15T17:57:34","date_gmt":"2020-02-15T15:57:34","guid":{"rendered":"https:\/\/unitycoder.com\/blog\/?p=5171"},"modified":"2020-03-24T13:28:27","modified_gmt":"2020-03-24T11:28:27","slug":"encode-decode-audio-to-from-png-alpha-channel","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2020\/02\/15\/encode-decode-audio-to-from-png-alpha-channel\/","title":{"rendered":"Encode\/Decode Audio To\/From PNG Alpha Channel"},"content":{"rendered":"\n<p>Small test on embedding Audio data into PNG alpha channel.<br>With added option to shuffle pixels to hide\/&#8221;encrypt&#8221; original image and sound.<br><br>To make sound file small enough, use <a href=\"https:\/\/unitycoder.com\/blog\/2020\/02\/13\/use-audioimporter-sample-rate-lower-than-8000hz\/\">this option to set low hz<\/a>.<br><br><strong>Ideas for later:<\/strong><br>&#8211; Compress audio (tested RLE but didn&#8217;t do much with audio)<br>&#8211; Use full texture size automatically (currently just fills as long as have data)<br>&#8211; Resample audio in script, instead setting sample rate in audio importer<br>&#8211; Option to encode seed and\/or hz value into texture<\/p>\n\n\n\n<p><strong>Sources:<\/strong> (take both scripts)<br><a href=\"https:\/\/gist.github.com\/unitycoder\/6fece768157c038fb4c28d4b59931625\">https:\/\/gist.github.com\/unitycoder\/6fece768157c038fb4c28d4b59931625<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"5173\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2020\/02\/15\/encode-decode-audio-to-from-png-alpha-channel\/rickroll512\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512.png?fit=512%2C512&amp;ssl=1\" data-orig-size=\"512,512\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"rickroll512\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512.png?fit=512%2C512&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512.png?resize=578%2C578&#038;ssl=1\" alt=\"\" class=\"wp-image-5173\" width=\"578\" height=\"578\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512.png?w=512&amp;ssl=1 512w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512.png?resize=150%2C150&amp;ssl=1 150w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512.png?resize=300%2C300&amp;ssl=1 300w\" sizes=\"auto, (max-width: 578px) 100vw, 578px\" \/><figcaption>full mp3 (at 1000hz quality) embedded into 512&#215;512 PNG Alpha channel<br>(note the alpha channel values starting from bottom)<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"5174\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2020\/02\/15\/encode-decode-audio-to-from-png-alpha-channel\/rickroll512-1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512-1.png?fit=512%2C512&amp;ssl=1\" data-orig-size=\"512,512\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"rickroll512-1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512-1.png?fit=512%2C512&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512-1.png?resize=580%2C580&#038;ssl=1\" alt=\"\" class=\"wp-image-5174\" width=\"580\" height=\"580\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512-1.png?w=512&amp;ssl=1 512w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512-1.png?resize=150%2C150&amp;ssl=1 150w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512-1.png?resize=300%2C300&amp;ssl=1 300w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><figcaption>Same image and mp3 as above, but Shuffle pixels is enabled<br>(seed=123 and samplerate=1000  if you want to decode)<\/figcaption><\/figure>\n\n\n\n<p>Example results<\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/FnK4qPvK43s?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Small test on embedding Audio data into PNG alpha channel.With added option to shuffle pixels to hide\/&#8221;encrypt&#8221; original image and sound. To make sound file small enough, use this option to set low hz. Ideas for later:&#8211; Compress audio (tested RLE but didn&#8217;t do much [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5173,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[804],"tags":[338,1144,890,1152,1151,1154,1153,1155],"class_list":["post-5171","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripts","tag-alpha","tag-audio","tag-decode","tag-embed","tag-encode","tag-hide","tag-png","tag-steganography"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2020\/02\/rickroll512.png?fit=512%2C512&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-1lp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/5171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=5171"}],"version-history":[{"count":3,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/5171\/revisions"}],"predecessor-version":[{"id":5232,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/5171\/revisions\/5232"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/5173"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=5171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=5171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=5171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}