mercury-engine 1.0.7 → 1.0.8
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/dist/mercury.js +19 -13
- package/dist/mercury.min.es5.js +1 -1
- package/dist/mercury.min.js +1 -1
- package/package.json +1 -1
package/dist/mercury.js
CHANGED
|
@@ -17149,6 +17149,7 @@ class MercuryInterpreter {
|
|
|
17149
17149
|
// arrays with the current and previous instruments for crossfade
|
|
17150
17150
|
this._sounds = [];
|
|
17151
17151
|
this.sounds = [];
|
|
17152
|
+
this.silenced = false;
|
|
17152
17153
|
|
|
17153
17154
|
// storage of latest evaluated code
|
|
17154
17155
|
this._code = '';
|
|
@@ -17216,6 +17217,9 @@ class MercuryInterpreter {
|
|
|
17216
17217
|
}
|
|
17217
17218
|
|
|
17218
17219
|
code(file=''){
|
|
17220
|
+
// is not silenced initially
|
|
17221
|
+
this.silenced = false;
|
|
17222
|
+
|
|
17219
17223
|
// parse and evaluate the inputted code
|
|
17220
17224
|
let c = (!file)? this._code : file;
|
|
17221
17225
|
|
|
@@ -17279,10 +17283,7 @@ class MercuryInterpreter {
|
|
|
17279
17283
|
},
|
|
17280
17284
|
'silence' : (mute) => {
|
|
17281
17285
|
if (mute){
|
|
17282
|
-
|
|
17283
|
-
if (this.silence()){
|
|
17284
|
-
return;
|
|
17285
|
-
}
|
|
17286
|
+
this.silenced = this.silence();
|
|
17286
17287
|
}
|
|
17287
17288
|
},
|
|
17288
17289
|
'scale' : (args) => {
|
|
@@ -17379,11 +17380,6 @@ class MercuryInterpreter {
|
|
|
17379
17380
|
}
|
|
17380
17381
|
}
|
|
17381
17382
|
|
|
17382
|
-
// copy current sounds over to past
|
|
17383
|
-
this._sounds = this.sounds.slice();
|
|
17384
|
-
// empty new sounds array
|
|
17385
|
-
this.sounds = [];
|
|
17386
|
-
|
|
17387
17383
|
// handle .global
|
|
17388
17384
|
Object.keys(this.tree.global).forEach((g) => {
|
|
17389
17385
|
if (globalMap[g]){
|
|
@@ -17391,6 +17387,16 @@ class MercuryInterpreter {
|
|
|
17391
17387
|
}
|
|
17392
17388
|
});
|
|
17393
17389
|
|
|
17390
|
+
// if silenced break out of everything
|
|
17391
|
+
if (this.silenced){
|
|
17392
|
+
return;
|
|
17393
|
+
}
|
|
17394
|
+
|
|
17395
|
+
// copy current sounds over to past
|
|
17396
|
+
this._sounds = this.sounds.slice();
|
|
17397
|
+
// empty new sounds array
|
|
17398
|
+
this.sounds = [];
|
|
17399
|
+
|
|
17394
17400
|
// handle .objects
|
|
17395
17401
|
for (let o in this.tree.objects){
|
|
17396
17402
|
let type = this.tree.objects[o].object;
|
|
@@ -17565,17 +17571,17 @@ class Mercury extends MercuryInterpreter {
|
|
|
17565
17571
|
|
|
17566
17572
|
// stop the transport and all the sounds
|
|
17567
17573
|
silence(){
|
|
17568
|
-
// fade out and remove code after 100ms
|
|
17569
|
-
this.removeSounds(this.sounds, 0.1);
|
|
17570
|
-
|
|
17571
17574
|
try {
|
|
17575
|
+
// fade out and remove code after 100ms
|
|
17576
|
+
this.removeSounds(this.sounds, 0.1);
|
|
17572
17577
|
// Stops instead of pause so restarts at 0
|
|
17573
17578
|
Tone.Transport.stop(Tone.now()+0.1);
|
|
17579
|
+
return true;
|
|
17574
17580
|
// console.log('Stopped Transport');
|
|
17575
17581
|
} catch {
|
|
17576
17582
|
console.error('Error stopping Transport');
|
|
17583
|
+
return false;
|
|
17577
17584
|
}
|
|
17578
|
-
return true;
|
|
17579
17585
|
}
|
|
17580
17586
|
|
|
17581
17587
|
// set the bpm and optionally ramp in milliseconds
|