Friday, March 4, 2016

NumPy to Ruby

Depending how much digging you have done into the Mutable Instruments code you may have come across the /resources directory. This is where Oliver keeps a lot of the information that is generated at Compile Time. He uses an interesting Python package called NumPy which is a sort of concatenation of Numerical Python. It seems quite popular and well supported and allows some very powerful scripting. It is used to generate a lot of things in Briads where the processing overhead of doing all the complex mathematics is pushed into a LUT (lookup table). There are various transfer functions for waveshaping, sinewave generation, filter transfer coefficients etc. Not being a massive fan of Python (despite the cool name) and being more a Ruby aficionado I have brutalized the method of generating the tables into a more (well for my understanding and approach) modular scheme. This integrates well into the Keil IDE and allows all the parameters and behavior of a certain module to be captured into one file. As a simple example I have included the Sinewave generation. The script is run before the file is compiled and generates the include file, m_sine_table.h. The IDE does this automatically for me, which is some extra build time but in most cases is just fractions of a second. I find it easier to keep it all together, especially when your still trying to get your head around all the cleverness that Oliver has done!


No comments: