Refactoring musicalization code into Django-independent module