mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-26 13:08:28 +00:00
playing
This commit is contained in:
parent
f5c7b58b3a
commit
f62b268f1d
@ -27,7 +27,7 @@ const noises = ['pink', 'white', 'brown', 'crackle'];
|
|||||||
export function registerSynthSounds() {
|
export function registerSynthSounds() {
|
||||||
registerSound('bet', (t, value, onended) => {
|
registerSound('bet', (t, value, onended) => {
|
||||||
const ac = getAudioContext();
|
const ac = getAudioContext();
|
||||||
let { note, freq } = value;
|
let { note, freq, duration, cps } = value;
|
||||||
note = note || 36;
|
note = note || 36;
|
||||||
if (typeof note === 'string') {
|
if (typeof note === 'string') {
|
||||||
note = noteToMidi(note); // e.g. c3 => 48
|
note = noteToMidi(note); // e.g. c3 => 48
|
||||||
@ -40,19 +40,12 @@ export function registerSynthSounds() {
|
|||||||
// set frequency
|
// set frequency
|
||||||
freq = Number(freq);
|
freq = Number(freq);
|
||||||
|
|
||||||
const node = getWorklet(ac, 'better-oscillator', { frequency: freq });
|
const node = getWorklet(ac, 'better-oscillator', { frequency: freq, start: t, end: t + duration * cps });
|
||||||
const o = ac.createOscillator();
|
|
||||||
o.start(t);
|
|
||||||
o.onended = () => {
|
|
||||||
console.log('here');
|
|
||||||
o.disconnect();
|
|
||||||
node.disconnect();
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
node,
|
node,
|
||||||
stop: (time) => {
|
stop: (time) => {
|
||||||
o.stop(time);
|
// o.stop(time);
|
||||||
},
|
},
|
||||||
triggerRelease: (time) => {
|
triggerRelease: (time) => {
|
||||||
// envGain?.stop(time);
|
// envGain?.stop(time);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user