{"id":104,"date":"2015-01-10T15:48:08","date_gmt":"2015-01-10T15:48:08","guid":{"rendered":"http:\/\/weegreenblobbie.com\/?p=104"},"modified":"2015-03-08T18:30:05","modified_gmt":"2015-03-08T18:30:05","slug":"nsound-circular-iterators","status":"publish","type":"post","link":"http:\/\/weegreenblobbie.com\/?p=104","title":{"rendered":"Nsound Circular Iterators"},"content":{"rendered":"<p>On the Nsound development <a title=\"branch\" href=\"http:\/\/sourceforge.net\/p\/nsound\/code\/HEAD\/tree\/branch\/nsound-dev-weegreenblobbie\/\">branch<\/a>, I&#8217;ve exposed the C++ circular iterators for the Buffer class to the Python module.\u00a0 This code will eventually get released as part of Nsound-0.9.3.<\/p>\n<p>Here&#8217;s how one might use them:<\/p>\n<pre class=\"lang:python decode:true\">import Nsound as ns\r\n\r\nb = ns.Buffer()\r\n\r\nb &lt;&lt; 1 &lt;&lt; 2 &lt;&lt; 3\r\n\r\nc = b.cbegin()\r\n\r\nfor i in xrange(10):\r\n    print float(c)\r\n    c += 1\r\n<\/pre>\n<p>Which will produce the this output:<\/p>\n<pre class=\"lang:default decode:true\">1.0\r\n2.0\r\n3.0\r\n1.0\r\n2.0\r\n3.0\r\n1.0\r\n2.0\r\n3.0\r\n1.0\r\n<\/pre>\n<p>&nbsp;<br \/>\nThe function <code>cbegin()<\/code> returns a <code>Buffer::circular_iterator<\/code> object that can be dereferenced using the Python builtin <code>float()<\/code>.  The iterator can be incremented using the <code>+=<\/code> operator.  Once the iterator goes off the end of the Buffer, it wraps around back to the beginning again, circular.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On the Nsound development branch, I&#8217;ve exposed the C++ circular iterators for the Buffer class to the Python module.\u00a0 This code will eventually get released as part of Nsound-0.9.3. Here&#8217;s how one might use them: import Nsound as ns b &hellip; <a href=\"http:\/\/weegreenblobbie.com\/?p=104\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-nsound"],"_links":{"self":[{"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=104"}],"version-history":[{"count":5,"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":109,"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=\/wp\/v2\/posts\/104\/revisions\/109"}],"wp:attachment":[{"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/weegreenblobbie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}