Skip to content

Instantly share code, notes, and snippets.

View eeropic's full-sized avatar

Eero Pitkänen eeropic

View GitHub Profile
@eeropic
eeropic / askFifths.js
Last active May 23, 2017 08:58
updated gist via ajax
include('http://eerojohannes.com/midi/js/teoria.js')
var l = console.log.bind(console)
var keyboardPiano=["q","2","w","3","e","r","5","t","6","y","7","u"]
var intervals=["m2","M2","m3","M3","P4","A4","P5","m6","M6","m7","M7"]
l()
function getNote(nr){
@eeropic
eeropic / dragRotateTest.js
Last active May 29, 2017 14:19
updated gist via ajax
Number.prototype.mod = function(n) {return ((this%n)+n)%n;};
project.currentStyle={strokeWidth:10,strokeColor:"black"};
function getCenterPt(path){
var xC=[];
var yC=[];
for(var i=0;i<path.segments.length;i++){
xC.push(path.segments[i].point.x);
yC.push(path.segments[i].point.y);
@eeropic
eeropic / ToneJSAudioBufferToWav.js
Created May 25, 2017 17:15
no description yet
include('http://eerojohannes.com/js/Tone.min.js')
include('http://eerojohannes.com/js/FileSaver.min.js')
//tone.js offline rendering example
//load the buffer for use in the convolver
var buffer = new Tone.Buffer("https://googlechrome.github.io/web-audio-samples/samples/audio/impulse-responses/chorus-feedback.wav");
Tone.loaded().then(function(){
return Tone.Offline(function(Transport){
var reverb = new Tone.Convolver(buffer).toMaster();
@eeropic
eeropic / easing.js
Last active September 27, 2017 16:19 — forked from gre/easing.js
updated gist via ajax
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInSin: function (t) {return 1 + Math.sin(Math.PI / 2 * t - Math.PI / 2)},
easeOutSin : function (t) {return Math.sin(Math.PI / 2 * t)},
@eeropic
eeropic / ToneJS-NexusSketch.js
Last active October 15, 2017 12:14
updated gist via ajax
var root="#root"
var oscillatorTypes=["sine","triangle","square","sawtooth"]
Nexus.Sequencer.prototype.noteScale=[]
Nexus.Dial.prototype.plug=function(target){
this.on('change',function(v){
if(target._sourceType=="Oscillator"){
target.type=oscillatorTypes[Math.min(Math.max(0,Math.floor(v)),3)]
@eeropic
eeropic / svg-nexus-nodes.js
Last active October 22, 2017 09:52
node editor hack in progress
include('https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.3/svg.min.js');
include('http://eerojohannes.com/js/svg.draggable.min.js')
include('http://eerojohannes.com/js/NexusUI.js')
include('https://cdnjs.cloudflare.com/ajax/libs/tone/0.12.7/Tone.min.js')
$('.right_panel').prepend('<div id="root"></div>')
$('<style>svg text{user-select:none;cursor:initial}.node{cursor:move}.inlet, .outlet { fill: #eee; } .inlet:hover, .outlet:hover { fill: #bbb; cursor:pointer }</style>').appendTo('body');
const letWidth=10
const letHeight=20
@eeropic
eeropic / tone-nodes.js
Last active November 3, 2017 14:26
node editor for tone (hacky) editing at sketch.paperjs.org
//SVG.JS NEXUS UI TONE.JS WEBMIDI.JS
include('https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.3/svg.min.js');
include('http://eerojohannes.com/js/NexusUI.js')
include('http://eerojohannes.com/js/svg.panzoom.min.js')
include('https://cdnjs.cloudflare.com/ajax/libs/tone/0.12.7/Tone.min.js')
include('http://eerojohannes.com/js/webmidi.min.js')
$('.right_panel').prepend('<div id="root"></div>')
$('<style>svg text{user-select:none;pointer-events:none;cursor:initial}.node{cursor:move}.inlet, .outlet { fill: #eee; } .inlet:hover, .outlet:hover { fill: #bbb; cursor:e-resize }</style>').appendTo('body');
@eeropic
eeropic / tone-nodes2.js
Last active November 5, 2017 16:59
tone-nodes2.js
//SVG.JS NEXUS UI TONE.JS WEBMIDI.JS
include('https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.3/svg.min.js');
include('http://eerojohannes.com/js/NexusUI.js')
include('http://eerojohannes.com/js/svg.panzoom.min.js')
include('https://cdnjs.cloudflare.com/ajax/libs/tone/0.12.7/Tone.min.js')
include('http://eerojohannes.com/js/webmidi.min.js')
$('.right_panel').prepend('<div id="root"></div>')
$('<style>svg text{user-select:none;pointer-events:none;cursor:initial}.node{cursor:move}.inlet, .outlet { opacity:0.7 } .inlet:hover, .outlet:hover { opacity:1.0; cursor:e-resize }</style>').appendTo('body');
var nodeColors={'audio':"#777777",'control':"#CCCCCC",}
@eeropic
eeropic / debug-log.js
Last active January 8, 2018 19:28
Debug logging
const DEBUG=true;
function log(item){if(typeof console != "undefined" && console.log && DEBUG){var props=[];for(var a in arguments){props.push(arguments[a])}console.log(props.join(","));}}
@eeropic
eeropic / paperjs-huewheel.js
Created December 9, 2017 12:03
paper.js color hue wheel
steps=128
radius=160
var wheel=new Group()
for(var i=0;i<steps;i++){
var seg=new Path();
var circum=radius*2*Math.PI
var step=circum/steps
seg.add([0,0],[radius,-step/2-0.5],[radius,step/2+0.5])