mercury-engine 1.0.2 → 1.0.3

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 CHANGED
@@ -15195,7 +15195,7 @@ const LFO = function(_params){
15195
15195
  if (this._waveMap[w]){
15196
15196
  w = this._waveMap[w];
15197
15197
  } else {
15198
- console.log(`'${w} is not a valid waveshape`);
15198
+ Util.log(`'${w} is not a valid waveshape`);
15199
15199
  // default wave if wave does not exist
15200
15200
  w = 'sine';
15201
15201
  }
@@ -15244,7 +15244,7 @@ const Filter = function(_params){
15244
15244
  if (this._types[_params[0]]){
15245
15245
  this._fx.set({ type: this._types[_params[0]] });
15246
15246
  } else {
15247
- console.log(`'${_params[0]}' is not a valid filter type`);
15247
+ Util.log(`'${_params[0]}' is not a valid filter type`);
15248
15248
  this._fx.set({ type: 'lowpass' });
15249
15249
  }
15250
15250
  this._fx.set({ rolloff: -24 });
@@ -15318,7 +15318,7 @@ const TriggerFilter = function(_params){
15318
15318
  if (this._types[_params[0][0]]){
15319
15319
  this._fx.set({ type: this._types[_params[0][0]] });
15320
15320
  } else {
15321
- console.log(`'${_params[0][0]}' is not a valid filter type. Defaulting to lowpass`);
15321
+ Util.log(`'${_params[0][0]}' is not a valid filter type. Defaulting to lowpass`);
15322
15322
  this._fx.set({ type: 'lowpass' });
15323
15323
  }
15324
15324
 
@@ -15758,7 +15758,7 @@ class Instrument extends Sequencer {
15758
15758
  let tmpF = fxMap[f[0]](f.slice(1));
15759
15759
  this._fx.push(tmpF);
15760
15760
  } else {
15761
- log(`Effect ${f[0]} does not exist`);
15761
+ Util.log(`Effect ${f[0]} does not exist`);
15762
15762
  }
15763
15763
  });
15764
15764
  // if any fx working
@@ -15789,6 +15789,7 @@ module.exports = Instrument;
15789
15789
  },{"./Effects.js":56,"./Sequencer.js":65,"./Util.js":66,"tone":44}],58:[function(require,module,exports){
15790
15790
  const Tone = require('tone');
15791
15791
  const Instrument = require('./Instrument.js');
15792
+ const Util = require('./Util.js');
15792
15793
 
15793
15794
  class MonoInput extends Instrument {
15794
15795
  constructor(engine, d, canvas){
@@ -15799,7 +15800,7 @@ class MonoInput extends Instrument {
15799
15800
  } else if (d.match(/in(\d+)/g)){
15800
15801
  this._device = Number(d.match(/in(\d+)/)[1]);
15801
15802
  } else {
15802
- console.log(`${d} is not a valid microphone input. defaults to in0`);
15803
+ Util.log(`${d} is not a valid microphone input. defaults to in0`);
15803
15804
  this._device = 0;
15804
15805
  }
15805
15806
 
@@ -15812,9 +15813,9 @@ class MonoInput extends Instrument {
15812
15813
  createSource(){
15813
15814
  this.mic = new Tone.UserMedia().connect(this.channelStrip());
15814
15815
  this.mic.open(this._device).then(() => {
15815
- console.log(`Opened microphone: ${window.devices[this._device]}`);
15816
+ Util.log(`Opened microphone: ${window.devices[this._device]}`);
15816
15817
  }).catch((e) => {
15817
- console.log(`Unable to use microphone`);
15818
+ Util.log(`Unable to use microphone`);
15818
15819
  });
15819
15820
  this.mic.channelInterpretation = 'discrete';
15820
15821
 
@@ -15837,11 +15838,11 @@ class MonoInput extends Instrument {
15837
15838
  }
15838
15839
  }
15839
15840
  module.exports = MonoInput;
15840
- },{"./Instrument.js":57,"tone":44}],59:[function(require,module,exports){
15841
+ },{"./Instrument.js":57,"./Util.js":66,"tone":44}],59:[function(require,module,exports){
15841
15842
  const Tone = require('tone');
15842
15843
  const Util = require('./Util.js');
15843
15844
  const Sequencer = require('./Sequencer.js');
15844
- const WebMidi = require("webmidi");
15845
+ const { WebMidi } = require("webmidi");
15845
15846
 
15846
15847
  class MonoMidi extends Sequencer {
15847
15848
  constructor(engine, d='default', canvas){
@@ -15852,7 +15853,7 @@ class MonoMidi extends Sequencer {
15852
15853
  if (d === 'default'){
15853
15854
  this._device = WebMidi.outputs[0];
15854
15855
  } else if (!this._device){
15855
- console.log(`${d} is not a valid MIDI Device name, set to default`);
15856
+ Util.log(`${d} is not a valid MIDI Device name, set to default`);
15856
15857
  this._device = WebMidi.outputs[0];
15857
15858
  }
15858
15859
 
@@ -15919,8 +15920,8 @@ class MonoMidi extends Sequencer {
15919
15920
  n[x] = Util.toMidi(i[x], o);
15920
15921
  }
15921
15922
 
15922
- // play the note(s)!
15923
- this._device.playNote(n, ch, { duration: d, velocity: g, time: sync });
15923
+ // play the note(s)! updated for webmidi 3.x
15924
+ this._device.playNote(n, ch, { duration: d, attack: g, time: sync });
15924
15925
 
15925
15926
  // }
15926
15927
  }
@@ -15959,7 +15960,7 @@ class MonoMidi extends Sequencer {
15959
15960
  this._cc = [];
15960
15961
  cc.forEach((c) => {
15961
15962
  if (isNaN(c[0])){
15962
- console.log(`'${c[0]}' is not a valid CC number`);
15963
+ Util.log(`'${c[0]}' is not a valid CC number`);
15963
15964
  } else {
15964
15965
  let cc = [];
15965
15966
  cc[0] = c[0];
@@ -16084,7 +16085,7 @@ class MonoSample extends Instrument {
16084
16085
  // error if soundfile does not exist
16085
16086
  else if (!this._bufs.has(s)){
16086
16087
  // set default (or an ampty soundfile?)
16087
- console.log(`sample ${s} not found`);
16088
+ Util.log(`sample ${s} not found`);
16088
16089
  return 'kick_909';
16089
16090
  }
16090
16091
  return s;
@@ -16191,7 +16192,7 @@ class MonoSynth extends Instrument {
16191
16192
  if (this._waveMap[w]){
16192
16193
  w = this._waveMap[w];
16193
16194
  } else {
16194
- console.log(`${w} is not a valid waveshape`);
16195
+ Util.log(`${w} is not a valid waveshape`);
16195
16196
  // default wave if wave does not exist
16196
16197
  w = 'sine';
16197
16198
  }
@@ -16387,7 +16388,7 @@ class PolyInstrument extends Instrument {
16387
16388
  }
16388
16389
 
16389
16390
  voices(v){
16390
- console.log(`Changing voice amount is not yet supported. You can use voice-stealing with steal(on)`);
16391
+ Util.log(`Changing voice amount is not yet supported. You can use voice-stealing with steal(on)`);
16391
16392
  // TODO change voice amount
16392
16393
  // set the voiceamount for the polyphonic synth
16393
16394
  // this.numVoices = Math.max(1, isNaN(Number(v))? 6 : Number(v));
@@ -16402,7 +16403,7 @@ class PolyInstrument extends Instrument {
16402
16403
  } else if (s === 'off' || s == 0){
16403
16404
  this._steal = false;
16404
16405
  } else {
16405
- console.log(`${s} is not a valid argument for steal()`);
16406
+ Util.log(`${s} is not a valid argument for steal()`);
16406
16407
  }
16407
16408
  }
16408
16409
 
@@ -16543,7 +16544,7 @@ class PolySample extends PolyInstrument {
16543
16544
  // error if soundfile does not exist
16544
16545
  else if (!this._bufs.has(s)){
16545
16546
  // set default (or an ampty soundfile?)
16546
- console.log(`sample ${s} not found`);
16547
+ Util.log(`sample ${s} not found`);
16547
16548
  return 'kick_909';
16548
16549
  }
16549
16550
  return s;
@@ -16960,7 +16961,7 @@ function getOSC(a){
16960
16961
  return a;
16961
16962
  } else if (osc.match(/^\/[^`'"\s]+/g)){
16962
16963
  if (!window.oscMessages[osc]){
16963
- console.log(`No message received on address ${osc}`);
16964
+ log(`No message received on address ${osc}`);
16964
16965
  return [0];
16965
16966
  }
16966
16967
  return window.oscMessages[osc];
@@ -16993,7 +16994,7 @@ function evalExpr(a){
16993
16994
  try {
16994
16995
  result = eval(expr);
16995
16996
  } catch (e){
16996
- console.log(`Unable to evaluate expression: ${expr}`);
16997
+ log(`Unable to evaluate expression: ${expr}`);
16997
16998
  }
16998
16999
  return result;
16999
17000
  }
@@ -17018,8 +17019,7 @@ function formatRatio(d, bpm){
17018
17019
  } else if (!isNaN(Number(d))){
17019
17020
  return Number(d) * 4.0 * 60 / bpm;
17020
17021
  } else {
17021
- // print(`${d} is not a valid time value`);
17022
- console.log(`${d} is not a valid time value`);
17022
+ log(`${d} is not a valid time value`);
17023
17023
  return 60 / bpm;
17024
17024
  }
17025
17025
  }
@@ -17031,7 +17031,7 @@ function divToS(d, bpm){
17031
17031
  } else if (!isNaN(Number(d))){
17032
17032
  return Number(d) / 1000;
17033
17033
  } else {
17034
- console.log(`${d} is not a valid time value`);
17034
+ log(`${d} is not a valid time value`);
17035
17035
  return 0.1;
17036
17036
  }
17037
17037
  }
@@ -17041,7 +17041,7 @@ function noteToFreq(i, o){
17041
17041
  if (isNaN(i)){
17042
17042
  let _i = noteToMidi(i);
17043
17043
  if (!_i){
17044
- console.log(`${i} is not a valid number or name`);
17044
+ log(`${i} is not a valid number or name`);
17045
17045
  i = 0;
17046
17046
  } else {
17047
17047
  i = _i - 48;
@@ -17072,7 +17072,7 @@ function assureWave(w){
17072
17072
  if (waveMap[w]){
17073
17073
  w = waveMap[w];
17074
17074
  } else {
17075
- console.log(`${w} is not a valid waveshape`);
17075
+ log(`${w} is not a valid waveshape`);
17076
17076
  // default wave if wave does not exist
17077
17077
  w = 'sine';
17078
17078
  }
@@ -17084,7 +17084,7 @@ function toMidi(n=0, o=0){
17084
17084
  if (isNaN(n)){
17085
17085
  let _n = noteToMidi(n);
17086
17086
  if (!_n){
17087
- console.log(`${n} is not a valid number or name`);
17087
+ log(`${n} is not a valid number or name`);
17088
17088
  n = 0;
17089
17089
  } else {
17090
17090
  n = _n - 36;
@@ -17093,7 +17093,18 @@ function toMidi(n=0, o=0){
17093
17093
  return toScale(n + o * 12 + 36);
17094
17094
  }
17095
17095
 
17096
- module.exports = { clip, assureNum, lookup, randLookup, isRandom, getParam, toArray, msToS, formatRatio, divToS, toMidi, mtof, noteToMidi, noteToFreq, assureWave }
17096
+ // the log message is used to log to the console but also
17097
+ // sends a custom event that can be listened for to print the
17098
+ // content at some other place in the window, for example using a div
17099
+ function log(msg){
17100
+ console.log(msg);
17101
+ if (window){
17102
+ let print = new CustomEvent('mercuryLog', { detail: msg });
17103
+ window.dispatchEvent(print);
17104
+ }
17105
+ }
17106
+
17107
+ module.exports = { clip, assureNum, lookup, randLookup, isRandom, getParam, toArray, msToS, formatRatio, divToS, toMidi, mtof, noteToMidi, noteToFreq, assureWave, log }
17097
17108
  },{"total-serialism":47}],67:[function(require,module,exports){
17098
17109
  module.exports={
17099
17110
  "uptempo" : 10,
@@ -17120,7 +17131,7 @@ module.exports={
17120
17131
  const Tone = require('tone');
17121
17132
  const Mercury = require('mercury-lang');
17122
17133
  const TL = require('total-serialism').Translate;
17123
- const Util = require('total-serialism').Utility;
17134
+ const { normalize, multiply } = require('total-serialism').Utility;
17124
17135
 
17125
17136
  const MonoSample = require('./core/MonoSample.js');
17126
17137
  const MonoMidi = require('./core/MonoMidi.js');
@@ -17129,11 +17140,12 @@ const MonoInput = require('./core/MonoInput.js');
17129
17140
  const PolySynth = require('./core/PolySynth.js');
17130
17141
  const PolySample = require('./core/PolySample.js');
17131
17142
  const Tempos = require('./data/genre-tempos.json');
17143
+ const Util = require('./core/Util.js');
17132
17144
 
17133
17145
  class MercuryInterpreter {
17134
17146
  constructor({ hydra, p5canvas } = {}){
17135
17147
  // cross-fade time
17136
- this.crossFade = 0.5;
17148
+ this.crossFade;
17137
17149
 
17138
17150
  // arrays with the current and previous instruments for crossfade
17139
17151
  this._sounds = [];
@@ -17173,34 +17185,45 @@ class MercuryInterpreter {
17173
17185
  startSounds(s, f=0){
17174
17186
  // fade in new sounds
17175
17187
  s.map((_s) => {
17176
- _s.fadeIn(f);
17188
+ if (_s){ _s.fadeIn(f); }
17177
17189
  });
17178
17190
  }
17179
17191
 
17180
17192
  removeSounds(s, f=0) {
17181
17193
  // fade out and delete after fade
17182
17194
  s.map((_s) => {
17183
- _s.fadeOut(f);
17195
+ if (_s){ _s.fadeOut(f); }
17184
17196
  });
17185
17197
  // empty array to trigger garbage collection
17186
17198
  s.length = 0;
17187
17199
  }
17188
17200
 
17201
+ makeLoops(s){
17202
+ // make the loops for all the instruments
17203
+ s.map((_s) => {
17204
+ if (_s){ _s.makeLoop(); }
17205
+ });
17206
+ }
17207
+
17189
17208
  setCrossFade(f){
17190
17209
  // set the crossFade in milliseconds
17191
17210
  this.crossFade = Number(f) / 1000;
17192
- // log(`Crossfade: ${f}ms`);
17211
+ Util.log(`Crossfade set to: ${f}ms`);
17212
+ }
17213
+
17214
+ getCode(){
17215
+ // return the last evaluated code
17216
+ return this._code;
17193
17217
  }
17194
17218
 
17195
17219
  code(file=''){
17196
17220
  // parse and evaluate the inputted code
17197
- // as an asyncronous function with promise
17198
17221
  let c = (!file)? this._code : file;
17199
- this._code = c;
17200
-
17201
- let t = Tone.Transport.seconds;
17202
17222
 
17223
+ let t = Tone.Transport.seconds;
17224
+
17203
17225
  // is this necessary?
17226
+ // as an asyncronous function with promise
17204
17227
  // let parser = new Promise((resolve) => {
17205
17228
  // return resolve(Mercury(c));
17206
17229
  // });
@@ -17216,18 +17239,19 @@ class MercuryInterpreter {
17216
17239
  // l.innerHTML = '';
17217
17240
  // handle .print and .errors
17218
17241
  this.errors.forEach((e) => {
17219
- console.log(e);
17220
- // log(e);
17242
+ Util.log(e);
17221
17243
  });
17222
17244
  if (this.errors.length > 0){
17223
17245
  // return if the code contains any syntax errors
17224
- console.log(`Could not run because of syntax error`);
17225
- console.log(`Please see Help for more information`);
17246
+ Util.log(`Could not run because of syntax error`);
17247
+ Util.log(`Please see Help for more information`);
17226
17248
  return;
17227
17249
  }
17250
+ // if no errors the last evaluated code is stored
17251
+ this._code = c;
17228
17252
 
17229
17253
  this.tree.print.forEach((p) => {
17230
- console.log(p);
17254
+ Util.log(p);
17231
17255
  });
17232
17256
 
17233
17257
  // set timer to check evaluation time
@@ -17244,7 +17268,7 @@ class MercuryInterpreter {
17244
17268
  if (isNaN(t)){
17245
17269
  t = Tempos[args[0].toLowerCase()];
17246
17270
  if (t === undefined){
17247
- console.log(`tempo ${args[0]} is not a valid genre or number`);
17271
+ Util.log(`tempo ${args[0]} is not a valid genre or number`);
17248
17272
  return;
17249
17273
  }
17250
17274
  args[0] = t;
@@ -17274,16 +17298,15 @@ class MercuryInterpreter {
17274
17298
  if (s.indexOf(scl) > -1){
17275
17299
  TL.setScale(scl);
17276
17300
  } else {
17277
- console.log(`${scl} is not a valid scale`);
17301
+ Util.log(`${scl} is not a valid scale`);
17278
17302
  }
17279
17303
  if (rt){
17280
17304
  TL.setRoot(rt);
17281
17305
  }
17282
-
17283
- let tmpS = TL.getScale().scale;
17284
- let tmpR = TL.getScale().root;
17306
+ // let tmpS = TL.getScale().scale;
17307
+ // let tmpR = TL.getScale().root;
17285
17308
  // document.getElementById('scale').innerHTML = `scale = ${tmpR} ${tmpS}`;
17286
- // log(`set scale to ${tmpR} ${tmpS}`);
17309
+ // Util.log(`set scale to ${tmpR} ${tmpS}`);
17287
17310
  },
17288
17311
  'amp' : (args) => {
17289
17312
  this.setVolume(...args);
@@ -17328,6 +17351,10 @@ class MercuryInterpreter {
17328
17351
  return inst;
17329
17352
  },
17330
17353
  'midi' : (obj) => {
17354
+ if (!this.midi.enabled){
17355
+ Util.log(`WebMIDI is not started. Please load the package and check your browser compatibility`);
17356
+ return null;
17357
+ }
17331
17358
  let inst = new MonoMidi(this, obj.type, this.canvas);
17332
17359
  objectMap.applyFunctions(obj.functions, inst, obj.type);
17333
17360
  return inst;
@@ -17368,18 +17395,15 @@ class MercuryInterpreter {
17368
17395
  if (objectMap[type]){
17369
17396
  this.sounds.push(objectMap[type](this.tree.objects[o]));
17370
17397
  } else {
17371
- log(`Instrument named '${type}' is not supported`);
17398
+ Util.log(`Instrument named '${type}' is not supported`);
17372
17399
  }
17373
17400
  }
17374
17401
 
17375
17402
  // start new loops;
17376
- this.sounds.map((s) => {
17377
- s.makeLoop();
17378
- });
17379
-
17380
- console.log(`Instruments added in: ${((Tone.Transport.seconds - t) * 1000).toFixed(3)}ms`);
17381
-
17403
+ this.makeLoops(this.sounds);
17382
17404
  this.transferCounts(this._sounds, this.sounds);
17405
+
17406
+ console.log(`Instruments added in: ${((Tone.Transport.seconds - t) * 1000).toFixed(3)}ms`);
17383
17407
 
17384
17408
  // when all loops started fade in the new sounds and fade out old
17385
17409
  if (!this.sounds.length){
@@ -17398,7 +17422,7 @@ class MercuryInterpreter {
17398
17422
  // handle .display to p5
17399
17423
  tree.display.forEach((p) => {
17400
17424
  // restart canvas if view is used
17401
- let n = Util.mul(Util.normalize(p), 255);
17425
+ let n = multiply(normalize(p), 255);
17402
17426
  this.p5canvas.sketch.fillCanvas(n);
17403
17427
  this.p5canvas.display();
17404
17428
  });
@@ -17406,7 +17430,7 @@ class MercuryInterpreter {
17406
17430
  }
17407
17431
  }
17408
17432
  module.exports = { MercuryInterpreter }
17409
- },{"./core/MonoInput.js":58,"./core/MonoMidi.js":59,"./core/MonoSample.js":60,"./core/MonoSynth.js":61,"./core/PolySample.js":63,"./core/PolySynth.js":64,"./data/genre-tempos.json":67,"mercury-lang":27,"tone":44,"total-serialism":47}],69:[function(require,module,exports){
17433
+ },{"./core/MonoInput.js":58,"./core/MonoMidi.js":59,"./core/MonoSample.js":60,"./core/MonoSynth.js":61,"./core/PolySample.js":63,"./core/PolySynth.js":64,"./core/Util.js":66,"./data/genre-tempos.json":67,"mercury-lang":27,"tone":44,"total-serialism":47}],69:[function(require,module,exports){
17410
17434
 
17411
17435
  console.log(`
17412
17436
  Mercury Engine by Timo Hoogland (c) 2023
@@ -17419,7 +17443,9 @@ Mercury Engine by Timo Hoogland (c) 2023
17419
17443
  `);
17420
17444
 
17421
17445
  const Tone = require('tone');
17446
+ const Util = require('./core/Util.js');
17422
17447
  const { MercuryInterpreter } = require('./interpreter');
17448
+ const { WebMidi } = require("webmidi");
17423
17449
 
17424
17450
  // load extra AudioWorkletProcessors from file
17425
17451
  // transformed to inline with browserify brfs
@@ -17431,7 +17457,7 @@ Tone.getContext().addAudioWorkletModule(URL.createObjectURL(new Blob([ fxExtensi
17431
17457
  // also has the interpreter evaluating the code and adding the instruments
17432
17458
  //
17433
17459
  class Mercury extends MercuryInterpreter {
17434
- constructor({ onload, hydra, p5canvas } = {}){
17460
+ constructor({ onload, onmidi, hydra, p5canvas } = {}){
17435
17461
  // initalize the constructor of inheriting class with
17436
17462
  // optionally a hydra and p5 canvas
17437
17463
  super({ hydra, p5canvas });
@@ -17444,28 +17470,69 @@ class Mercury extends MercuryInterpreter {
17444
17470
  // this.addBuffers(['http://localhost:8080/mercury-engine/src/data/samples.json'])
17445
17471
 
17446
17472
  // setting parameters
17447
- this.bpm = 100;
17448
- this.volume = 1;
17473
+ this.bpm;
17474
+ this.volume;
17475
+ this.lowPass;
17476
+ this.highPass;
17449
17477
 
17450
17478
  // effects on main output for Tone
17451
17479
  this.gain = new Tone.Gain(1);
17452
- this.lowPass = new Tone.Filter(18000, 'lowpass');
17453
- this.highPass = new Tone.Filter(5, 'highpass');
17454
- Tone.Destination.chain(this.lowPass, this.highPass, this.gain);
17480
+ this.lowPassF = new Tone.Filter(18000, 'lowpass');
17481
+ this.highPassF = new Tone.Filter(5, 'highpass');
17482
+ Tone.Destination.chain(this.lowPassF, this.highPassF, this.gain);
17455
17483
 
17456
17484
  // a recorder for the sound
17457
17485
  this.recorder = new Tone.Recorder({ mimeType: 'audio/webm' });
17458
17486
  this.gain.connect(this.recorder);
17459
17487
 
17488
+ // default settings
17489
+ this.setBPM(100);
17490
+ this.setVolume(1);
17491
+ this.setHighPass(18000);
17492
+ this.setLowPass(5);
17493
+ this.setCrossFade(250);
17494
+
17495
+ // load the buffers from the github
17460
17496
  this.buffers = new Tone.ToneAudioBuffers({
17461
17497
  urls: this.samples,
17462
17498
  baseUrl: "https://raw.githubusercontent.com/tmhglnd/mercury-playground/main/public/assets/samples/",
17463
17499
  onload: () => {
17464
17500
  console.log('Samples loaded', this.buffers);
17465
17501
  // executes a callback from the class constructor
17502
+ // if a callback is provided
17466
17503
  if (onload){ onload(); }
17467
17504
  }
17468
17505
  });
17506
+
17507
+ // the midi status, inputs and outputs
17508
+ this.midi = { enabled: false, inputs: [], outputs: [] };
17509
+
17510
+ // WebMIDI Setup if supported by the browser
17511
+ // Else `midi` not supported in the Mercury code
17512
+ WebMidi.enable((error) => {
17513
+ if (error) {
17514
+ console.error(`WebMIDI not enabled: ${error}`);
17515
+ } else {
17516
+ this.midi.enabled = true;
17517
+
17518
+ console.log(`WebMIDI enabled`);
17519
+ if (WebMidi.inputs.length < 1){
17520
+ console.log(`No MIDI device detected`);
17521
+ } else {
17522
+ this.midi.inputs = WebMidi.inputs;
17523
+ this.midi.outputs = WebMidi.outputs;
17524
+
17525
+ WebMidi.inputs.forEach((device, index) => {
17526
+ console.log(`in ${index}: ${device.name}`);
17527
+ });
17528
+ WebMidi.outputs.forEach((device, index) => {
17529
+ console.log(`out ${index}: ${device.name}`);
17530
+ });
17531
+ }
17532
+ // execute a callback when midi is loaded if provided
17533
+ if (onmidi) { onmidi(); }
17534
+ }
17535
+ });
17469
17536
  }
17470
17537
 
17471
17538
  // resume webaudio and transport
@@ -17520,7 +17587,7 @@ class Mercury extends MercuryInterpreter {
17520
17587
 
17521
17588
  // add files to the buffer from a single File Link
17522
17589
  // an array or file paths, or a json of { name:file, ... }
17523
- async addSamples(uploads){
17590
+ async addBuffers(uploads){
17524
17591
  // for every file from uploads
17525
17592
  uploads.forEach((f) => {
17526
17593
  let n = f;
@@ -17561,7 +17628,7 @@ class Mercury extends MercuryInterpreter {
17561
17628
 
17562
17629
  // add to ToneAudioBuffers
17563
17630
  this.buffers.add(n, url, () => {
17564
- console.log(`sound added as: ${n}`);
17631
+ Util.log(`sound added as: ${n}`);
17565
17632
  URL.revokeObjectURL(url);
17566
17633
 
17567
17634
  // also add soundfiles to menu for easy selection
@@ -17570,7 +17637,7 @@ class Mercury extends MercuryInterpreter {
17570
17637
  // o.value = o.innerHTML = n;
17571
17638
  // m.appendChild(o);
17572
17639
  }, (e) => {
17573
- console.log(`error adding sound from: ${n}`);
17640
+ Util.log(`error adding sound from: ${n}`);
17574
17641
  });
17575
17642
  }
17576
17643
 
@@ -17608,19 +17675,21 @@ class Mercury extends MercuryInterpreter {
17608
17675
 
17609
17676
  // set lowpass frequency cutoff and ramptime
17610
17677
  setLowPass(f, t=0){
17678
+ this.lowPass = f;
17611
17679
  if (t > 0){
17612
- this.lowPass.frequency.rampTo(f, t/1000, Tone.now());
17680
+ this.lowPassF.frequency.rampTo(f, t/1000, Tone.now());
17613
17681
  } else {
17614
- this.lowPass.frequency.setValueAtTime(f, Tone.now());
17682
+ this.lowPassF.frequency.setValueAtTime(f, Tone.now());
17615
17683
  }
17616
17684
  }
17617
17685
 
17618
17686
  // set highpass frequency cutoff and ramptime
17619
17687
  setHighPass(f, t=0){
17688
+ this.highPass = f;
17620
17689
  if (t > 0){
17621
- this.highPass.frequency.rampTo(f, t/1000, Tone.now());
17690
+ this.highPassF.frequency.rampTo(f, t/1000, Tone.now());
17622
17691
  } else {
17623
- this.highPass.frequency.setValueAtTime(f, Tone.now());
17692
+ this.highPassF.frequency.setValueAtTime(f, Tone.now());
17624
17693
  }
17625
17694
  }
17626
17695
 
@@ -17658,7 +17727,7 @@ class Mercury extends MercuryInterpreter {
17658
17727
  anchor.click();
17659
17728
  }
17660
17729
  } catch(e) {
17661
- console.log(`Error starting/stopping recording ${e}`);
17730
+ Util.log(`Error starting/stopping recording ${e}`);
17662
17731
  }
17663
17732
  }
17664
17733
 
@@ -17668,5 +17737,5 @@ class Mercury extends MercuryInterpreter {
17668
17737
  }
17669
17738
  }
17670
17739
  module.exports = { Mercury };
17671
- },{"./interpreter":68,"tone":44}]},{},[69])(69)
17740
+ },{"./core/Util.js":66,"./interpreter":68,"tone":44,"webmidi":55}]},{},[69])(69)
17672
17741
  });