standardise on hap rather than event, especially in function names

This commit is contained in:
alex 2022-05-05 17:20:36 +01:00
parent b0dfb44e96
commit f8f744dd87
13 changed files with 159 additions and 153 deletions

View file

@ -14,8 +14,8 @@ Pattern.prototype._tune = function (scale, tonic = 220) {
}
tune.loadScale(scale);
tune.tonicize(tonic);
return this._asNumber()._withEvent((event) => {
return event.withValue(() => tune.note(event.value)).setContext({ ...event.context, type: 'frequency' });
return this._asNumber()._withHap((hap) => {
return hap.withValue(() => tune.note(hap.value)).setContext({ ...hap.context, type: 'frequency' });
});
};

View file

@ -49,18 +49,18 @@ function xenOffset(xenScale, offset, index = 0) {
// scaleNameOrRatios: string || number[], steps?: number
Pattern.prototype._xen = function (scaleNameOrRatios, steps) {
return this._asNumber()._withEvent((event) => {
return this._asNumber()._withHap((hap) => {
const scale = getXenScale(scaleNameOrRatios);
steps = steps || scale.length;
const frequency = xenOffset(scale, event.value);
return event.withValue(() => frequency).setContext({ ...event.context, type: 'frequency' });
const frequency = xenOffset(scale, hap.value);
return hap.withValue(() => frequency).setContext({ ...hap.context, type: 'frequency' });
});
};
Pattern.prototype.tuning = function (steps) {
return this._asNumber()._withEvent((event) => {
const frequency = xenOffset(steps, event.value);
return event.withValue(() => frequency).setContext({ ...event.context, type: 'frequency' });
return this._asNumber()._withHap((hap) => {
const frequency = xenOffset(steps, hap.value);
return hap.withValue(() => frequency).setContext({ ...hap.context, type: 'frequency' });
});
};
Pattern.prototype.define('xen', (scale, pat) => pat.xen(scale), { composable: true, patternified: true });