This commit is contained in:
Felix Roos 2022-03-24 23:57:32 +01:00
parent b1cde584bf
commit a19d789145
7 changed files with 70 additions and 13 deletions

View File

@ -539,11 +539,11 @@ class Pattern {
stut(times, feedback, time) { stut(times, feedback, time) {
return this.stutWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i))); return this.stutWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i)));
} }
echoWith(times, time, func) { _echoWith(times, time, func) {
return stack(...range(0, times - 1).map((i) => func(this.late(i * time), i))); return stack(...range(0, times - 1).map((i) => func(this.late(i * time), i)));
} }
echo(times, time, feedback) { _echo(times, time, feedback) {
return this.echoWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i))); return this._echoWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i)));
} }
iter(times) { iter(times) {
return slowcat(...range(0, times - 1).map((i) => this.early(i / times))); return slowcat(...range(0, times - 1).map((i) => this.early(i / times)));
@ -731,6 +731,17 @@ export function makeComposable(func) {
}); });
return func; return func;
} }
const patternify2 = (f) => (pata, patb, pat) => pata.fmap((a) => (b) => f.call(pat, a, b)).appLeft(patb).outerJoin();
const patternify3 = (f) => (pata, patb, patc, pat) => pata.fmap((a) => (b) => (c) => f.call(pat, a, b, c)).appLeft(patb).appLeft(patc).outerJoin();
const patternify4 = (f) => (pata, patb, patc, patd, pat) => pata.fmap((a) => (b) => (c) => (d) => f.call(pat, a, b, c, d)).appLeft(patb).appLeft(patc).appLeft(patd).outerJoin();
Pattern.prototype.echo = function(...args) {
args = args.map(reify);
return patternify3(Pattern.prototype._echo)(...args, this);
};
Pattern.prototype.echoWith = function(...args) {
args = args.map(reify);
return patternify3(Pattern.prototype._echoWith)(...args, this);
};
Pattern.prototype.bootstrap = function() { Pattern.prototype.bootstrap = function() {
const bootstrapped = Object.fromEntries(Object.entries(Pattern.prototype.composable).map(([functionName, composable]) => { const bootstrapped = Object.fromEntries(Object.entries(Pattern.prototype.composable).map(([functionName, composable]) => {
if (Pattern.prototype[functionName]) { if (Pattern.prototype[functionName]) {

4
docs/dist/App.js vendored
View File

@ -45,8 +45,8 @@ function App() {
} }
} }
}; };
document.addEventListener("keypress", handleKeyPress); window.addEventListener("keydown", handleKeyPress);
return () => document.removeEventListener("keypress", handleKeyPress); return () => window.removeEventListener("keydown", handleKeyPress);
}, [pattern, code]); }, [pattern, code]);
useWebMidi({ useWebMidi({
ready: useCallback(({outputs}) => { ready: useCallback(({outputs}) => {

View File

@ -29,7 +29,7 @@ function hackLiteral(literal, names, func) {
} }
hackLiteral(String, ["mini", "m"], bootstrapped.mini); hackLiteral(String, ["mini", "m"], bootstrapped.mini);
hackLiteral(String, ["pure", "p"], bootstrapped.pure); hackLiteral(String, ["pure", "p"], bootstrapped.pure);
Object.assign(globalThis, bootstrapped, Tone, toneHelpers, voicingHelpers, drawHelpers, uiHelpers, { Object.assign(globalThis, Tone, bootstrapped, toneHelpers, voicingHelpers, drawHelpers, uiHelpers, {
gist, gist,
euclid, euclid,
mini mini

29
docs/dist/tunes.js vendored
View File

@ -601,3 +601,32 @@ stack(
"mad".slow(2).tone(breaks) "mad".slow(2).tone(breaks)
).cpm(78).slow(4).pianoroll() ).cpm(78).slow(4).pianoroll()
`; `;
export const goodTimes = `const scale = slowcat('C3 dorian','Bb2 major').slow(4);
stack(
"2*4".add(12).scale(scale)
.off(1/8,x=>x.scaleTranspose("2")).fast(2)
.scaleTranspose("<0 1 2 1>").hush(),
"<0 1 2 3>(3,8,2)"
.scale(scale)
.off(1/4,x=>x.scaleTranspose("2,4")),
"<0 4>(5,8)".scale(scale).transpose(-12)
)
.velocity(".6 .7".fast(4))
.legato("2")
.scale(scale)
.scaleTranspose("<0>".slow(4))
.tone((await piano()).chain(out()))
//.midi()
.velocity(.8)
.transpose(5)
.slow(2)
.pianoroll({maxMidi:100,minMidi:20})`;
export const echoPiano = `"<0 2 [4 6](3,4,1) 3*2>"
.scale('D minor')
.color('salmon')
.off(1/4, x=>x.scaleTranspose(2).color('green'))
.off(1/2, x=>x.scaleTranspose(6).color('steelblue'))
.legato(.5)
.echo(4, 1/8, .5)
.tone((await piano()).chain(out()))
.pianoroll()`;

View File

@ -42013,7 +42013,7 @@ hackLiteral(String, [
'p' 'p'
], bootstrapped.pure); // comment out this line if you panic ], bootstrapped.pure); // comment out this line if you panic
// this will add everything to global scope, which is accessed by eval // this will add everything to global scope, which is accessed by eval
Object.assign(globalThis, bootstrapped, _tone1, _tone, _voicings, _drawMjs, _uiMjs, { Object.assign(globalThis, _tone1, bootstrapped, _tone, _voicings, _drawMjs, _uiMjs, {
gist: _gistJsDefault.default, gist: _gistJsDefault.default,
euclid: _euclidMjsDefault.default, euclid: _euclidMjsDefault.default,
mini: _parse.mini mini: _parse.mini
@ -42847,12 +42847,12 @@ class Pattern {
); );
} }
// these might change with: https://github.com/tidalcycles/Tidal/issues/902 // these might change with: https://github.com/tidalcycles/Tidal/issues/902
echoWith(times, time, func) { _echoWith(times, time, func) {
return stack(...range(0, times - 1).map((i)=>func(this.late(i * time), i) return stack(...range(0, times - 1).map((i)=>func(this.late(i * time), i)
)); ));
} }
echo(times, time, feedback) { _echo(times, time, feedback) {
return this.echoWith(times, time, (pat, i)=>pat.velocity(Math.pow(feedback, i)) return this._echoWith(times, time, (pat, i)=>pat.velocity(Math.pow(feedback, i))
); );
} }
iter(times) { iter(times) {
@ -43144,6 +43144,23 @@ function makeComposable(func) {
}); });
return func; return func;
} }
const patternify2 = (f)=>(pata, patb, pat)=>pata.fmap((a)=>(b)=>f.call(pat, a, b)
).appLeft(patb).outerJoin()
;
const patternify3 = (f)=>(pata, patb, patc, pat)=>pata.fmap((a)=>(b)=>(c)=>f.call(pat, a, b, c)
).appLeft(patb).appLeft(patc).outerJoin()
;
const patternify4 = (f)=>(pata, patb, patc, patd, pat)=>pata.fmap((a)=>(b)=>(c)=>(d)=>f.call(pat, a, b, c, d)
).appLeft(patb).appLeft(patc).appLeft(patd).outerJoin()
;
Pattern.prototype.echo = function(...args) {
args = args.map(reify);
return patternify3(Pattern.prototype._echo)(...args, this);
};
Pattern.prototype.echoWith = function(...args) {
args = args.map(reify);
return patternify3(Pattern.prototype._echoWith)(...args, this);
};
// call this after all Patter.prototype.define calls have been executed! (right before evaluate) // call this after all Patter.prototype.define calls have been executed! (right before evaluate)
Pattern.prototype.bootstrap = function() { Pattern.prototype.bootstrap = function() {
// makeComposable(Pattern.prototype); // makeComposable(Pattern.prototype);
@ -183357,4 +183374,4 @@ exports.default = cx;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}]},["3uVTb"], "3uVTb", "parcelRequire94c2") },{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}]},["3uVTb"], "3uVTb", "parcelRequire94c2")
//# sourceMappingURL=index.fbb7f699.js.map //# sourceMappingURL=index.1d7e465c.js.map

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,6 @@
<body> <body>
<div id="root"></div> <div id="root"></div>
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>You need to enable JavaScript to run this app.</noscript>
<script src="/tutorial/index.fbb7f699.js" defer=""></script> <script src="/tutorial/index.1d7e465c.js" defer=""></script>
</body> </body>
</html> </html>