blob: 2b0ab5e394f4ea7ac9fc2147a70be9136683dfd4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# morphology-img
Convert meta-affine sequences to SVG visualizations using LilyPond.
## Prerequisites
This library requires **LilyPond** to be installed and available in your system PATH.
## Overview
The `morphology-img` crate transforms meta-affine sequences from the `morphology` crate into musical notation rendered as SVG images. It uses LilyPond's typesetting engine to generate high-quality visualizations.
## Example
### Basic Usage
```rust
use morphology::{Sequence, Value};
use morphology_img::sequence_to_markup;
// Create a meta-affine sequence
let seq = Sequence::new(vec![
Value::new(1, 0),
Value::new(-1, 1),
Value::new(-1, 0),
Value::new(0, 0),
]);
// Convert to LilyPond markup
let markup = sequence_to_markup(&seq);
println!("{}", markup); // Output: f'4 f4 e4 b4
```
## API
### Converting Sequences to Markup
The main public API converts sequences directly to LilyPond markup strings:
```rust
use morphology_img::sequence_to_markup;
let markup = sequence_to_markup(&sequence);
```
## Testing
Run tests with:
```bash
cargo test
```
Some tests require LilyPond to be installed and are marked with `#[ignore]`. To run these:
```bash
cargo test -- --ignored
```
## Module Structure
```
morphology-img/src/
├── lib.rs // Public API, re-exports
├── error.rs // Error types using thiserror
├── note.rs // Integer → LilyPond pitch conversion
├── template.rs // Template handling & substitution
├── file_gen.rs // .ly file generation
└── render.rs // LilyPond CLI invocation
```
## Troubleshooting
### "LilyPond not found"
If you see this error, ensure:
1. LilyPond is installed (see installation instructions above)
2. The `lilypond` command is in your PATH
3. You can run `lilypond --version` from your terminal
### "LilyPond execution failed"
This can happen if:
- The generated .ly file has syntax errors
- LilyPond encountered an internal error
- File permissions prevent LilyPond from writing output
Check the error message for specific details.
|