mercury-engine 1.0.0 → 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 +62 -182
- package/dist/mercury.min.es5.js +1 -1
- package/dist/mercury.min.js +1 -1
- package/examples/basic/index.html +80 -0
- package/package.json +2 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<title>Mercury Engine Example</title>
|
|
6
|
+
|
|
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
|
+
|
|
10
|
+
</head>
|
|
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 -->
|
|
18
|
+
<button id="b1">start</button>
|
|
19
|
+
<button id="b2">silence</button>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
// This script loads the Mercury Engine and allows to insert code
|
|
23
|
+
// from a textarea in the html page
|
|
24
|
+
|
|
25
|
+
// Include the package from unpkg.com
|
|
26
|
+
const { Mercury } = MercuryEngine;
|
|
27
|
+
// const { OSC } = MercuryEngine;
|
|
28
|
+
// const { MIDI } = MercuryEngine;
|
|
29
|
+
|
|
30
|
+
// Initialize a Mercury engine with callback function when loaded
|
|
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
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// console.log(this.getBPM());
|
|
49
|
+
|
|
50
|
+
// Some mercury code initially created
|
|
51
|
+
const simpleCode = `
|
|
52
|
+
set tempo 110
|
|
53
|
+
set randomSeed 4831
|
|
54
|
+
set scale dorian d
|
|
55
|
+
|
|
56
|
+
list progression chordsFromNumerals([I7 IIIm7 IV7 V7])
|
|
57
|
+
new polySynth saw name(chrd)
|
|
58
|
+
set chrd note(progression 1) time(2/1) shape(1 2/1) fx(triggerFilter low 1/1 1/1 4000 100) super(0.132 3)
|
|
59
|
+
|
|
60
|
+
list melody add(repeat(flat(progression) 2) [0 12])
|
|
61
|
+
new polySynth saw name(lead)
|
|
62
|
+
set lead note(melody 2) time(1/8) shape(1 2/1) super(0.112 3) gain(0.6) fx(triggerFilter low 1 1/6 5000 100)
|
|
63
|
+
|
|
64
|
+
set all fx(squash 1) fx(reverb 0.4 7)
|
|
65
|
+
|
|
66
|
+
list drums choose(17 [hat_808 kick_808 snare_808])
|
|
67
|
+
new sample drums time(1/8) gain(0.7) fx(degrade 0.7) fx(delay 3/16 5/16 0.9) timediv([1 1 1 2])
|
|
68
|
+
`
|
|
69
|
+
|
|
70
|
+
// evaluate the code on the click of a button
|
|
71
|
+
let b1 = document.getElementById('b1');
|
|
72
|
+
b1.onclick = () => Engine.code(simpleCode);
|
|
73
|
+
|
|
74
|
+
// stop the code on the click of a button
|
|
75
|
+
let b2 = document.getElementById('b2');
|
|
76
|
+
b2.onclick = () => Engine.silence();
|
|
77
|
+
</script>
|
|
78
|
+
</body>
|
|
79
|
+
|
|
80
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mercury-engine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "The mercury engine generates web audio output from mercury code input",
|
|
5
5
|
"main": "./dist/mercury.js",
|
|
6
6
|
"scripts": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@babel/preset-env": "^7.23.3",
|
|
44
44
|
"brfs": "^2.0.2",
|
|
45
45
|
"browserify": "^17.0.0",
|
|
46
|
+
"minify-inline-json": "^1.1.11",
|
|
46
47
|
"terser": "^5.24.0",
|
|
47
48
|
"uglifyjs": "^2.4.11",
|
|
48
49
|
"watchify": "^4.0.0"
|