{"id":343,"date":"2015-06-30T21:40:33","date_gmt":"2015-06-30T20:40:33","guid":{"rendered":"http:\/\/atwrk.phae.eu\/?p=343"},"modified":"2015-08-17T14:18:07","modified_gmt":"2015-08-17T13:18:07","slug":"python-wave","status":"publish","type":"post","link":"https:\/\/atwrk.phae.eu\/?p=343","title":{"rendered":"python wave"},"content":{"rendered":"<p>bases en python &gt;&gt;&gt; <a href=\"http:\/\/www.flossmanualsfr.net\/initiation-a-python\/\">FLOSS Manual : Initiation \u00e0 Python &gt;&gt;&gt; http:\/\/www.flossmanualsfr.net\/initiation-a-python\/<\/a><\/p>\n<p>la librairie \u00ab\u00a0wave\u00a0\u00bb assez simple d&rsquo;utilisation : <a href=\"https:\/\/docs.python.org\/2\/library\/wave.html\">https:\/\/docs.python.org\/2\/library\/wave.html<\/a><br \/>\n<code><\/code><\/p>\n<p>premier tests sous python :<\/p>\n<pre class=\"lang:python decode:true \"># -*- coding:utf-8 -*-\r\n\r\nimport wave, struct\r\n\r\nsndfile = wave.open(\"Lusitania.wav\",  'r')\r\nprint sndfile.getparams()\r\nsndfile.setpos(48200)\r\nframes = sndfile.readframes(12)\r\nprint(len(frames))\r\n\r\ni = 0\r\nwhile i &lt; len(frames):\r\n        oneframe = frames[i:i+2]\r\n        print(len(oneframe))\r\n        data = struct.unpack(\"&lt;h\", oneframe)\r\n        print(data)\r\n        i+= 2\r\n\r\nsndfile.close()\r\n<\/pre>\n<p>\u00e9galement la librairie externe <strong>PyMedia<\/strong> (<a href=\"http:\/\/www.pymedia.org\">http:\/\/www.pymedia.org<\/a>) qui permet de lire directement un CD Audio<\/p>\n<p>\u00e0 noter les sp\u00e9cificit\u00e9s du CD Audio (voir notamment <a href=\"https:\/\/en.wikipedia.org\/wiki\/Compact_Disc_Digital_Audio#Frames_and_timecode_frames\">https:\/\/en.wikipedia.org\/wiki\/Compact_Disc_Digital_Audio#Frames_and_timecode_frames<\/a>) : il semblerait que, au moins dans la TOC (Table Of Content) les dur\u00e9es et positions soient inscrites en \u00ab\u00a0frames\u00a0\u00bb de 588 paire d&rsquo;\u00e9chantillons (gauche et droite) soit 1\/75e de seconde (588 x 75 = 44100). Donc il s&rsquo;agit du \u00ab\u00a0grain\u00a0\u00bb, de l&rsquo;unit\u00e9 minimale de dur\u00e9e.<br \/>\n(\u00e0 v\u00e9rifier tout de m\u00eame avec un autre outil (par ex : rip puis pd [soundfiler] voir si on a des dur\u00e9es qui ne sont pas multiples de 588)<\/p>\n<p>\u00e9galement \u00e0 propos du format WAVE : un bon document &gt;&gt; <a href=\"http:\/\/web.archive.org\/web\/20080113195252\/http:\/\/www.borg.com\/~jglatt\/tech\/wave.htm\">http:\/\/web.archive.org\/web\/20080113195252\/http:\/\/www.borg.com\/~jglatt\/tech\/wave.htm<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>bases en python &gt;&gt;&gt; FLOSS Manual : Initiation \u00e0 Python &gt;&gt;&gt; http:\/\/www.flossmanualsfr.net\/initiation-a-python\/ la librairie \u00ab\u00a0wave\u00a0\u00bb assez simple d&rsquo;utilisation : https:\/\/docs.python.org\/2\/library\/wave.html premier tests sous python : # -*- coding:utf-8 -*- import wave, struct sndfile = wave.open(\u00ab\u00a0Lusitania.wav\u00a0\u00bb, &lsquo;r&rsquo;) print sndfile.getparams() sndfile.setpos(48200) frames = sndfile.readframes(12) print(len(frames)) i = 0 while i &lt; len(frames): oneframe = frames[i:i+2] print(len(oneframe)) data &hellip; <a href=\"https:\/\/atwrk.phae.eu\/?p=343\" class=\"more-link\">Continuer la lecture de <span class=\"screen-reader-text\">python wave<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[229,62,2,90],"tags":[59,230,119,86,231,104,42,232],"_links":{"self":[{"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/posts\/343"}],"collection":[{"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343"}],"version-history":[{"count":12,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions"}],"predecessor-version":[{"id":375,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions\/375"}],"wp:attachment":[{"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atwrk.phae.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}