-
Notifications
You must be signed in to change notification settings - Fork 1
/
noteNeuron.js
41 lines (36 loc) · 1021 Bytes
/
noteNeuron.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Oscillator
var osc;
osc = new p5.Oscillator();
osc.setType('triangle');
osc.start();
osc.amp(0);
var twelveTones = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B'];
class NoteNeuron extends Neuron {
constructor(x, y, neuronSize, actlvl, note) {
super(x, y, neuronSize, actlvl);
this.note = note;
}
display() {
this.selected ? fill(200, 200, 60) : fill(0, 255, 255);
stroke(sketchOptions.gridColor);
rect(this.x, this.y, this.size, this.size);
fill(0);
textAlign(CENTER);
textSize(this.size);
let letter = '♪';
text(letter, this.x + this.size/2, this.y + this.size/1.15);
}
activate() {
osc.amp(0.05);
osc.freq(midiToFreq(this.note));
_.each(this.outBoundConnections, otherNeuron => {
let id = _.uniqueId();
actionPotentialList[`${id}`] = new ActionPotential(this, otherNeuron, this.size/2, id, this.actionPotentialCharge, this.size);
});
}
reset() {
this.curCharge = 0;
this.currentSteps = 0;
osc.amp(0);
}
}