{"id":2556,"date":"2015-12-29T11:22:29","date_gmt":"2015-12-29T11:22:29","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=2556"},"modified":"2017-06-08T12:02:43","modified_gmt":"2017-06-08T12:02:43","slug":"phpaudio-audio-file-processing-in-pure-php","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2015\/12\/29\/phpaudio-audio-file-processing-in-pure-php\/","title":{"rendered":"PHPAudio &#8211; Audio file processing in pure PHP"},"content":{"rendered":"<h3>OVERVIEW<\/h3>\n<p>There currently exists no PHP library or code to work with audio file formats. The general solution is to use external libraries or softwares like ffmpeg, sox etc , by calling them with parameters and then capturing their output.<\/p>\n<p>PHPAudio is an attempt to process audio files in pure PHP code without using any external dependencies. This is going to take at least a few months as audio processing is a very big field. For starters, I am going to focus on WAV and MP3 formats as they are the most commonly used and then move on to other formats like Ogg, AU, AIFF etc.<\/p>\n<p>As the library progresses, the download link and documentation will be constantly updated. Any queries, questions or suggestions are very welcome.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>DOCUMENTATION<\/h3>\n<p><strong>WAV files<\/strong><\/p>\n<p>The following types of WAV files are handled:<\/p>\n<ul>\n<li>Uncompressed PCM format<\/li>\n<li>IEEE Floating Point<\/li>\n<li>ALaw encoded<\/li>\n<li>muLaw encoded<\/li>\n<\/ul>\n<p>1.Parse a WAV file and get information about it<\/p>\n<p>Usage:<\/p>\n<pre>require_once(\"clsWAV.php\");\r\n$wav = new \\phpaudio\\WAV('\/path to your wave file.wav');\r\nif ($wav-&gt;getError() != null &amp;&amp; $wav-&gt;getError() != \"\") \r\n   echo($wav-&gt;getError() . \"\\n\");\r\nelse \r\n   var_dump($wav-&gt;getHeaderData());\r\n<\/pre>\n<p>The WaveHeader class gets filled up with all the information about the WAV file. Among other things, it provides information about:<\/p>\n<ul>\n<li>WAV format type<\/li>\n<li>No.of Channels<\/li>\n<li>Sample Rate<\/li>\n<li>Byte Rate<\/li>\n<li>Bits per Sample<\/li>\n<li>No.of Samples<\/li>\n<li>Size of Each Sample<\/li>\n<li>Duration in Seconds or in HH:MM:SS format<\/li>\n<li>Bytes in Each Channel<\/li>\n<\/ul>\n<p>Check the comments in clsWAV.php for more details.<\/p>\n<p>&nbsp;<\/p>\n<h3>DOWNLOADS<\/h3>\n<p><a href=\"http:\/\/truelogic.org\/php-audio.zip\" target=\"_blank\">Download Version 1.0 (7.2 Kb) Last Updated 29 Dec 2015<\/a><\/p>\n<p>GitHub Repository: <a href=\"https:\/\/github.com\/amitonline\/phpaudio\/tree\/master\/wav\" target=\"_blank\">https:\/\/github.com\/amitonline\/phpaudio\/tree\/master\/wav<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW There currently exists no PHP library or code to work with audio file formats. The general solution is to use external libraries or softwares <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2015\/12\/29\/phpaudio-audio-file-processing-in-pure-php\/\" title=\"PHPAudio &#8211; Audio file processing in pure PHP\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":2560,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,301],"tags":[],"class_list":["post-2556","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apachephp","category-audio"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2556","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=2556"}],"version-history":[{"count":4,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2556\/revisions"}],"predecessor-version":[{"id":2561,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2556\/revisions\/2561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/2560"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=2556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=2556"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=2556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}