Skip to content

Instantly share code, notes, and snippets.

@fand fand/cpusound.js
Created Jun 4, 2014

Embed
What would you like to do?
CPUSOUND
var spawn = require('child_process').spawn;
var top = spawn('top', ['-b', '-d', '1']);
var buf = '';
top.stdout.on('data', function(data){
buf = data.toString();
});
var baudio = require('baudio');
var b = baudio(function (t, i) {
var idx = i * (i >> 11);
return t * buf[idx % buf.length] % 0xFF;
});
b.play();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.