mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-25 04:28:30 +00:00
dont use tone audio context
This commit is contained in:
parent
c1e934d171
commit
faa4019b27
@ -7,9 +7,18 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||||||
// import { Pattern, getFrequency, patternify2 } from '@strudel.cycles/core';
|
// import { Pattern, getFrequency, patternify2 } from '@strudel.cycles/core';
|
||||||
import * as strudel from '@strudel.cycles/core';
|
import * as strudel from '@strudel.cycles/core';
|
||||||
import { fromMidi } from '@strudel.cycles/core';
|
import { fromMidi } from '@strudel.cycles/core';
|
||||||
import { Tone } from '@strudel.cycles/tone';
|
|
||||||
const { Pattern } = strudel;
|
const { Pattern } = strudel;
|
||||||
|
|
||||||
|
// export const getAudioContext = () => Tone.getContext().rawContext;
|
||||||
|
|
||||||
|
let audioContext;
|
||||||
|
export const getAudioContext = () => {
|
||||||
|
if (!audioContext) {
|
||||||
|
audioContext = new AudioContext();
|
||||||
|
}
|
||||||
|
return audioContext;
|
||||||
|
};
|
||||||
|
|
||||||
const getFilter = (ac, type, frequency, Q) => {
|
const getFilter = (ac, type, frequency, Q) => {
|
||||||
const filter = ac.createBiquadFilter();
|
const filter = ac.createBiquadFilter();
|
||||||
filter.type = type;
|
filter.type = type;
|
||||||
@ -31,7 +40,7 @@ const getADSR = (ac, attack, decay, sustain, release, velocity, begin, end) => {
|
|||||||
|
|
||||||
Pattern.prototype.out = function () {
|
Pattern.prototype.out = function () {
|
||||||
return this.onTrigger((t, hap, ct) => {
|
return this.onTrigger((t, hap, ct) => {
|
||||||
const ac = Tone.getContext().rawContext;
|
const ac = getAudioContext();
|
||||||
// calculate correct time (tone.js workaround)
|
// calculate correct time (tone.js workaround)
|
||||||
t = ac.currentTime + t - ct;
|
t = ac.currentTime + t - ct;
|
||||||
// destructure value
|
// destructure value
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user