<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hello Bill, Everyone
<div class=""><br class="">
</div>
<div class="">Have found myself having to use python a lot lately and have not been too happy with choice of sound libs I started making bindings for sndlib&nbsp;<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><a href="https://github.com/testcase/pysndlib" class="">https://github.com/testcase/pysndlib</a></span></div>
<div class=""><br class="">
</div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">There is a lot more to do but just wanted to mention this in case anyone else is working on the same thing or may want to hack this or make recommendations, etc</span></div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class="">
</span></div>
<div class=""><br class="">
</div>
<div class="">I used&nbsp;ctypesgen (<a href="https://github.com/ctypesgen/ctypesgen" class="">https://github.com/ctypesgen/ctypesgen</a>) to generate bindings from header files and then have been coding wrapper functions.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">I used ctypes for the ffi and also want it to work nicely with numpy. Really want to keep this as simple as possible.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">I also focused on trying to be as literal as possible with translation so that it would be easy to port existing examples. This may mean something aren’t pythonic.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">It is not exactly fast but was not expecting it to be using python/&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">Want to also be able to use this in juypter notebooks for teaching sound synthesis next year&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">Many rough edges and things to be documented. Error handling in non-existent but feel like I at least have some working examples. There is an examples.py file with some simple things just ported from the the simple examples in the docs. Hope to
 address much of this in coming month or so.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">Of course all thanks to Bill for everything . This is really just simple translation of everything you have done. Would be happy to see this folded into main project or &nbsp;keep is separate for easier maintenance. Whatever is best&nbsp;</div>
<div class=""><br class="">
</div>
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">To give a sense here is an example with jc-reverb and some simple instrument.&nbsp;</span></div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">def jc_reverb(lowpass=False, volume=1., amp_env = None):</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>allpass1 = make_all_pass(-.7, .7, 1051)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>allpass2 = make_all_pass(-.7, .7, 337)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>allpass3 = make_all_pass(-.7, .7, 113)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>comb1 = make_comb(.742, 4799)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>comb2 = make_comb(.733, 4999)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>comb3 = make_comb(.715, 5399)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>comb4 = make_comb(.697, 5801)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>chans = Sound.output.mus_channels</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>length = Sound.reverb.mus_length</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>filts = [make_delay(seconds2samples(.013))] if chans == 1 else [make_delay(seconds2samples(.013)),make_delay(seconds2samples(.011)) ]</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>combs = make_comb_bank([comb1, comb2, comb3, comb4])</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>allpasses = make_all_pass_bank([allpass1,allpass2,allpass3])</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>if lowpass or amp_env:</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>flt = make_fir_filter(3, [.25, .5, .25]) if lowpass else None</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>envA = make_env(amp_env, scaler=volume, duration = length / mus_srate())</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>if lowpass:</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>for i in range(length):</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>out_bank(filts, i, (env(envA) * fir_filter(flt, comb_bank(combs, all_pass(allpasses, ina(i, Sound.reverb))))))</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>else:</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>for i in range(length):</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>out_bank(filts, i, (env(envA) * comb_bank(combs, all_pass_bank(allpasses, ina(i, Sound.reverb)))))</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>else:</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>if chans == 1:</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>gen = filts[0]</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>for i in range(length):</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>outa(i, delay(gen), volume * comb_bank(combs, all_pass_bank(allpasses, ina(i, Sound.reverb))))</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>else:<span class="Apple-tab-span" style="white-space:pre">
</span></div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>gen1 = filts[0]</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>gen2 = filts[1]</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>for i in range(length):</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>val = volume * comb_bank(combs, all_pass_bank(allpasses, ina(i, Sound.reverb)))&nbsp;</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>outa(i, delay(gen1, val))</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>outb(i, delay(gen2, val))</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">def blip(beg, dur, freq):</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>start = seconds2samples(beg)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>end = seconds2samples(dur) + start</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>loc = make_locsig(degree=random.randrange(-90, 90), distance=1., reverb=.7)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>cmb = make_comb(0.4, seconds2samples(0.4))</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>osc = make_oscil(freq)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>ampf = make_env([0.0, 0.0, 1.0, 1.0, 2.0, 1.0, 3.0, 0.0], length=4410)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>for i in range(start, end):</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>locsig(loc, i, 0.5 * (comb(cmb, env(ampf) * oscil(osc))))</div>
<div class=""><br class="">
</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div class="">with Sound(&quot;out1.aif&quot;, 2, reverb=jc_reverb, reverb_channels=2, play=True):<span class="Apple-tab-span" style="white-space:pre">
</span></div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>blip(0, 2, 100)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>blip(1, 2, 400)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>blip(2, 2, 200)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>blip(3, 2, 300)</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>blip(4, 2, 500)</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="Apple-interchange-newline">
<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Todd
 Ingalls</span><br style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Associate
 Director</span><br style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">School
 of Arts, Media and Engineering</span><br class="">
</div>
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""><a href="http://ame.asu.edu" class="">ame.asu.edu</a></span></div>
</div>
</div>
<br class="">
</div>
</body>
</html>