add tranpose method
This commit is contained in:
parent
016d5c5ef4
commit
3d0d526051
3 changed files with 20 additions and 4 deletions
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);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue