This commit is contained in:
Felix Roos
2022-03-18 17:39:14 +01:00
parent 6691afb9b9
commit 8af4a92fc0
7 changed files with 44 additions and 30 deletions
@@ -41802,6 +41802,12 @@ function useRepl({ tune , defaultSynth , autolink =true , onEvent , onDraw }) {
const logCycle = (_events, cycle)=>{
_events.length;
};
// below block allows disabling the highlighting by including "strudel disable-highlighting" in the code (as comment)
onDraw = _react.useMemo(()=>{
if (activeCode && !activeCode.includes('strudel disable-highlighting')) return onDraw;
}, [
activeCode
]);
// cycle hook to control scheduling
const cycle1 = _useCycleDefault.default({
onDraw,
@@ -42358,21 +42364,6 @@ class Pattern {
// the following functions will get patternFactories as nested functions:
constructor(query){
this.query = query;
// the following code will assign `patternFactories` as child functions to all methods of Pattern that don't start with '_'
const proto = Object.getPrototypeOf(this);
// proto.patternified is defined below Pattern class. You can add more patternified functions from outside.
proto.patternified.forEach((prop)=>{
// patternify function
this[prop] = (...args)=>this._patternify(Pattern.prototype['_' + prop])(...args)
;
// with the following, you can do, e.g. `stack(c3).fast.slowcat(1, 2, 4, 8)` instead of `stack(c3).fast(slowcat(1, 2, 4, 8))`
Object.assign(this[prop], Object.fromEntries(Object.entries(Pattern.prototype.factories).map(([type, func])=>[
type,
(...args)=>this[prop](func(...args))
,
]
)));
});
}
_splitQueries() {
// Splits queries at cycle boundaries. This makes some calculations
@@ -43133,7 +43124,7 @@ Pattern.prototype.define('bypass', (pat)=>pat.bypass(on)
composable: true
});
// call this after all Patter.prototype.define calls have been executed! (right before evaluate)
Pattern.prototype.bootstrap = ()=>{
Pattern.prototype.bootstrap = function() {
// makeComposable(Pattern.prototype);
const bootstrapped = Object.fromEntries(Object.entries(Pattern.prototype.composable).map(([functionName, composable])=>{
if (Pattern.prototype[functionName]) // without this, 'C^7'.m.chordBass.transpose(2) will throw "C^7".m.chordBass.transpose is not a function
@@ -43143,6 +43134,26 @@ Pattern.prototype.bootstrap = ()=>{
curry(composable, makeComposable)
];
}));
// note: this === Pattern.prototypetgh6z
this.patternified.forEach((prop)=>{
// the following will patternify all functions in Pattern.prototype.patternified
Pattern.prototype[prop] = function(...args) {
return this._patternify(Pattern.prototype['_' + prop])(...args);
};
// with the following, you can do, e.g. `stack(c3).fast.slowcat(1, 2, 4, 8)` instead of `stack(c3).fast(slowcat(1, 2, 4, 8))`
// TODO: find a way to implement below outside of constructor (code only worked there)
/* Object.assign(
Pattern.prototype[prop],
Object.fromEntries(
Object.entries(Pattern.prototype.factories).map(([type, func]) => [
type,
function(...args) {
console.log('this', this);
return this[prop](func(...args))
}
])
)
); */ });
return bootstrapped;
};
// this is wrapped around mini patterns to offset krill parser location into the global js code space
@@ -171906,6 +171917,7 @@ function useCycle(props) {
onEvent,
onSchedule,
onQuery,
onDraw,
ready
]);
const start = async ()=>{
@@ -183291,4 +183303,4 @@ exports.default = cx;
},{"@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}]},["3uVTb"], "3uVTb", "parcelRequire94c2")
//# sourceMappingURL=index.dd5b0e5b.js.map
//# sourceMappingURL=index.f8c9aeff.js.map
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -11,6 +11,6 @@
<body>
<div id="root"></div>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="/tutorial/index.dd5b0e5b.js" defer=""></script>
<script src="/tutorial/index.f8c9aeff.js" defer=""></script>
</body>
</html>