start packaging

This commit is contained in:
Felix Roos 2022-03-25 14:39:25 +01:00
parent a19d789145
commit 6f60a3a1d5
98 changed files with 11162 additions and 11122 deletions

16
packages/xen/tune.mjs Normal file
View file

@ -0,0 +1,16 @@
import Tune from './tunejs.js';
import { Pattern } from '../core/strudel.mjs';
Pattern.prototype._tune = function (scale, tonic = 220) {
const tune = new Tune();
if (!tune.isValidScale(scale)) {
throw new Error('not a valid tune.js scale name: "' + scale + '". See http://abbernie.github.io/tune/scales.html');
}
tune.loadScale(scale);
tune.tonicize(tonic);
return this._asNumber()._withEvent((event) => {
return event.withValue(() => tune.note(event.value)).setContext({ ...event.context, type: 'frequency' });
});
};
Pattern.prototype.define('tune', (scale, pat) => pat.tune(scale), { composable: true, patternified: true });