mercury-engine 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/mercury.js +59 -34
- package/dist/mercury.min.es5.js +1 -1
- package/dist/mercury.min.js +1 -1
- package/examples/basic/index.html +30 -7
- package/package.json +1 -1
|
@@ -4,26 +4,49 @@
|
|
|
4
4
|
<head>
|
|
5
5
|
<title>Mercury Engine Example</title>
|
|
6
6
|
|
|
7
|
-
<script src="https://unpkg.com/mercury-engine@1.0.
|
|
8
|
-
"></script>
|
|
7
|
+
<script src="https://unpkg.com/mercury-engine@1.0.2/dist/mercury.min.es5.js"></script>
|
|
8
|
+
<!-- <script src="./../../dist/mercury.js"></script> -->
|
|
9
|
+
|
|
9
10
|
</head>
|
|
10
11
|
|
|
11
12
|
<body>
|
|
13
|
+
<p style="font-family: 'arial';">
|
|
14
|
+
The Mercury Engine is running on an html page through a script src include from unpkg.com. Open the Javascript Console to see some information logged about the engine while it's running. For documentation go to <a target="blank" href="https://github.com/tmhglnd/mercury-engine#usage">github.com/tmhglnd/mercury-engine</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<!-- 2 buttons in the html page -->
|
|
12
18
|
<button id="b1">start</button>
|
|
13
19
|
<button id="b2">silence</button>
|
|
14
20
|
|
|
15
21
|
<script>
|
|
16
22
|
// This script loads the Mercury Engine and allows to insert code
|
|
17
23
|
// from a textarea in the html page
|
|
18
|
-
|
|
24
|
+
|
|
19
25
|
// Include the package from unpkg.com
|
|
20
26
|
const { Mercury } = MercuryEngine;
|
|
27
|
+
// const { OSC } = MercuryEngine;
|
|
28
|
+
// const { MIDI } = MercuryEngine;
|
|
21
29
|
|
|
22
30
|
// Initialize a Mercury engine with callback function when loaded
|
|
23
|
-
const Engine = new Mercury(
|
|
24
|
-
|
|
31
|
+
const Engine = new Mercury({
|
|
32
|
+
onload: () => {
|
|
33
|
+
console.log('The engine and sounds are loaded!');
|
|
34
|
+
|
|
35
|
+
// set the volume to 0.7, about -3dBFS
|
|
36
|
+
Engine.setVolume(0.7);
|
|
37
|
+
// generate a random BPM
|
|
38
|
+
Engine.randomBPM();
|
|
39
|
+
// set the crossfade from previous and new evaluated code to 250 ms
|
|
40
|
+
Engine.setCrossFade(1000);
|
|
41
|
+
|
|
42
|
+
console.log('BPM:', Engine.bpm);
|
|
43
|
+
console.log('Volume:', Engine.volume);
|
|
44
|
+
console.log('CrossFade:', Engine.crossFade);
|
|
45
|
+
}
|
|
25
46
|
});
|
|
26
47
|
|
|
48
|
+
// console.log(this.getBPM());
|
|
49
|
+
|
|
27
50
|
// Some mercury code initially created
|
|
28
51
|
const simpleCode = `
|
|
29
52
|
set tempo 110
|
|
@@ -46,12 +69,12 @@
|
|
|
46
69
|
|
|
47
70
|
// evaluate the code on the click of a button
|
|
48
71
|
let b1 = document.getElementById('b1');
|
|
49
|
-
b1.onclick = () => Engine.code(
|
|
72
|
+
b1.onclick = () => Engine.code(simpleCode);
|
|
50
73
|
|
|
51
74
|
// stop the code on the click of a button
|
|
52
75
|
let b2 = document.getElementById('b2');
|
|
53
76
|
b2.onclick = () => Engine.silence();
|
|
54
|
-
|
|
55
77
|
</script>
|
|
56
78
|
</body>
|
|
79
|
+
|
|
57
80
|
</html>
|