Python: How to make it do pretty things.
See controllerism for Human-centric interaction design..
Pro-tip: run your python code as a web service
Web services are the new reliable lingua franca, and have a lot of development time sunk into them, so even if you, as I do, hate the web, you may as well steal their labour.
Python + tornado + ProcessPoolExecutor is reasonably performant.
You will probably need FRP to make it interactive in this case.
Look! the heady mix of excellent realtime and non-real-time performance in a semi-pro interactive IDE! Get amongst it. I wrote some tips for Jupyter GUIS elsewhere
I will use this to prototype amazing music using python machine listening, I hope. But GUIs are my least favourite thing, so it will be slow going even on this easy terrain.
DIY, bareback style. Tedious, but do-able. The best example I know is paulstretch, which creates a lovely phase vocoder from nothing reasonably compactly. For real-time things though, this will get tedious.
Resampling: not quite trivial. Here is a comparison of options. Summary:
pyo (github) is a python audio processing framework by Olivier Bélanger. Intermittently updated. Supports python 2.7 and 3.5. Distributed through weird OS-specific installer packages which want to invade your system python installation, which is inconvenient. This is probably because it wants to run a WXPython gui, which is its won kind of inconvenience, if you want some other GUI.
It claims to be
a Python module written in C to help DSP script creation. Pyo contains classes for a wide variety of audio signal processing. With pyo, the user will be able to include signal processing chains directly in Python scripts or projects, and to manipulate them in real time through the interpreter. Tools in the pyo module offer primitives, like mathematical operations on audio signals, basic signal processing (filters, delays, synthesis generators, etc.), but also complex algorithms to create sound granulation and other creative audio manipulations. pyo supports the OSC protocol (Open Sound Control) to ease communications between softwares, and the MIDI protocol for generating sound events and controlling process parameters. pyo allows the creation of sophisticated signal processing chains with all the benefits of a mature, and widely used, general programming language.:
Here is an example
>>> s = Server().boot() >>> s.start() >>> wav = SquareTable() >>> env = CosTable([(0,0), (100,1), (500,.3), (8191,0)]) >>> met = Metro(.125, 12).play() >>> amp = TrigEnv(met, table=env, dur=1, mul=.1) >>> pit = TrigXnoiseMidi( met, dist='loopseg', x1=20, scale=1, mrange=(48,84) ) >>> out = Osc(table=wav, freq=pit, mul=amp).out()
See also cecilia, a gui for pyo.
audiolazy, by Danilo de Jesus da Silva Bellini, looks great for technical audio analysis and synthesis, although a bit clunky for, you know, synths. Intermittently updated.
Prioritizing code expressiveness, clarity and simplicity, without precluding the lazy evaluation, and aiming to be used together with Numpy, Scipy and Matplotlib as well as default Python structures like lists and generators, AudioLazy is a package written in pure Python proposing digital audio signal processing (DSP), featuring:
- A Stream class for finite and endless signals representation with elementwise operators (auto-broadcast with non-iterables) in a common Python iterable container accepting heterogeneous data;
- Strongly sample-based representation (Stream class) with easy conversion to block representation using the Stream.blocks(size, hop) method;
- Sample-based interactive processing with ControlStream;
- Streamix mixer for iterables given their starting time deltas;
- Multi-thread audio I/O integration with PyAudio;
- Linear filtering with Z-transform filters directly as equations (e.g. filt = 1 / (1 - .3 * z ** -1)), including linear time variant filters (i.e., the a in a * z ** k can be a Stream instance), cascade filters (behaves as a list of filters), resonators, etc.. Each LinearFilter instance is compiled just in time when called;
- Zeros and poles plots and frequency response plotting integration with MatPlotLib;
- Linear Predictive Coding (LPC) directly to ZFilter instances, from which you can find PARCOR coeffs and LSFs;
- Both sample-based (e.g., zero-cross rate, envelope, moving average, clipping, unwrapping) and block-based (e.g., window functions, DFT, autocorrelation, lag matrix) analysis and processing tools;
- A simple synthesizer (Table lookup, Karplus-Strong) with processing tools (Linear ADSR envelope, fade in/out, fixed duration line stream) and basic wave data generation (sinusoid, white noise, impulse);
- Biological auditory periphery modeling (ERB and gammatone filter models);
- Multiple implementation organization as StrategyDict instances: callable dictionaries that allows the same name to have several different implementations (e.g. erb, gammatone, lowpass, resonator, lpc, window);
- Converters among MIDI pitch numbers, strings like “F#4” and frequencies;
I can’t tell the difference between pydub and amen, both of which seem to be designed to mainly edit audio files with precise slicing and crossfades, but not to do much like effects or synthesis. Handy for algorithmic remix.
Surprisingly, GNURadio supports extensive DSP for python using a high-performance compiled dataflow graph, kind of like a realtime Tensorflow.
python’s audio analysis toolkit is much more impressive than its synthesis - see machine listening.
colormotor_sandbox, live-reloading CV+video framework:
Colormotor is a creative coding framework with a “scientific twist”. The framework builds on top of Armadillo for linear algebra operations, OpenCV for image manipulation and OpenGL for hardware accellerated rendering.
Armadillo is definitely not the fastest or most lightweight solution for a graphics-oriented framework. On the other hand, the library provides many utilities that make it easy to switch between C++, Python and Matlab, and vectorised operations result in much more concise code.
Colormotor includes Python bindings that can be used independently as a module, or within the Colormotor Sandbox live coding environment.
an open-source software project initiated by OpenEndedGroup, for the creation of their digital artworks. It is an environment for writing code to rapidly and experimentally assemble and explore algorithmic systems. It is visual, it is hybrid, it is code-based. We think that it has something to offer a diverse range of programmers and artists.
It seems to be rarely updated (2 years old at time of writing) and based on Jython/JVM so you can’t use cpython conveniences like numpy.
slider1= sheetSlider("slider1") xySlider2 = sheetXY("xySlider2") aGraph = sheetGraph("aGraph") print slider1.get() print xySlider2.get() print aGraph.get().get(0.2) slider1.set(0.5) xySlider2.set( (0.2, 0.6))
GUI toolkit looks good (Java-based). OpenGL and other drawing functionality seem advanced. Audio does not seem to be a priority.
the graphing can be OK too — see graphing in python.
|||Nothing wrong with going to seed; It’s perfectly lovely software, just a bit overgrown, and it has lost that fresh tang.|