mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-27 05:28:41 +00:00
add tranpose method
This commit is contained in:
parent
016d5c5ef4
commit
3d0d526051
@ -4,6 +4,7 @@ import { Scale, Note, Interval } from '@tonaljs/tonal';
|
|||||||
import './tone';
|
import './tone';
|
||||||
import './midi';
|
import './midi';
|
||||||
import './voicings';
|
import './voicings';
|
||||||
|
import './tonal';
|
||||||
import * as toneStuff from './tone';
|
import * as toneStuff from './tone';
|
||||||
import shapeshifter from './shapeshifter';
|
import shapeshifter from './shapeshifter';
|
||||||
|
|
||||||
|
|||||||
15
repl/src/tonal.ts
Normal file
15
repl/src/tonal.ts
Normal file
@ -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) {
|
Pattern.prototype.fmapNested = function (func) {
|
||||||
return new Pattern((span) =>
|
return new Pattern((span) =>
|
||||||
this.query(span)
|
this.query(span)
|
||||||
.map((event) => {
|
.map((event) =>
|
||||||
return reify(func(event))
|
reify(func(event))
|
||||||
.query(span)
|
.query(span)
|
||||||
.map((hap) => new Hap(event.whole, event.part, hap.value));
|
.map((hap) => new Hap(event.whole, event.part, hap.value))
|
||||||
})
|
)
|
||||||
.flat()
|
.flat()
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user