{"id":285,"date":"2012-02-20T19:57:22","date_gmt":"2012-02-20T17:57:22","guid":{"rendered":"http:\/\/blog.ansuz.nl\/?p=285"},"modified":"2012-02-20T19:57:22","modified_gmt":"2012-02-20T17:57:22","slug":"sound-from-bytearray","status":"publish","type":"post","link":"http:\/\/blog.ansuz.nl\/index.php\/2012\/02\/20\/sound-from-bytearray\/","title":{"rendered":"Sound from ByteArray"},"content":{"rendered":"<p>While writing a quick test application to record microphone input and playing that same recording, I found out that playing back a ByteArray directly using the Sound class wasn&#8217;t possible. Luckily a solution is never far away when doing a Google search and it turns out that FlexibleFactory has a good solution: <a href=\"http:\/\/www.flexiblefactory.co.uk\/flexible\/?p=46\" target=\"_blank\">the MP3FileReferenceLoader lib<\/a>. With a bit of tweaking you can pass in a ByteArray directly and don&#8217;t need to rely on a FileReference.<\/p>\n<p>Good news though! As per Flash Player 11, the following 2 methods have been added to the (native) Sound class that can be used to achieve the same behaviour:<\/p>\n<ul>\n<li>Sound.loadCompressedDataFromByteArray(bytes:ByteArray, bytesLength:uint)<\/li>\n<li>Sound.loadPCMFromByteArray(bytes:ByteArray, samples:uint, format:String = &#8220;float&#8221;, stereo:Boolean = true, sampleRate:Number = 44100.0)<\/li>\n<\/ul>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>While writing a quick test application to record microphone input and playing that same recording, I found out that playing back a ByteArray directly using the Sound class wasn&#8217;t possible. Luckily a solution is never far away when doing a &hellip; <a href=\"http:\/\/blog.ansuz.nl\/index.php\/2012\/02\/20\/sound-from-bytearray\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,93,65],"tags":[105,103,104,102],"class_list":["post-285","post","type-post","status-publish","format-standard","hentry","category-actionscript-30","category-air","category-flex","tag-as3","tag-bytearray","tag-mp3","tag-sound"],"_links":{"self":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/comments?post=285"}],"version-history":[{"count":1,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/285\/revisions"}],"predecessor-version":[{"id":286,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/285\/revisions\/286"}],"wp:attachment":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/media?parent=285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/categories?post=285"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/tags?post=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}