standardise on hap rather than event, especially in function names
This commit is contained in:
parent
b0dfb44e96
commit
f8f744dd87
13 changed files with 159 additions and 153 deletions
|
|
@ -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' });
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue