-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPitchCounterApp.js
63 lines (53 loc) · 1.35 KB
/
PitchCounterApp.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* Summary. Contains the implementation to create a instrument dependent
* pitch counter. Exports a PitchCounterApp object for
* a react file to use.
*
* @file This files defines the PitchCounterApp class.
* @author Adam Peters.
*/
class PitchCounterApp {
constructor(instr) {
this.instrument = new InstrumentListener(instr);
this.get_pitch_count = function () {
return this.instrument.get_pitch_count();
};
}
/**
* Change the Instrument to which the app is listening
*
* @param {instr} the String name of the instrument
*/
change_instrument(instr) {
this.instrument.changeInstrument(instr)
}
/**
* Start the EventListener. Cannot start on opening of WebPage due
* to AudioContext limitations.
*/
start() {
this.instrument.startListener();
}
/**
* Completely stop the app from listening.
*/
stop() {
this.instrument.stopListener();
}
/**
* Pause the app from listening.
*/
changeState() {
return this.instrument.changeListenerState();
}
}
app = new PitchCounterApp("piano");
function Begin() {
app.start();
}
function Stop() {
app.stop();
}
function ChangeState() {
app.changeState();
}