-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample3.html
49 lines (39 loc) · 1.1 KB
/
sample3.html
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
<DOCTYPE html>
<html>
<head>
<script src="crotchet.js"></script>
</head>
<body>
<script>
/* OSCILLATOR AND GAIN NODE */
//CREATE OSCILATTOR NODE WITH FREQUENCY 1000 AND WAVEFORM TYPE SQUARE
var oscillator = CROTCHET.createOscillator(1000,"square");
//CREATE GAIN NODE WITH gain 0.5
var gain = CROTCHET.createGain(50);
//CONNECT OSCILLATOR TO GAIN
oscillator.connectNode(gain);
//PLAY OSCILLATOR SOUND WITH FREQ 1000Hz
oscillator.start();
//CHANGE FREQ AT 2s
setTimeout(function(){
oscillator.setFrequency(440);
},2000);
//GENERATE A DETUNE A SEMITONE AT 3.3s
setTimeout(function(){
oscillator.detune(Math.pow(2, 1/12) * 10);
},3300);
//CHANGE WAVEFORM TYPE TO SAWTOOTH (YOU CAN USE SINE, SAWTOOTH, SQUARE, TRIANGLE AND CUSTOM)
setTimeout(function(){
oscillator.setType("SAWTOOTH");
},4000);
//SET GAIN AT 1 AT 5s
setTimeout(function(){
gain.setGain(100);
},5000);
//STOP SOUND AT 6s
setTimeout(function(){
oscillator.stop();
},6000);
</script>
</body>
</html>