|
1 | 1 | import audiocontext from './audiocontext.js';
|
2 | 2 | // Master contains the master sound output.
|
3 |
| -var Master = function () { |
4 |
| - this.input = audiocontext.createGain(); |
5 |
| - this.output = audiocontext.createGain(); |
| 3 | +class Master { |
| 4 | + constructor() { |
| 5 | + this.input = audiocontext.createGain(); |
| 6 | + this.output = audiocontext.createGain(); |
6 | 7 |
|
7 |
| - //put a hard limiter on the output |
8 |
| - this.limiter = audiocontext.createDynamicsCompressor(); |
9 |
| - this.limiter.threshold.value = -3; |
10 |
| - this.limiter.ratio.value = 20; |
11 |
| - this.limiter.knee.value = 1; |
| 8 | + //put a hard limiter on the output |
| 9 | + this.limiter = audiocontext.createDynamicsCompressor(); |
| 10 | + this.limiter.threshold.value = -3; |
| 11 | + this.limiter.ratio.value = 20; |
| 12 | + this.limiter.knee.value = 1; |
12 | 13 |
|
13 |
| - this.audiocontext = audiocontext; |
| 14 | + this.audiocontext = audiocontext; |
14 | 15 |
|
15 |
| - this.output.disconnect(); |
| 16 | + this.output.disconnect(); |
16 | 17 |
|
17 |
| - // connect input to limiter |
18 |
| - this.input.connect(this.limiter); |
| 18 | + // connect input to limiter |
| 19 | + this.input.connect(this.limiter); |
19 | 20 |
|
20 |
| - // connect limiter to output |
21 |
| - this.limiter.connect(this.output); |
| 21 | + // connect limiter to output |
| 22 | + this.limiter.connect(this.output); |
22 | 23 |
|
23 |
| - // meter is just for global Amplitude / FFT analysis |
24 |
| - this.meter = audiocontext.createGain(); |
25 |
| - this.fftMeter = audiocontext.createGain(); |
26 |
| - this.output.connect(this.meter); |
27 |
| - this.output.connect(this.fftMeter); |
| 24 | + // meter is just for global Amplitude / FFT analysis |
| 25 | + this.meter = audiocontext.createGain(); |
| 26 | + this.fftMeter = audiocontext.createGain(); |
| 27 | + this.output.connect(this.meter); |
| 28 | + this.output.connect(this.fftMeter); |
28 | 29 |
|
29 |
| - // connect output to destination |
30 |
| - this.output.connect(this.audiocontext.destination); |
| 30 | + // connect output to destination |
| 31 | + this.output.connect(this.audiocontext.destination); |
31 | 32 |
|
32 |
| - // an array of all sounds in the sketch |
33 |
| - this.soundArray = []; |
34 |
| - // an array of all musical parts in the sketch |
35 |
| - this.parts = []; |
| 33 | + // an array of all sounds in the sketch |
| 34 | + this.soundArray = []; |
| 35 | + // an array of all musical parts in the sketch |
| 36 | + this.parts = []; |
36 | 37 |
|
37 |
| - // file extensions to search for |
38 |
| - this.extensions = []; |
39 |
| -}; |
| 38 | + // file extensions to search for |
| 39 | + this.extensions = []; |
| 40 | + } |
| 41 | +} |
40 | 42 |
|
41 | 43 | // create a single instance of the p5Sound / master output for use within this sketch
|
42 | 44 | const p5sound = new Master();
|
43 |
| -// console.log(p5sound.audiocontext) |
44 | 45 |
|
45 | 46 | /**
|
46 | 47 | * Returns a number representing the master amplitude (volume) for sound
|
|
0 commit comments