mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-14 23:28:30 +00:00
add chord voicings
This commit is contained in:
parent
f15686ba0f
commit
70dea049ae
17
repl/package-lock.json
generated
17
repl/package-lock.json
generated
@ -6,6 +6,7 @@
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@tonaljs/tonal": "^4.6.5",
|
||||
"chord-voicings": "^0.0.1",
|
||||
"codemirror": "^5.65.1",
|
||||
"estraverse": "^5.3.0",
|
||||
"multimap": "^1.1.0",
|
||||
@ -2759,6 +2760,14 @@
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/chord-voicings": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/chord-voicings/-/chord-voicings-0.0.1.tgz",
|
||||
"integrity": "sha512-SutgB/4ynkkuiK6qdQ/k3QvCFcH0Vj8Ch4t6LbRyRQbVzP/TOztiCk3kvXd516UZ6fqk7ijDRELEFcKN+6V8sA==",
|
||||
"dependencies": {
|
||||
"@tonaljs/tonal": "^4.6.5"
|
||||
}
|
||||
},
|
||||
"node_modules/chownr": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
|
||||
@ -10966,6 +10975,14 @@
|
||||
"readdirp": "~3.6.0"
|
||||
}
|
||||
},
|
||||
"chord-voicings": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/chord-voicings/-/chord-voicings-0.0.1.tgz",
|
||||
"integrity": "sha512-SutgB/4ynkkuiK6qdQ/k3QvCFcH0Vj8Ch4t6LbRyRQbVzP/TOztiCk3kvXd516UZ6fqk7ijDRELEFcKN+6V8sA==",
|
||||
"requires": {
|
||||
"@tonaljs/tonal": "^4.6.5"
|
||||
}
|
||||
},
|
||||
"chownr": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@tonaljs/tonal": "^4.6.5",
|
||||
"chord-voicings": "^0.0.1",
|
||||
"codemirror": "^5.65.1",
|
||||
"estraverse": "^5.3.0",
|
||||
"multimap": "^1.1.0",
|
||||
|
||||
@ -3,6 +3,7 @@ import * as strudel from '../../strudel.mjs';
|
||||
import { Scale, Note, Interval } from '@tonaljs/tonal';
|
||||
import './tone';
|
||||
import './midi';
|
||||
import './voicings';
|
||||
import * as toneStuff from './tone';
|
||||
import shapeshifter from './shapeshifter';
|
||||
|
||||
|
||||
28
repl/src/voicings.ts
Normal file
28
repl/src/voicings.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Pattern as _Pattern, stack, TimeSpan, Hap } from '../../strudel.mjs';
|
||||
import voicings from 'chord-voicings';
|
||||
const { dictionaryVoicing, minTopNoteDiff, lefthand } = voicings;
|
||||
|
||||
const getVoicing = (chord, lastVoicing, range = ['F3', 'A4']) =>
|
||||
dictionaryVoicing({
|
||||
chord,
|
||||
dictionary: lefthand,
|
||||
range,
|
||||
picker: minTopNoteDiff,
|
||||
lastVoicing,
|
||||
});
|
||||
|
||||
const Pattern = _Pattern as any;
|
||||
|
||||
Pattern.prototype.voicings = function (range = ['F3', 'A4']) {
|
||||
let lastVoicing;
|
||||
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));
|
||||
})
|
||||
.flat()
|
||||
);
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user