This commit is contained in:
Felix Roos 2022-02-12 22:56:41 +01:00
parent ffffca8cdc
commit a0c09f7575
4 changed files with 175 additions and 136 deletions

23
docs/dist/tunes.js vendored
View file

@ -231,4 +231,27 @@ export const swimming = `stack(
)
).slow(51);
`;
export const giantSteps = `stack(
// melody
sequence(
[['F#5', 'D5'], ['B4','G4'], 'Bb4', ['B4','A4']],
[['D5', 'Bb4'], ['G4', 'Eb4'], 'F#4', ['G4','F4']],
['Bb4', ['B4', 'A4'], 'D5', ['D#5', 'C#5']],
['F#5', ['G5', 'F5'], 'Bb5', ['F#5', 'F#5']],
),
// chords
sequence(
[['B^7', 'D7'], ['G^7', 'Bb7'], 'Eb^7', ['Am7', 'D7']],
[['G^7', 'Bb7'], ['Eb^7', 'F#7'], 'B^7', ['Fm7', 'Bb7']],
['Eb^7', ['Am7', 'D7'], 'G^7', ['C#m7', 'F#7']],
['B^7', ['Fm7', 'Bb7'], 'Eb^7', ['C#m7', 'F#7']]
).voicings(['E3', 'G4']),
// bass
sequence(
[['B2', 'D2'], ['G2', 'Bb2'], ['Eb2', 'Bb3'], ['A2', 'D2']],
[['G2', 'Bb2'], ['Eb2', 'F#2'], ['B2', 'F#2'], ['F2', 'Bb2']],
[['Eb2','Bb2'], ['A2', 'D2'], ['G2', 'D2'], ['C#2', 'F#2']],
[['B2', 'F#2'], ['F2', 'Bb2'], ['Eb2', 'Bb3'], ['C#2', 'F#2']]
)
).slow(20);`;
export default swimming;

15
docs/dist/voicings.js vendored
View file

@ -1,4 +1,4 @@
import {Pattern as _Pattern, stack, Hap} from "../_snowpack/link/strudel.js";
import {Pattern as _Pattern, stack, Hap, reify} from "../_snowpack/link/strudel.js";
import voicings from "../_snowpack/pkg/chord-voicings.js";
const {dictionaryVoicing, minTopNoteDiff, lefthand} = voicings;
const getVoicing = (chord, lastVoicing, range = ["F3", "A4"]) => dictionaryVoicing({
@ -9,10 +9,15 @@ const getVoicing = (chord, lastVoicing, range = ["F3", "A4"]) => dictionaryVoici
lastVoicing
});
const Pattern = _Pattern;
Pattern.prototype.voicings = function(range = ["F3", "A4"]) {
let lastVoicing;
Pattern.prototype.fmapNested = function(func) {
return new Pattern((span) => this.query(span).map((event) => {
lastVoicing = getVoicing(event.value, lastVoicing, range);
return stack(...lastVoicing).query(span).map((hap) => new Hap(event.whole, event.part, hap.value));
return reify(func(event)).query(span).map((hap) => new Hap(event.whole, event.part, hap.value));
}).flat());
};
Pattern.prototype.voicings = function(range = ["F3", "A4"]) {
let lastVoicing;
return this.fmapNested((event) => {
lastVoicing = getVoicing(event.value, lastVoicing, range);
return stack(...lastVoicing);
});
};