Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
schedule(start, stop, note, envelopeMode) {
const osc = context.createOscillator();
osc.type = typeMap[this.type.next()];
let noteMidiValue = typeof note === 'string' ? Note.midi(note) : note;
osc.frequency.setValueAtTime(
Note.freq(Note.fromMidi(noteMidiValue + this.detune.next())),
context.currentTime,
0
);
osc.start(start);
// Envelope mode is a flag that an ADSR envelope will pass
// into Osc if it is controlling this Block. This is the
// only reasonable way to solve the problem of the envelope
// needing to control the stop time.
if (!envelopeMode) osc.stop(stop);
osc.onended = () => {
osc.disconnect();
};
// Envelope mode returns the osc without setting stop, while
(currentLowest, note) =>
Note.freq(note) < Note.freq(currentLowest) ? note : currentLowest,
Infinity
(currentHighest, note) =>
Note.freq(note) > Note.freq(currentHighest) ? note : currentHighest,
-Infinity
(currentHighest, note) =>
Note.freq(note) > Note.freq(currentHighest) ? note : currentHighest,
-Infinity
({ samples }) => {
if (Tone.context !== audioContext) {
Tone.setContext(audioContext);
}
const noise = new Tone.Noise('brown');
const eq = new Tone.EQ3(-15, -Infinity, -Infinity).connect(destination);
eq.lowFrequency.value = Note.freq('C1');
const lfo = new Tone.LFO({
min: -50,
max: -15,
frequency: Math.random() / 100,
phase: 45,
});
lfo.connect(eq.low);
noise.connect(eq);
lfo.start();
const delay1 = new Tone.FeedbackDelay({
feedback: 0.7,
delayTime: 0.2,
wet: 0.5,
});
const delay2 = new Tone.FeedbackDelay({
(currentLowest, note) =>
Note.freq(note) < Note.freq(currentLowest) ? note : currentLowest,
Infinity