mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-13 06:19:33 -04:00
piano
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
Sampler,
|
||||
getDestination
|
||||
} from 'tone';
|
||||
import { Piano } from '@tonejs/piano';
|
||||
|
||||
// what about
|
||||
// https://www.charlie-roberts.com/gibberish/playground/
|
||||
@@ -33,6 +34,9 @@ Pattern.prototype.tone = function (instrument) {
|
||||
instrument.triggerAttack(event.value, time);
|
||||
} else if (instrument.constructor.name === 'NoiseSynth') {
|
||||
instrument.triggerAttackRelease(event.duration, time); // noise has no value
|
||||
} else if (instrument.constructor.name === 'Piano') {
|
||||
instrument.keyDown({ note: event.value, time, velocity: 0.5 });
|
||||
instrument.keyUp({ note: event.value, time: time + event.duration });
|
||||
} else {
|
||||
instrument.triggerAttackRelease(event.value, event.duration, time);
|
||||
}
|
||||
@@ -55,6 +59,11 @@ export const pluck = (options) => new PluckSynth(options);
|
||||
export const polysynth = (options) => new PolySynth(options);
|
||||
export const sampler = (options) => new Sampler(options);
|
||||
export const synth = (options) => new Synth(options);
|
||||
export const piano = async (options = { velocities: 1 }) => {
|
||||
const p = new Piano(options);
|
||||
await p.load();
|
||||
return p;
|
||||
};
|
||||
|
||||
// effect helpers
|
||||
export const vol = (v) => new Gain(v);
|
||||
|
||||
Reference in New Issue
Block a user