This commit is contained in:
Felix Roos 2023-01-12 00:10:58 +01:00
parent 95fcce1bcf
commit 4059e9faa9
5 changed files with 101 additions and 18 deletions

View File

@ -1010,9 +1010,6 @@ function _composeOp(a, b, func) {
/** /**
* Applies the given structure to the pattern: * Applies the given structure to the pattern:
* *
* @name struct
* @memberof Pattern
* @returns Pattern
* @example * @example
* note("c3,eb3,g3") * note("c3,eb3,g3")
* .struct("x ~ x ~ ~ x ~ x ~ ~ ~ x ~ x ~ ~") * .struct("x ~ x ~ ~ x ~ x ~ ~ ~ x ~ x ~ ~")
@ -1024,18 +1021,37 @@ function _composeOp(a, b, func) {
Pattern.prototype.structAll = function (...args) { Pattern.prototype.structAll = function (...args) {
return this.keep.out(...args); return this.keep.out(...args);
}; };
/**
* Returns silence when mask is 0 or "~"
*
* @example
* note("c [eb,g] d [eb,g]").mask("<1 [0 1]>").slow(2)
*/
Pattern.prototype.mask = function (...args) { Pattern.prototype.mask = function (...args) {
return this.keepif.in(...args); return this.keepif.in(...args);
}; };
Pattern.prototype.maskAll = function (...args) { Pattern.prototype.maskAll = function (...args) {
return this.keep.in(...args); return this.keep.in(...args);
}; };
/**
* Resets the pattern to the start of the cycle for each onset of the reset pattern.
*
* @example
* s("<bd lt> sd, hh*4").reset("<x@3 x(3,8)>")
*/
Pattern.prototype.reset = function (...args) { Pattern.prototype.reset = function (...args) {
return this.keepif.trig(...args); return this.keepif.trig(...args);
}; };
Pattern.prototype.resetAll = function (...args) { Pattern.prototype.resetAll = function (...args) {
return this.keep.trig(...args); return this.keep.trig(...args);
}; };
/**
* Restarts the pattern for each onset of the restart pattern.
* While reset will only reset the current cycle, restart will start from cycle 0.
*
* @example
* s("<bd lt> sd, hh*4").restart("<x@3 x(3,8)>")
*/
Pattern.prototype.restart = function (...args) { Pattern.prototype.restart = function (...args) {
return this.keepif.trigzero(...args); return this.keepif.trigzero(...args);
}; };
@ -1049,6 +1065,7 @@ export const polyrhythm = stack;
export const pr = stack; export const pr = stack;
// methods that create patterns, which are added to patternified Pattern methods // methods that create patterns, which are added to patternified Pattern methods
// TODO: remove? this is only used in old transpiler (shapeshifter)
Pattern.prototype.factories = { Pattern.prototype.factories = {
pure, pure,
stack, stack,
@ -1118,6 +1135,7 @@ export function reify(thing) {
/** The given items are played at the same time at the same length. /** The given items are played at the same time at the same length.
* *
* @return {Pattern} * @return {Pattern}
* @synonyms polyrhythm, pr
* @example * @example
* stack(g3, b3, [e4, d4]).note() // "g3,b3,[e4,d4]".note() * stack(g3, b3, [e4, d4]).note() // "g3,b3,[e4,d4]".note()
*/ */
@ -1277,7 +1295,8 @@ export function polymeterSteps(steps, ...args) {
/** /**
* Combines the given lists of patterns with the same pulse. This will create so called polymeters when different sized sequences are used. * Combines the given lists of patterns with the same pulse. This will create so called polymeters when different sized sequences are used.
* @name polymeter * @name polymeters
* @synonyms pm
* @example * @example
* polymeter(["c", "eb", "g"], ["c2", "g2"]).note() * polymeter(["c", "eb", "g"], ["c2", "g2"]).note()
* // "{c eb g, c2 g2}".note() * // "{c eb g, c2 g2}".note()
@ -1455,23 +1474,27 @@ export const range = register('range', function (min, max, pat) {
}); });
/** /**
* Assumes a numerical pattern, containing unipolar values in the range 0 .. * Assumes a numerical pattern, containing unipolar values in the range 0 .. 1
* 1. Returns a new pattern with values scaled to the given min/max range, * Returns a new pattern with values scaled to the given min/max range,
* following an exponential curve. * following an exponential curve.
* @param {Number} min * @name rangex
* @param {Number} max * @memberof Pattern
* @returns Pattern * @returns Pattern
* @example
* s("bd sd,hh*4").cutoff(sine.rangex(500,2000).slow(4))
*/ */
export const rangex = register('rangex', function (min, max, pat) { export const rangex = register('rangex', function (min, max, pat) {
return pat._range(Math.log(min), Math.log(max)).fmap(Math.exp); return pat._range(Math.log(min), Math.log(max)).fmap(Math.exp);
}); });
/** /**
* Assumes a numerical pattern, containing bipolar values in the range -1 .. * Assumes a numerical pattern, containing bipolar values in the range -1 .. 1
* 1. Returns a new pattern with values scaled to the given min/max range. * Returns a new pattern with values scaled to the given min/max range.
* @param {Number} min * @name range2
* @param {Number} max * @memberof Pattern
* @returns Pattern * @returns Pattern
* @example
* s("bd sd,hh*4").cutoff(sine2.range2(500,2000).slow(4))
*/ */
export const range2 = register('range2', function (min, max, pat) { export const range2 = register('range2', function (min, max, pat) {
return pat.fromBipolar()._range(min, max); return pat.fromBipolar()._range(min, max);

View File

@ -131,6 +131,14 @@ This group of functions allows to modify the value of events.
<JsDoc client:idle name="Pattern.range" h={0} /> <JsDoc client:idle name="Pattern.range" h={0} />
## rangex
<JsDoc client:idle name="Pattern.rangex" h={0} />
## range2
<JsDoc client:idle name="Pattern.range2" h={0} />
# Custom Parameters # Custom Parameters
You can also create your own parameters: You can also create your own parameters:

View File

@ -35,3 +35,19 @@ import { JsDoc } from '../../docs/JsDoc';
## arpWith 🧪 ## arpWith 🧪
<JsDoc client:idle name="Pattern#arpWith" h={0} /> <JsDoc client:idle name="Pattern#arpWith" h={0} />
## struct
<JsDoc client:idle name="Pattern#struct" h={0} />
## mask
<JsDoc client:idle name="Pattern#mask" h={0} />
## reset
<JsDoc client:idle name="Pattern#reset" h={0} />
## restart
<JsDoc client:idle name="Pattern#restart" h={0} />

View File

@ -38,10 +38,6 @@ Some of these have equivalent operators in the Mini Notation:
<JsDoc client:idle name="Pattern.legato" h={0} /> <JsDoc client:idle name="Pattern.legato" h={0} />
## struct
<JsDoc client:idle name="Pattern.struct" h={0} />
## euclid ## euclid
<JsDoc client:idle name="Pattern.euclid" h={0} /> <JsDoc client:idle name="Pattern.euclid" h={0} />

View File

@ -208,10 +208,50 @@ These functions are more low level, probably not needed by the live coder.
## collect ## collect
# Functions # Functions
## groupHapsBy ## groupHapsBy
<JsDoc client:idle name="groupHapsBy" h={0} /> <JsDoc client:idle name="groupHapsBy" h={0} />
## pure
<JsDoc client:idle name="pure" h={0} />
## reify
<JsDoc client:idle name="reify" h={0} />
## slowcatPrime
<JsDoc client:idle name="slowcatPrime" h={0} />
## isPattern
<JsDoc client:idle name="isPattern" h={0} />
## register
<JsDoc client:idle name="register" h={0} />
## toBipolar
<JsDoc client:idle name="toBipolar" h={0} />
## fromBipolar
<JsDoc client:idle name="fromBipolar" h={0} />
## \_composeOp
# Composers
```
set keep keepif add sub mul div mod pow band bor bxor blshift brshift lt gt lte gte eq eqt ne net and or func
```
```
In Out Mix Squeeze SqueezeOut Trig Trigzero
```