mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 21:58:31 +00:00
add queryArc + update readme
This commit is contained in:
parent
87605ca25e
commit
2060e86875
@ -15,14 +15,14 @@ import { sequence, State, TimeSpan } from '@strudel.cycles/core';
|
||||
|
||||
const pattern = sequence('a', ['b', 'c']);
|
||||
|
||||
const events = pattern.query(new State(new TimeSpan(0, 2)));
|
||||
const events = pattern.queryArc(0, 1);
|
||||
|
||||
const spans = events.map(
|
||||
(event) => `${event.value}: ${event.whole.begin.toFraction()} - ${event.whole.end.toFraction()} `,
|
||||
);
|
||||
```
|
||||
|
||||
spans:
|
||||
yields:
|
||||
|
||||
```log
|
||||
a: 0 - 1/2
|
||||
@ -33,4 +33,6 @@ b: 3/2 - 7/4
|
||||
c: 7/4 - 2
|
||||
```
|
||||
|
||||
[play with @strudel.cycles/core on codesandbox](https://codesandbox.io/s/strudel-core-test-qmz6qr?file=/src/index.js).
|
||||
- [play with @strudel.cycles/core on codesandbox](https://codesandbox.io/s/strudel-core-test-qmz6qr?file=/src/index.js).
|
||||
- [open color pattern example](https://raw.githack.com/tidalcycles/strudel/package-examples/packages/core/examples/canvas.html)
|
||||
- [open minimal repl example](https://raw.githack.com/tidalcycles/strudel/package-examples/packages/core/examples/metro.html)
|
||||
|
||||
@ -236,6 +236,10 @@ class Pattern {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
queryArc(begin, end) {
|
||||
return this.query(new State(new TimeSpan(begin, end)));
|
||||
}
|
||||
|
||||
_splitQueries() {
|
||||
// Splits queries at cycle boundaries. This makes some calculations
|
||||
// easier to express, as all events are then constrained to happen within
|
||||
@ -686,12 +690,12 @@ class Pattern {
|
||||
}
|
||||
|
||||
_chop(n) {
|
||||
const slices = Array.from({length: n}, (x, i) => i);
|
||||
const slice_objects = slices.map(i => ({begin: i/n, end: (i+1)/n}));
|
||||
const func = function(o) {
|
||||
return(sequence(slice_objects.map(slice_o => Object.assign({}, o, slice_o))))
|
||||
}
|
||||
return(this._squeezeBind(func));
|
||||
const slices = Array.from({ length: n }, (x, i) => i);
|
||||
const slice_objects = slices.map((i) => ({ begin: i / n, end: (i + 1) / n }));
|
||||
const func = function (o) {
|
||||
return sequence(slice_objects.map((slice_o) => Object.assign({}, o, slice_o)));
|
||||
};
|
||||
return this._squeezeBind(func);
|
||||
}
|
||||
|
||||
// cpm = cycles per minute
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user