Merge pull request #185 from bpow/mini-notation-random-offsets
change "stride"/"offset" of successive degradeBy/chooseIn
This commit is contained in:
commit
4d8adde9d5
2 changed files with 7 additions and 6 deletions
|
|
@ -11,6 +11,7 @@ import { addMiniLocations } from '@strudel.cycles/eval/shapeshifter.mjs';
|
||||||
const { pure, Pattern, Fraction, stack, slowcat, sequence, timeCat, silence, reify } = strudel;
|
const { pure, Pattern, Fraction, stack, slowcat, sequence, timeCat, silence, reify } = strudel;
|
||||||
|
|
||||||
var _seedState = 0;
|
var _seedState = 0;
|
||||||
|
const randOffset = 0.0002;
|
||||||
|
|
||||||
function _nextSeed() {
|
function _nextSeed() {
|
||||||
return _seedState++;
|
return _seedState++;
|
||||||
|
|
@ -28,7 +29,7 @@ const applyOptions = (parent) => (pat, i) => {
|
||||||
case 'bjorklund':
|
case 'bjorklund':
|
||||||
return pat.euclid(operator.arguments_.pulse, operator.arguments_.step, operator.arguments_.rotation);
|
return pat.euclid(operator.arguments_.pulse, operator.arguments_.step, operator.arguments_.rotation);
|
||||||
case 'degradeBy':
|
case 'degradeBy':
|
||||||
return reify(pat)._degradeByWith(strudel.rand.early(Math.PI * _nextSeed()).segment(1), operator.arguments_.amount);
|
return reify(pat)._degradeByWith(strudel.rand.early(randOffset * _nextSeed()).segment(1), operator.arguments_.amount);
|
||||||
// TODO: case 'fixed-step': "%"
|
// TODO: case 'fixed-step': "%"
|
||||||
}
|
}
|
||||||
console.warn(`operator "${operator.type_}" not implemented`);
|
console.warn(`operator "${operator.type_}" not implemented`);
|
||||||
|
|
@ -91,7 +92,7 @@ export function patternifyAST(ast) {
|
||||||
return stack(...children);
|
return stack(...children);
|
||||||
}
|
}
|
||||||
if (alignment === 'r') {
|
if (alignment === 'r') {
|
||||||
return strudel.chooseInWith(strudel.rand.early(Math.PI * _nextSeed()).segment(1), children);
|
return strudel.chooseInWith(strudel.rand.early(randOffset * _nextSeed()).segment(1), children);
|
||||||
}
|
}
|
||||||
const weightedChildren = ast.source_.some((child) => !!child.options_?.weight);
|
const weightedChildren = ast.source_.some((child) => !!child.options_?.weight);
|
||||||
if (!weightedChildren && alignment === 't') {
|
if (!weightedChildren && alignment === 't') {
|
||||||
|
|
|
||||||
|
|
@ -318,10 +318,10 @@ exports[`renders tunes > tune: bossa 1`] = `
|
||||||
|
|
||||||
exports[`renders tunes > tune: bossaRandom 1`] = `
|
exports[`renders tunes > tune: bossaRandom 1`] = `
|
||||||
[
|
[
|
||||||
"0/1 -> 1/2: {\\"note\\":\\"G4\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5601851851851851}",
|
"0/1 -> 1/4: {\\"note\\":\\"G4\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5601851851851851}",
|
||||||
"0/1 -> 1/2: {\\"note\\":\\"B4\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5787037037037037}",
|
"0/1 -> 1/4: {\\"note\\":\\"B4\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5787037037037037}",
|
||||||
"0/1 -> 1/2: {\\"note\\":\\"C5\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5833333333333333}",
|
"0/1 -> 1/4: {\\"note\\":\\"C5\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5833333333333333}",
|
||||||
"0/1 -> 1/2: {\\"note\\":\\"E5\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.6018518518518519}",
|
"0/1 -> 1/4: {\\"note\\":\\"E5\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.6018518518518519}",
|
||||||
"3/4 -> 1/1: {\\"note\\":\\"G4\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5601851851851851}",
|
"3/4 -> 1/1: {\\"note\\":\\"G4\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5601851851851851}",
|
||||||
"3/4 -> 1/1: {\\"note\\":\\"B4\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5787037037037037}",
|
"3/4 -> 1/1: {\\"note\\":\\"B4\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5787037037037037}",
|
||||||
"3/4 -> 1/1: {\\"note\\":\\"C5\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5833333333333333}",
|
"3/4 -> 1/1: {\\"note\\":\\"C5\\",\\"clip\\":1,\\"s\\":\\"piano\\",\\"pan\\":0.5833333333333333}",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue