Expand description
Mini notation parser and evaluator for Strudel.
This crate provides parsing, formatting, and evaluation of Strudel’s mini notation, a concise syntax for expressing rhythmic patterns.
§Examples
use strudel_mini::{evaluate, parse};
// Parse mini notation
let ast = parse("bd sd [cp cp] ~").unwrap();
// Evaluate to a pattern
let pattern = evaluate(&ast).unwrap();§Mini Notation Syntax
- Space-separated sequences:
a b c - Nested groups:
[a b] - Stacking (layering):
a,b,c - Polymeter:
{a b c, d e} - Random choice:
a|b|c - Silence:
~ - Replication:
a!3 - Euclidean rhythms:
bd(3,8)
§Main Functions
parse: Parse mini notation string to AST.evaluate: Evaluate AST to executable pattern.format(): Format AST back to mini notation.rewrite,rewrite_str,verify_roundtrip: Verified rewriting / compression framework (the foundation for turning verbose midi-to-strudel output into beautiful livecodable patterns).extract_patterns: Extract mini notation from .strudel files.
Re-exports§
pub use span::Span;
Modules§
- ast
- Ast for Strudel mini notation.
- error
- Error types for mini notation parsing and evaluation.
- evaluator
- Evaluator for mini-notation.
- formatter
- Format implementations for
Ast. - lexer
- Lexer for mini-notation.
- parser
- Parser for mini-notation.
- preprocessor
- Preprocessor for extracting mini notation from Strudel JavaScript files.
- rewriter
- Verified pattern rewriter / compressor for Strudel mini notation.
Structs§
- Eval
Error - Errors that occur during evaluation of a mini-notation AST.
- Extracted
Pattern - Represents an extracted pattern with context.
- Lexer
- Lexer wrapper with position tracking.
- Mini
Error - Combined error for operations that both parse and evaluate.
- Parse
Error - Errors that occur during parsing of mini-notation.
- Parser
- Parser for mini notation.
- Rewrite
Options - Options controlling the rewriter.
- Section
Structure - A detected higher-level song structure that can be expressed with pickRestart.
Enums§
- Alignment
- Alignment type for patterns.
- Ast
- Abstract Syntax Tree for mini notation.
- Combine
Strategy - Strategy for combining multiple patterns.
- Eval
Error Kind - Error kinds that occur during evaluation of a mini-notation AST.
- Expected
Kind - The specific target item the parser was expecting.
- Mini
Error Kind - Combined error for operations that both parse and evaluate.
- Parse
Error Kind - Error kinds that occur during parsing of mini-notation.
- Rewrite
Error - Error type for rewrite / parity failures.
- Rewrite
Style - Style / strategy for rewriting.
- Token
- Lexical tokens evaluated by the logos analyzer.
Functions§
- combine_
patterns - Combine multiple extracted patterns into a single playable pattern.
- detect_
sections - ============================================================================ SECTION DETECTOR (Prototype for pickRestart refactoring)
- eval_
str - Parses and evaluates a mini-notation string, applying a global source offset.
- eval_
str_ with_ colons - Parses and evaluates a mini-notation string with context keys, applying a global source offset.
- evaluate
- Evaluate an AST node into a Pattern.
- extract_
patterns - Extract mini notation patterns from a Strudel JavaScript file.
- format
- Format an AST node as mini notation string.
- musical_
haps_ equal - Compare two Hap lists for musical (not source-location) equality. Strips source locations from context before comparison.
- parse
- Convenience function to parse a mini notation string.
- rewrite
- Rewrite an AST into a more compact / live-friendly equivalent AST.
- rewrite_
str - Convenience: parse + rewrite + format back to a (hopefully more compact) mini string.
- suggest_
pickrestart_ structure - High-level convenience function: given a mini notation string (especially
a long slowcat from midi output), try to detect repeated section structure
and return a nicely formatted suggestion using the
pickRestartDSL pattern. - verify_
roundtrip - Verify that
originalandrewritten(both mini strings) produce musically identical Haps overcyclescycles.
Type Aliases§
- Eval
Result - Result type for evaluation operations.
- Mini
Result - Result type for combined parse-and-evaluate operations.
- Parse
Result - Result type for parse operations.
- Rewrite
Result - Result type for rewrite operations.