Skip to content

Instantly share code, notes, and snippets.

View celber's full-sized avatar

Dariusz Damian Jakubowski celber

View GitHub Profile

Keybase proof

I hereby claim:

  • I am celber on github.
  • I am celber (https://keybase.io/celber) on keybase.
  • I have a public key ASCzVhk6wHLZtLkDDhXT_eUPKAdqzSrAMe0I0wiUQeePhQo

To claim this, I am signing this object:

#!/bin/bash
# network
declare hostname
declare net_usage # todo
# hardware
declare ram_usage
declare swap_usage
declare cpu_usage
declare cpu_temp # todo
@celber
celber / synth.js
Created November 23, 2012 10:39
Wylicza fale do wav, pzoniejs ie przyda
var wav = [],
c = "g05_e05_e05_f05_d05_d05_c05_e05_g05_g05_e05_e05_f05_d05_d05_c05_e05_c05".replace(/c/g, "00").replace(/d/g, "02").replace(/e/g, "04").replace(/f/g, "06").replace(/g/g, "08").replace(/a/g, "10").replace(/h/g, "12").replace(/C/g, "01").replace(/D/g, "03").replace(/E/g, "05").replace(/F/g, "07").replace(/G/g, "09").replace(/A/g, "11").replace(/H/g, "13").split("_");
const bitrate = ~~16000, f = [262, 294, 330, 350, 392, 440, 494, 523, 555]; //ostatni element tablicy jest potrzebny do wyliczenia H;
synth = function(n, o) {
var sound = (n % 1 ? ~~ ((f[parseInt(n - 1)] - f[parseInt(n + 1)]) / 2) : f[parseInt(n)]) * (o + 1),
herz = [];
for (var i = 0; i < bitrate && (buf = ~~ (((c = Math.sin(((i < ~~ (bitrate / 2) ? (1 / bitrate) : (-1 / bitrate)) * i) * sound) / 2) < 0 ? -c : c += .5) * 65535)); ++i) {
for (var a = 4 - (byte = (buf).toString(16)).length; a > 1; --a) {
byte = "0" + byte
}