Skip to content

Commit

Permalink
Day 24 Added
Browse files Browse the repository at this point in the history
  • Loading branch information
stc committed Nov 24, 2018
1 parent b46c26d commit 769f373
Show file tree
Hide file tree
Showing 67 changed files with 5,516 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Day-24-Noise-Pianist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
9 changes: 9 additions & 0 deletions Day-24-Noise-Pianist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<title>Prime Distribution</title>
</head>
<body>
<script src="dist/main.js"></script>
</body>
</html>
5,306 changes: 5,306 additions & 0 deletions Day-24-Noise-Pianist/package-lock.json

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions Day-24-Noise-Pianist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "Focus",
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --mode development --open",
"build": "webpack --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.9"
},
"dependencies": {
"@tensorflow/tfjs": "^0.13.4",
"p5": "^0.7.2",
"tfjs": "^0.6.0",
"tone": "^0.12.80"
}
}
13 changes: 13 additions & 0 deletions Day-24-Noise-Pianist/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Day 23 - Prime Distribution

Inspiration
- [Poeme Symphonique for 100 Metronomes](https://www.youtube.com/watch?v=-mUv705xj3U) by György Ligeti

### Install
`npm install --save`

### Develop
`npm run start`

### Deploy
`npm run build`
Binary file added Day-24-Noise-Pianist/sounds/A0.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A0.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A1.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A1.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A2.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A2.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A3.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A3.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A4.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A4.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A5.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A5.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A6.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A6.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A7.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/A7.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C1.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C1.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C2.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C2.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C3.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C3.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C4.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C4.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C5.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C5.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C6.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C6.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C7.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C7.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C8.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/C8.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds1.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds1.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds2.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds2.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds3.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds3.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds4.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds4.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds5.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds5.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds6.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds6.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds7.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Ds7.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs1.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs1.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs2.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs2.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs3.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs3.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs4.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs4.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs5.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs5.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs6.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs6.ogg
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs7.mp3
Binary file not shown.
Binary file added Day-24-Noise-Pianist/sounds/Fs7.ogg
Binary file not shown.
140 changes: 140 additions & 0 deletions Day-24-Noise-Pianist/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import p5 from 'p5/lib/p5.min';
import Tone from 'tone';

const sketch = (p) => {
let noiseScale=0.03;
let n=0.00;
let d=0.5;

let piano;

p.preload = () => {
piano = new Tone.Sampler({
'A0' : 'A0.[mp3|ogg]',
'C1' : 'C1.[mp3|ogg]',
'D#1' : 'Ds1.[mp3|ogg]',
'F#1' : 'Fs1.[mp3|ogg]',
'A1' : 'A1.[mp3|ogg]',
'C2' : 'C2.[mp3|ogg]',
'D#2' : 'Ds2.[mp3|ogg]',
'F#2' : 'Fs2.[mp3|ogg]',
'A2' : 'A2.[mp3|ogg]',
'C3' : 'C3.[mp3|ogg]',
'D#3' : 'Ds3.[mp3|ogg]',
'F#3' : 'Fs3.[mp3|ogg]',
'A3' : 'A3.[mp3|ogg]',
'C4' : 'C4.[mp3|ogg]',
'D#4' : 'Ds4.[mp3|ogg]',
'F#4' : 'Fs4.[mp3|ogg]',
'A4' : 'A4.[mp3|ogg]',
'C5' : 'C5.[mp3|ogg]',
'D#5' : 'Ds5.[mp3|ogg]',
'F#5' : 'Fs5.[mp3|ogg]',
'A5' : 'A5.[mp3|ogg]',
'C6' : 'C6.[mp3|ogg]',
'D#6' : 'Ds6.[mp3|ogg]',
'F#6' : 'Fs6.[mp3|ogg]',
'A6' : 'A6.[mp3|ogg]',
'C7' : 'C7.[mp3|ogg]',
'D#7' : 'Ds7.[mp3|ogg]',
'F#7' : 'Fs7.[mp3|ogg]',
'A7' : 'A7.[mp3|ogg]',
'C8' : 'C8.[mp3|ogg]'
}, {
'release' : 1,
'baseUrl' : '../sounds/'
}).toMaster();
}

let val1, val2 = 0;
let loaded = false;
let alpha = 0;
p.setup = () => {
let canvas = p.createCanvas(800, 800, p.WEBGL);

}
let ptick = 0;
let ptick2 = 0;
p.draw = () => {
p.camera(0,0, 800, 0, 0, 0, 0, 1, 0);
p.background(240);
//p.smooth();

p.stroke(255);
p.line(0,-3000,0,1000);

p.translate(-p.width/2, p.height/4,0);
p.rotateX(p.PI);

n=n+d;
for (let y=0; y<20; y++) {
for(let x=0; x<200; x++) {
let noiseVal = p.noise((n+x)*noiseScale,(-n+y)*noiseScale,y*noiseScale);
p.noStroke();
p.fill((noiseVal*50));
if(x==100) {
p.fill(255,0,0);
if(y==0) {
val1 = noiseVal;
}
if(y==19) {
val2 = noiseVal;
}
}
p.push();
p.translate(x*4,noiseVal*400);
p.sphere(1);
p.pop();
}
}
alpha-=100;

p.push();

p.translate(100*4,val1*400);
p.fill(255,0,0,alpha);
p.sphere(5);
p.pop();

p.push();

p.translate(100*4,val2*400);
p.sphere(5);
p.pop();

if(loaded) {
let tick = p.floor(p.millis()/300);
if(ptick!=tick) {
let rnd = p.random(2);
if(rnd > 0.3) {
alpha = 255;

piano.triggerAttackRelease(Tone.Midi(p.floor(val1*100) + 10).toFrequency(),"128n");
piano.triggerAttackRelease(Tone.Midi(p.floor(val2*100) + 10).toFrequency(),"128n");

}
}
ptick = tick;

let tick2 = p.floor(p.millis()/200);
if(ptick2!=tick2) {
let rnd = p.random(2);
if(rnd > 0.3) {
alpha = 255;
piano.triggerAttackRelease(Tone.Midi(p.floor(val1*100) + 10).toFrequency(),"64n");
//piano.triggerAttackRelease(Tone.Midi(p.floor(val2*100) + 30).toFrequency(),"128n");

}
}
ptick2 = tick2;


}
}

p.keyPressed = () => {
loaded = true;
}
}
export default sketch;
new p5(sketch);
21 changes: 21 additions & 0 deletions Day-24-Noise-Pianist/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const path = require('path');

module.exports = {
entry: {
app: './src/index.js',
},
devtool: 'inline-source-map',
devServer: {
contentBase: path.resolve(__dirname, '.'),
publicPath: '/dist/',
openPage: 'index.html',
port: 8001,
},
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
modules: [path.resolve(__dirname, "node_modules"), "node_modules"]
}
};

0 comments on commit 769f373

Please sign in to comment.