Programming Real-Time Sound in Python
Yuri De Pra, Federico Fontana · Applied Sciences · 2020
For its versatility, Python has become one of the most popular programming languages. In spite of its possibility to straightforwardly link native code with powerful libraries for scientific computing, the use of Python for real-time sound applications development is often neglected in favor of alternative programming languages, which are tailored to the digital music domain. This article introduces Python as a real-time software programming tool to interested readers, including Python developers who are new to the real time or, conversely, sound programmers who have not yet taken this language into consideration. Cython and Numba are proposed as libraries supporting agile development of efficient software running at machine level. Moreover, it is shown that refactoring few critical parts of the program under these libraries can dramatically improve the performances of a sound algorithm. Such improvements can be directly benchmarked within Python, thanks to the existence of appropriate code parsing resources. After introducing a simple sound processing example, two algorithms that are known from the literature are coded to show how Python can be effectively employed to program sound software. Finally, issues of efficiency are mainly discussed in terms of latency of the resulting applications. Overall, such issues suggest that the use of real-time Python should be limited to the prototyping phase, where the benefits of language flexibility prevail on low latency requirements, for instance, needed during computer music live performances.
Cited by 6 works. doi:10.3390/app10124214 Open-access PDF
Authors
References
- Cython: The Best of Both Worlds
- librosa: Audio and Music Signal Analysis in Python
- Numba
- Pure Data : another integrated computer music environment
- Rethinking the Computer Music Language: SuperCollider
- Real-time CSound: Software Synthesis with Sensing and Control
- DAFX: Digital Audio Effects
- Real-time detection of musical onsets with linear prediction and sinusoidal modeling
- Trends in introductory programming courses in Australian universities: languages, environments and pedagogy
- Real-Time Guitar Amplifier Emulation with Deep Learning