Stochastis
Convert Python code into music to hear algorithms
About
Pronounced "stoʊ-kæst-ɪs" ("stow" + "cast" + "is" like "miss"), Stochastis was a small experiment in figuring out if it would be possible to hear what a given algorithm sounds like. However, the goal was accomplished in a much more general fashion. Instead of only algorithms, Stochastis converts each function in a Python module to its corresponding bytecode which it then converts to MIDI notes along a predefined scale. It then generates a MIDI file from them or plays them upon generation.
Installation
$ pip install stochastis
$ pip install git+https://github.com/Pebaz/stochastis
Usage
$ stochastis foo.mid # Play from file
$ stochastis some_file.py # Generate and play from file
$ stochastis some_file.py --out foo.mid # Generate only
Conclusion
What was accomplished in this experiment is just a small inkling of the amount of potential this has for pleasing music being generated from a given codebase.
Some ideas for extensions include:
- Identifying patterns in bytecode to produce familiar stanzas
- Performing analysis on the bytecode of functions to identify patterns so that pre-built sequences of notes can be grafted into the output
- Clearer rules for what is generated based on what is actually written in Python code
- Integration with better sounding synthesizers
- Layered tracks with multiple intstruments playing at once (drums, etc.)
- Converting program control flow into sections of a given song
Metadata
Release files for stochastis 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stochastis-1.0.2.tar.gz | 3.1 kB | Details |
Release files / stochastis-1.0.2.tar.gz
| Download URL | stochastis-1.0.2.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
360858792c7fbd54932f4a2d04fcc452a0cd9894240abaf2b331f561250e4ff7
|
|
BLAKE2b-256 checksum How to use checksums |
3341a08c140dba524a8520ae769fd84feaefe65d3bed46e067121c8638382c2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.25.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|