-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
38 lines (30 loc) · 769 Bytes
/
app.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
var kicker = angular.module("kicker", ['rzModule'])
function KickerController($scope) {
$scope.frequency = 200;
$scope.$watch('frequency', function(){
$scope.setFrequency();
});
$scope.setFrequency = function() {
Audio.getInstance().frequency.value = $scope.frequency;
}
};
var Audio = (function () {
var instance;
function createInstance() {
var context = new webkitAudioContext();
var oscillator = context.createOscillator();
oscillator.type = 0;
oscillator.frequency = 0;
oscillator.connect(context.destination);
oscillator.noteOn(0);
return oscillator;
}
return {
getInstance: function () {
if (!instance) {
instance = createInstance();
}
return instance;
}
};
})();