Skip to main content

Convert Python code into music to hear algorithms

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stochastis-1.0.2.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file stochastis-1.0.2.tar.gz.

File metadata

  • Download URL: stochastis-1.0.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for stochastis-1.0.2.tar.gz
Algorithm Hash digest
SHA256 360858792c7fbd54932f4a2d04fcc452a0cd9894240abaf2b331f561250e4ff7
MD5 ad2cbc03730d5e5f226c7c4a579057ae
BLAKE2b-256 3341a08c140dba524a8520ae769fd84feaefe65d3bed46e067121c8638382c2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page