add makeComposable for chainable composition
- only used with transpose so far
This commit is contained in:
parent
22baae10dd
commit
2f164649b9
5 changed files with 60 additions and 6 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Note, Interval, Scale } from '@tonaljs/tonal';
|
||||
import { Pattern as _Pattern, curry } from '../../strudel.mjs';
|
||||
import { Pattern as _Pattern, curry, makeComposable } from '../../strudel.mjs';
|
||||
|
||||
const Pattern = _Pattern as any;
|
||||
|
||||
|
|
@ -75,10 +75,15 @@ Pattern.prototype._transpose = function (intervalOrSemitones: string | number) {
|
|||
});
|
||||
};
|
||||
|
||||
// TODO: find out how to patternify this function when it's standalone
|
||||
// example: transpose(3).late(0.2) will be equivalent to compose(transpose(3), late(0.2))
|
||||
export const transpose = curry(
|
||||
(a, pat) => pat.transpose(a),
|
||||
(partial) => makeComposable(partial)
|
||||
);
|
||||
// TODO: add Pattern.define(name, function, options) that handles all the meta programming stuff
|
||||
// TODO: find out how to patternify this function when it's standalone
|
||||
// e.g. `stack(c3).superimpose(transpose(slowcat(7, 5)))` or
|
||||
// or even `stack(c3).superimpose(transpose.slowcat(7, 5))` or
|
||||
export const transpose = curry((a, pat) => pat.transpose(a))
|
||||
|
||||
Pattern.prototype._scaleTranspose = function (offset: number | string) {
|
||||
return this._mapNotes(({ value, scale }: NoteEvent) => {
|
||||
|
|
@ -93,4 +98,4 @@ Pattern.prototype._scale = function (scale: string) {
|
|||
};
|
||||
|
||||
Pattern.prototype.patternified = Pattern.prototype.patternified.concat(['transpose', 'scaleTranspose', 'scale']);
|
||||
// Object.assign(Pattern.prototype.modifiers, { transpose })
|
||||
Object.assign(Pattern.prototype.composable, { transpose });
|
||||
|
|
|
|||
|
|
@ -363,4 +363,16 @@ export const confusedPhoneDynamic = `stack('[g2 ~@1.3] [c3 ~@1.3]'.mini.slow(2))
|
|||
.scaleTranspose(slowcat(0,1,2,1).slow(2))
|
||||
.synth('triangle').gain(0.2).filter(1500)`;
|
||||
|
||||
export const confusedPhonePartial = `stack('[g2 ~@1.3] [c3 ~@1.3]'.mini.slow(2))
|
||||
.superimpose(
|
||||
transpose(-12).late(0),
|
||||
transpose(7).late(0.2),
|
||||
transpose(10).late(0.4),
|
||||
transpose(12).late(0.6),
|
||||
transpose(24).late(0.8)
|
||||
)
|
||||
.scale(sequence('C dorian', 'C mixolydian').slow(4))
|
||||
.scaleTranspose(slowcat(0,1,2,1).slow(2))
|
||||
.synth('triangle').gain(0.2).filter(1500)`;
|
||||
|
||||
export default swimming;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue