Skip to main content

Crate strudel_mini

Crate strudel_mini 

Source
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§

EvalError
Errors that occur during evaluation of a mini-notation AST.
ExtractedPattern
Represents an extracted pattern with context.
Lexer
Lexer wrapper with position tracking.
MiniError
Combined error for operations that both parse and evaluate.
ParseError
Errors that occur during parsing of mini-notation.
Parser
Parser for mini notation.
RewriteOptions
Options controlling the rewriter.
SectionStructure
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.
CombineStrategy
Strategy for combining multiple patterns.
EvalErrorKind
Error kinds that occur during evaluation of a mini-notation AST.
ExpectedKind
The specific target item the parser was expecting.
MiniErrorKind
Combined error for operations that both parse and evaluate.
ParseErrorKind
Error kinds that occur during parsing of mini-notation.
RewriteError
Error type for rewrite / parity failures.
RewriteStyle
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 pickRestart DSL pattern.
verify_roundtrip
Verify that original and rewritten (both mini strings) produce musically identical Haps over cycles cycles.

Type Aliases§

EvalResult
Result type for evaluation operations.
MiniResult
Result type for combined parse-and-evaluate operations.
ParseResult
Result type for parse operations.
RewriteResult
Result type for rewrite operations.