build tutorial

This commit is contained in:
Felix Roos 2022-02-19 21:20:36 +01:00
parent f0a96ba75d
commit 8339d18e0a
5 changed files with 81 additions and 37 deletions

14
docs/dist/tonal.js vendored
View file

@ -18,7 +18,8 @@ export function intervalDirection(from, to, direction = 1) {
}
function scaleTranspose(scale, offset, note) {
let [tonic, scaleName] = Scale.tokenize(scale);
const {notes} = Scale.get(`${tonic} ${scaleName}`);
let {notes} = Scale.get(`${tonic} ${scaleName}`);
notes = notes.map((note2) => Note.get(note2).pc);
offset = Number(offset);
if (isNaN(offset)) {
throw new Error(`scale offset "${offset}" not a number`);
@ -64,7 +65,16 @@ Pattern.prototype._scaleTranspose = function(offset) {
});
};
Pattern.prototype._scale = function(scale) {
return this._mapNotes((value) => ({...value, scale}));
return this._mapNotes((value) => {
let note = value.value;
const asNumber = Number(note);
if (!isNaN(asNumber)) {
let [tonic, scaleName] = Scale.tokenize(scale);
const {pc, oct = 3} = Note.get(tonic);
note = scaleTranspose(pc + " " + scaleName, asNumber, pc + oct);
}
return {...value, value: note, scale};
});
};
Pattern.prototype.define("transpose", (a, pat) => pat.transpose(a), {composable: true, patternified: true});
Pattern.prototype.define("scale", (a, pat) => pat.scale(a), {composable: true, patternified: true});

12
docs/dist/voicings.js vendored
View file

@ -22,16 +22,14 @@ Pattern.prototype.voicings = function(range) {
return stack(...lastVoicing);
});
};
Pattern.prototype.chordBass = function() {
Pattern.prototype.rootNotes = function(octave = 2) {
return this._mapNotes((value) => {
console.log("value", value);
const [_, root] = value.value.match(/^([a-gC-G])[b#]?.*$/);
const bassNote = root + "2";
const [_, root] = value.value.match(/^([a-gA-G])[b#]?.*$/);
const bassNote = root + octave;
return {...value, value: bassNote};
});
};
Pattern.prototype.define("voicings", (range, pat) => pat.voicings(range), {composable: true});
Pattern.prototype.define("chordBass", (pat) => {
console.log("call chordBass ...", pat);
return pat.chordBass();
Pattern.prototype.define("rootNotes", (pat) => {
return pat.rootNotes();
}, {composable: true});