-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsynthesizer.component.ts
83 lines (66 loc) · 2.14 KB
/
synthesizer.component.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { SynthesizerLfo } from './classes/synthesizer/synthesizer-modulator/synthesizer-modulators/synthesizer-lfo';
import { SynthesizerSequencer } from './classes/synthesizer/synthesizer-modulator/synthesizer-modulators/synthesizer-sequencer';
import { SynthesizerService } from './synthesizer.service';
import { Synthesizer } from './classes/synthesizer/synthesizer';
import { SynthesizerOsc } from './classes/synthesizer/synthesizer-osc/synthesizer-osc';
@Component({
selector: 'app-synthesizer',
templateUrl: './synthesizer.component.html',
styleUrls: ['./synthesizer.component.scss']
})
export class SynthesizerComponent implements OnInit {
views = ['osc', 'lfo'];
currentView = this.views[0];
synthesizer: Synthesizer;
currentOsc: SynthesizerOsc;
currentLfo: SynthesizerLfo;
currentSequencer: SynthesizerSequencer;
currentOscNumber;
octaves = 4;
connectLfo: SynthesizerLfo;
nodesTabs = ['LFO', 'Sequencer'];
nodesTab = this.nodesTabs[0];
showDisplay = true;
showKeyboard = true;
showMidiControls = false;
constructor(public audioEditor: SynthesizerService, private cdRef: ChangeDetectorRef) {
this.synthesizer = new Synthesizer(3, 1, 1, cdRef);
if (this.synthesizer.oscs) {
this.currentOsc = this.synthesizer.oscs[0];
}
}
ngOnInit(): void {
if (this.synthesizer && this.synthesizer.manager) {
this.synthesizer.manager.getLocalStorage();
}
}
showView(viewName) {
this.currentView = viewName;
}
selectOsc(osc: SynthesizerOsc) {
if (this.synthesizer.oscs) {
for (let i = 0; i < this.synthesizer.oscs.length; i++) {
if (this.synthesizer.oscs[i] === osc) {
this.currentOscNumber = i + 1;
}
}
}
this.currentOsc = osc;
}
selectLfo(lfo: SynthesizerLfo) {
this.currentLfo = lfo;
}
selectSequencer(sequencer: SynthesizerSequencer) {
this.currentSequencer = sequencer;
}
pianoKeyDown(e) {
this.synthesizer.playNote(e.note, e.octave);
}
pianoKeyUp(e) {
this.synthesizer.stopTone();
}
setPitch(pitch) {
this.synthesizer.pitch(pitch);
}
}