clean-up: #39

since long i had this idea of sonifying what my laptop is doing. before, when laptops had spinning harddrives, one could at least hear the faint little noises when there was disk activity. but today with the sd disks, this insight is gone.

below is a draft of how it could work. it tracks activity in the system.log file. to try it start supercollider and run the code. then launch some apps, save files, disconnect network etc etc. it's quite fun to have it running in the background for a while.

one day i plan to do a more thorough sonification, tracking many more things. here is a good reference for what to tap into in the future.

sudo iosnoop
sudo execsnoop -v
sudo opensnoop -ve
sudo dtruss -n SuperCollider
sudo errinfo -c
sudo iotop -CP 1
man -k dtrace

//osx only
s.latency= 0.05;
var num= 10;
var delta= 0.1;
var maxlen= 256;
var rate= 0.5;
var curr=;
var mySplit= {|str|
        var res= "";
        var arr= [];
        var separator=;
        var tab=;{|chr, i|
                if(chr.ascii!=separator or:{str.clipAt(i+1).ascii==tab}, {
                        res= res++chr;
                }, {
                        arr= arr.add(res);
                        res= "";
var read= Routine({
        var res, arr, last, new;{
                res= ("tail -n"+num+"/var/log/system.log").unixCmdGetStdOut;
                if(res!=last, {
                        last= res;
                        arr= mySplit.value(res);
                        new={|x| curr.indexOfEqual(x).isNil};
                delta.wait;     //time between checking system log
var play= Routine({
        var data;{
                if(curr.size>0, {
                        data= curr.pop;
                        ("buf"++curr.size++": ").post;
                                Synth(\log, [\data, data.ascii.extend(maxlen, 0)]);
                }, {
SynthDef(\log, {|out= 0, amp= 0.5, minFreq= 300, maxFreq= 14400|
        var data= Control.names([\data]).ir(Array.fill(maxlen, 0));
        var freq=*rate, 0, Dseq(data), 2);
        var src=, 255, minFreq, maxFreq), 0, (freq>0).lag(0.02));,, 0, amp));