mercury-engine 1.0.0

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 ADDED
@@ -0,0 +1,126 @@
1
+ ⚠️ **WORK IN PROGRESS, EXPERIMENTAL USE ONLY** ⚠️
2
+
3
+ # 🌕 Mercury Engine
4
+
5
+ **The engine (core) of the Mercury Live Coding Environment for the browser**
6
+
7
+ This Package does not include the browser editor and user interface. This package allows you to include the Mercury webaudio engine into your own web projects and generate sound from the Mercury code. This engine is used in the [Mercury-Playground](https://github.com/tmhglnd/mercury-playground), a browser based version of the environment.
8
+
9
+ Mercury currently has 2 versions:
10
+
11
+ * Web version running in the browser (Windows/Mac/Linux) [go to this repo](https://github.com/tmhglnd/mercury-playground)
12
+ * Original version running in Max8 (Windows/Mac only) [go to this repo](https://github.com/tmhglnd/mercury)
13
+
14
+ [**🚀 Start Sketching Online!** (recommended for beginners)](https://mercury.timohoogland.com/)
15
+
16
+ **👾 Or code with the latest full version in Max8:**
17
+
18
+ <!-- [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/tmhglnd/mercury)](https://github.com/tmhglnd/mercury/releases)
19
+
20
+ [**📟 Build a local app from the browser version with Electron**](https://github.com/tmhglnd/mercury-app) -->
21
+
22
+ [**🙏 Support Mercury by becoming a Patron**](https://www.patreon.com/bePatron?u=9649817)
23
+
24
+ [**💬 Join the Mercury Community on Discord**](https://discord.gg/vt59NYU)
25
+
26
+ ![The Mercury playground in the browser](media/screenshot.png)
27
+
28
+ # 🚀 Install
29
+
30
+ ## Install in node_modules
31
+
32
+ ```
33
+ $ npm install mercury-engine
34
+ ```
35
+
36
+ ```js
37
+ const { Mercury } = require('mercury-engine');
38
+
39
+ const Engine = new Mercury();
40
+ ```
41
+
42
+ ## Include in html
43
+
44
+ Include latest or specific version of bundled es5 version through url in index.html
45
+
46
+ ```html
47
+ <script src="https://unpkg.com/mercury-engine@1.0.0/build/mercury.min.js"></script>
48
+ ```
49
+
50
+ Use in a html `<script>` like so:
51
+
52
+ ```js
53
+ const { Mercury } = MercuryEngine;
54
+
55
+ const Engine = new Mercury();
56
+ ```
57
+
58
+ # Usage
59
+
60
+ ```js
61
+ // include the package
62
+ const { Mercury } = require('mercury-engine');
63
+
64
+ // initialize the engine and included a callback function
65
+ const Engine = Mercury(() => {
66
+ console.log('This callback is called when samples are loaded!');
67
+ });
68
+
69
+ // resume the transport and start the webaudio
70
+ // this has to be done from a user interaction (click/key) to allow sound
71
+ // to play from the browser window
72
+ Engine.resume()
73
+
74
+ // Evaluate a mercury code file by providing an object with {file:<code>}
75
+ // This also resumes the transport if .resume() was not called yet
76
+ Engine.code({ file: `
77
+ set tempo 100
78
+ new sample kick_909 time(1/4)
79
+ new sample hat_909 time(1/4 1/8) gain(0.6)
80
+ new synth saw note(0 0) time(1/16) shape(1 80)
81
+ `});
82
+
83
+ // stop the transport and silence the audio
84
+ Engine.silence();
85
+
86
+ // start the recording of the sound
87
+ Engine.record(true);
88
+
89
+ // returns 'started' if the recording is on
90
+ Engine.isRecording()
91
+
92
+ // stop the recording and download the file myRecording.webm
93
+ Engine.record(false, 'myRecording');
94
+
95
+ // set the BPM without adding `set tempo` to the Mercury code
96
+ Engine.setBPM(140);
97
+
98
+ // set the volume without adding `set volume` to the Mercury code
99
+ Engine.setVolume(0.5);
100
+
101
+ // add your own samples from for example a url like raw github or freesound
102
+ // the url can also contain a .json file that references multiple samples and
103
+ // the sample name
104
+ Engine.addSamples();
105
+ ```
106
+
107
+ ## 📋 To Do
108
+
109
+ - [ ] Include OSC communcation options via socket.io
110
+ - [ ] Use engine in the Mercury-playground instead of the other code-base
111
+ - [ ] Create examples for the engine
112
+ - [ ] Allow control of parameters via DOM elements
113
+
114
+ ## 🔋 Powered By
115
+
116
+ - Mercury was granted funding from [**Creative Industries Fund NL**](https://stimuleringsfonds.nl/en/)
117
+ - Mercury was granted in-kind funding from [**Creative Coding Utrecht**](https://creativecodingutrecht.nl/)
118
+
119
+ ## 📄 Licenses
120
+
121
+ - Main Source - [The GNU GPL v.3 License](https://choosealicense.com/licenses/gpl-3.0/) (c) Timo Hoogland 2019-2023
122
+ - Sound Files - Individually licensed, listed under [media/README.md](https://github.com/tmhglnd/mercury/blob/master/mercury_ide/media/README.md)
123
+ - Documentation - [The CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/) (c) Timo Hoogland 2019-2023
124
+ - Examples - [The CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/) (c) Timo Hoogland 2019-2023
125
+
126
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.