mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-13 14:26:58 -04:00
add tranpose method
This commit is contained in:
@@ -4,6 +4,7 @@ import { Scale, Note, Interval } from '@tonaljs/tonal';
|
||||
import './tone';
|
||||
import './midi';
|
||||
import './voicings';
|
||||
import './tonal';
|
||||
import * as toneStuff from './tone';
|
||||
import shapeshifter from './shapeshifter';
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Note, Interval } from '@tonaljs/tonal';
|
||||
import { Pattern as _Pattern } from '../../strudel.mjs';
|
||||
|
||||
const Pattern = _Pattern as any;
|
||||
|
||||
Pattern.prototype._transpose = function (intervalOrSemitones: string | number) {
|
||||
const interval = !isNaN(Number(intervalOrSemitones))
|
||||
? Interval.fromSemitones(intervalOrSemitones as number)
|
||||
: String(intervalOrSemitones);
|
||||
return this.fmap((note) => Note.transpose(note, interval));
|
||||
};
|
||||
|
||||
Pattern.prototype.transpose = function (intervalOrSemitones: string | number) {
|
||||
return this._patternify(Pattern.prototype._transpose)(intervalOrSemitones);
|
||||
};
|
||||
@@ -16,11 +16,11 @@ const Pattern = _Pattern as any;
|
||||
Pattern.prototype.fmapNested = function (func) {
|
||||
return new Pattern((span) =>
|
||||
this.query(span)
|
||||
.map((event) => {
|
||||
return reify(func(event))
|
||||
.map((event) =>
|
||||
reify(func(event))
|
||||
.query(span)
|
||||
.map((hap) => new Hap(event.whole, event.part, hap.value));
|
||||
})
|
||||
.map((hap) => new Hap(event.whole, event.part, hap.value))
|
||||
)
|
||||
.flat()
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user