Skip to content

Instantly share code, notes, and snippets.

@zgiles
Created November 23, 2015 03:43
Show Gist options
  • Select an option

  • Save zgiles/b95ad4e919448b454d50 to your computer and use it in GitHub Desktop.

Select an option

Save zgiles/b95ad4e919448b454d50 to your computer and use it in GitHub Desktop.
kicks
var lodash = require('lodash');
var noitech = require('noitech');
var SinWave = function(n,f) {
var f = f ? f : 440;
return lodash.map(lodash.range(n), function(n) { return Math.sin(f * (2 * Math.PI) * n / 44100); } );
}
var DiminishingSinWave = function(n, f, c) {
var f = f ? f : 440;
var c = c ? c: 2000.0;
return lodash.map(lodash.range(n), function(i) { return Math.sin(f * (2 * Math.PI) * i / 44100) * Math.pow(Math.E, (0-(i/c))); } );
}
var SumWaves = function(a,b,scale) {
return lodash.map(a, function(x, key) {
return (a[key] + b[key])/scale;
});
}
/// NICE ONE
/*
var w = DiminishingSineWave(10000,100);
var x = DiminishingSineWave(10000,50);
var q = SumWaves(w,x,2);
*/
/// NICE TWO
/// file kickflat30407540.wav
/*
var a = DiminishingSinWave(20000,30);
var b = DiminishingSinWave(20000,40);
var c = SumWaves(a,b,2);
var d = DiminishingSinWave(20000,75);
var e = DiminishingSinWave(20000,40);
var f = SumWaves(d,e,2);
var q = SumWaves(c,f,2);
*/
/// NICE THREE
/*
/// file kickflat3040.wav
var a = DiminishingSinWave(20000,30);
var b = DiminishingSinWave(20000,40);
var q = SumWaves(a,b,2);
/// file kickflat3040_4000.wav
var a = DiminishingSinWave(20000,30,4000);
var b = DiminishingSinWave(20000,40,4000);
var q = SumWaves(a,b,2);
*/
/// NICE FOUR
// higher complex hit
// file kickflat3040_4000_10050_500_2000.wav
/*
var a = DiminishingSinWave(20000,30, 4000);
var b = DiminishingSinWave(20000,40, 4000);
var c = SumWaves(a,b,2);
var d = DiminishingSinWave(20000,100, 500);
var e = DiminishingSinWave(20000,50, 2000);
var f = SumWaves(d,e,2);
var q = SumWaves(c,f,2);
*/
// for the graph. comment if not wanted
console.log(q);
// file output
noitech.build('filename.wav', [ noitech.to64Bit(q) ]);
@zgiles
Copy link
Author

zgiles commented Nov 23, 2015

3040_4000
screen shot 2015-11-22 at 10 45 41 pm

@zgiles
Copy link
Author

zgiles commented Nov 23, 2015

3040_2000
screen shot 2015-11-22 at 10 46 30 pm

@zgiles
Copy link
Author

zgiles commented Nov 23, 2015

3040_4000_10050_500_2000
screen shot 2015-11-22 at 10 47 27 pm

@zgiles
Copy link
Author

zgiles commented Nov 23, 2015

170 226 2245 3032 400

@zgiles
Copy link
Author

zgiles commented Nov 23, 2015

ooo:

// test reverb
// kickrev_60k_40_50_10000_30K_40_55_6000_2000.wav
var a = DiminishingSinWave(60000,40, 10000);
var b = DiminishingSinWave(60000,55, 10000);
var c = SumWaves(a,b,2);
var d = DiminishingSinWave(30000,40, 6000);
var e = DiminishingSinWave(30000,55, 2000);
var f = SumWaves(d,e,2);
var q = SumWaves(c,f,2);

screen shot 2015-11-22 at 11 20 57 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment