Techno generation based on server logs

Hasan Tayyar Beşik
2 min readMay 28, 2021

I started a project which will generate techno melodies by feeding the Sonic Pi with server access logs. It is a customised script for now.

To obfuscate the logs as much as possible I redacted the realtime log stream. The result was… listenable techno. I chose techno because it has the the potential of having something listenable (trying not to say it has the most clear and simple structure). I used this repo as a bootstrap https://github.com/mehackit/technomachine

How to pipe logs into Sonic Pi

I used a tiny Python script to get the logs as piped through the my shell.

tail access-log.log | python3 send.py# or realtime k8s logskubectl logs -f <my-backend> | python3 send.py

The script scrambles the log, removes some known private information (privacy reasons just in case) and runs some small logic cases like the frequency of the logs (logs per second) and number of certain phrases in the log. Every log line is processed. The script script sends a command to Sonic Pi after every log process. The communication happens via UDP. Sonic Pi listens packages via a specific command. The port can be different in your Sonic Pi installation. Mine is “4560". The script turns down the specified loops after some time as a final to the output to avoid sudden end.

A small part of the send.py script

from pythonosc import osc_message_builder
from pythonosc import udp_client
import sys
client = udp_client.SimpleUDPClient('127.0.0.1', 4560)# gets the piped data line by line
for line in sys.stdin:
print('new log line')
# ..... log processing
client.send_message('/notes', ["a1", "c7", "b1", "d2", "c2", "g2", "e1", "a6"])
# ... log processing
client.send_message('/waveform', ["saw""])

Sample

animation is from: https://30000fps.tumblr.com/

First Sample of the Project

Next Steps

BPM

The most important thing I could not configure so far was the BPM based on the logs.

Sonic Pi threads (live_loops) uses the global bpm and when I try to re set the BPM for every live_loop I got very complex errors.

Samples

I will try to add some samples to spicy up the output. The samples will be triggered with a custom rule set so the the generator will be configurable based on the format and the type of the log.

Open Source it

This step will require some work because I just started learning Sonic Pi and my code is a mess with lots of in-code documentation and notes for myself.

--

--

Hasan Tayyar Beşik

GCloud, AWS, Security, NodeJs, Berlin — This blog is mostly technical and multilingual. Be aware of possible and multiple typos!