Expand description
§cycles

A cyclic pattern abstraction, heavily inspired by TidalCycles.
Started as an attempt at porting the Pattern abstraction and related items
from the TidalCycles’ Haskell implementation, though some liberties have been
taken in order to achieve a more Rust-esque API.
The goal of this crate is to aim for a similar level of ergonomics to TidalCycles (it’s hard to compete with Haskell!), while taking advantage of Rust’s ability to provide low-to-zero-cost abstractions.
§The Pattern trait
The essence of this crate is the Pattern trait. Patterns are types
that can be queried with a Span to produce a sequence of Events. All
other items are related to constructing, applying, modifying or mapping types
implementing Pattern.
Re-exports§
pub use bjorklund::bjorklund;pub use bjorklund::Bjorklund;pub use slice::SliceEvents;
Modules§
- bjorklund
- ctrl
- Control patterns and related items.
- mini
- A mini-notation implementation inspired by tidalcycles’.
- prelude
- slice
- Items related to the
Patternimplementation for slices.
Macros§
- m
- A mini-notation implementation inspired by tidalcycles’.
- span
- A shorthand macro for constructing spans from rationals, e.g.
span!(0/1, 3/1).
Structs§
- Apply
Event - Context given to a
Pattern::apply_withfunction that can be used to produce the applied event along with its associated structure. - BoxEvents
- A dynamic representation of a pattern’s associated events iterator.
- DynPattern
- A dynamic representation of a
Pattern. - Event
- An event yielded by a pattern query, see
Pattern::query. - Event
Cache - Event
Span - The span associated with a single event.
- Events
Map - The
Pattern::Eventstype forMapEvents. - Events
MapPoints - The
Pattern::Eventstype forMapEventPoints. - Events
MapValues - The
Pattern::Eventstype forMapValues. - Events
Rate - The
Pattern::Eventstype forRate. - MapEvent
Points - See
Pattern::map_event_points. - MapEvents
- See
Pattern::map_events. - MapEvents
Iter - See
Pattern::map_events_iter. - MapQuery
Points - See
Pattern::map_query_points. - MapValues
- See
Pattern::map. - Pattern
Debug - A type providing a
std::fmt::Debugimplementation for types implementingPattern. - Rate
- See
Pattern::rate. - Signal
- See the
signalpattern constructor. - Span
- A rational range over a single dimension, represented with a start and end.
Traits§
- One
- Types that can represent the value
1. - Pattern
- A composable abstraction for 1-dimensional patterns.
- Polar
- Types that can represent a polar value.
- Sample
- Types that can be sampled with a rational to produce a value.
- ToF64
Lossy - Types convertible to a lossy representation of the same value.
Functions§
- atom
- Repeats a given discrete value once per cycle.
- euclid
- Divides up the cycle into
nequal events, evenly distributingknumber oftruevalues between them usingbjorklund’s algorithm, and filters out thefalseevents. - euclid_
bool - Divides up the cycle into
nequal events, evenly distributingknumber oftruevalues between them usingbjorklund’s algorithm. - euclid_
bool_ dist - Divides up the cycle into
nequal events, evenly distributingknumber oftruevalues between them usingbjorklund’s algorithm. Also provides the distance until the next onset, inclusive of the current event. - euclid_
full - The same as
euclid, but elongates thetrueevent spans to fill the silence left by the filtered outfalseevents. - euclid_
full_ off - The same as
euclid_full, but allows providing an offset (or “rotation”) for the euclidean rhythm. - euclid_
off - The same as
euclid, but allows providing an offset (or “rotation”) for the euclidean rhythm. - euclid_
off_ bool - The same as
euclid_bool, but allows providing an offset (or “rotation”) for the euclidean rhythm. - euclid_
off_ bool_ dist - The same as
euclid_bool, but allows providing an offset (or “rotation”) for the euclidean rhythm. - fastcat
- Concatenate the given sequence of patterns into a single pattern so that all patterns fit to a single cycle.
- fit_
cycle - The same as [fit_span_to], but assumes the
srcspan is a single cycle. - fit_
span - Fit the
srcspan of the given pattern to thedstspan by first adjusting the rate and then shifting the pattern. - indices
- A pattern producing an index per cycle.
- inner_
join - Similar to
join, but the structure only comes from the inner pattern. - join
- Joins a pattern of patterns into a single pattern.
- outer_
join - Similar to
join, but the structure only comes from the outer pattern. - saw
- A signal pattern that produces a saw wave in the range 0..=1.
- saw2
- A signal pattern that produces a saw wave in the range -1..=1.
- signal
- A pattern that, when queried, always produces a single event sampled from the given function.
- silence
- When queried, always produces an empty event iterator.
- slowcat
- Concatenate the given sequence of patterns into a single pattern whose total unique span covers a number of cycles equal to the number of patterns in the sequence.
- stack
- Combine the patterns into a single “stacked” pattern, where each query is equivalent to querying each of the inner patterns and concatenating their produced events.
- steady
- When queried, always returns a single event with a clone of the given value.
- timecat
- Like fastcat but allows the user to provide proportionate sizes for each pattern.