Lookout analyzer that generates sound from PRs.
The analyzer part uses bblfsh to extract the UAST nodes from old and new code separating the nodes in deleted and added. It gets the type of node, token (name), size (characters) and hash (used for comparing).
Sound generation is compatible with any midi synthesizer which exposes midi device. Currently the data sent is:
- Note
- Duration (sustain time in seconds)
Two note sequences are generated per file, one for deleted and another one for added:
- file 1
- deleted sequence
- added sequence
- file 2
- deleted sequence
- added sequence
- ...
Note generation is done using Markov chains. The idea was taken from a hackernoon post and even two of its midi files borrowed to generate the two chains used in the project:
song1.midi
: Yiruma - River Flows in Yousong2.midi
: Chopin’s Concerto №1 in E Minor (Op. 11)
The midi files are not used as is but converted first to JSON so they are easier to read in the project. This web application was used to convert them.
Even if it's not really noticeable delete sequences use song1.midi
Markov chain and added use song2.midi
. To pick one of the weighted notes we use the FNV hash of the token (name).
Duration is a direct conversion from the node size with a maximum of 250 milliseconds.
Here's the information on how to configure midi synthesizer and the development environment. The project as is cannot be used to send data to github as the sound is played where synthesizer is running.
docker run -d --name bblfshd --privileged -p 9432:9432 -v /var/lib/bblfshd:/var/lib/bblfshd bblfsh/bblfshd:latest
apt-get install libportmidi-dev
# or
brew install portmidi
-
Midi synthesizer
- for macOS we recommend SimpleSynth
There's a sound test with hardcoded data that can be run with:
go run cmd/test/main.go
Start analyzer:
go run cmd/sonic/main.go
Analyze a change (last commit of a repo)
- Go to a directory with the commit we want to analyze
git checkout
to the specific dir in case we are not in it- Execute lookout-sdk executable:
$PATH_TO_LOOKOUT_SDK_BINARY/lookout-sdk review ipv4://localhost:2001
- Maxim Sukharev
- Javi Fontán
This project is licensed under the MIT License - see the LICENSE.md file for details
- Kuba Podgórski - project idea
- Alvin Lin - post about Markov chains and music