Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Verovioxide
Safe Rust bindings to the Verovio music notation engraving library
Features
- Multi-format input: Load MusicXML, MEI, ABC, Humdrum, and Plaine & Easie notation
- Multi-format output: Render to SVG, export to MEI/Humdrum/PAE, generate MIDI
- Bundled fonts: Leipzig, Bravura, Gootville, Leland, and Petaluma (SMuFL-compliant)
- Type-safe API: Builder pattern for options with serde serialization
- Zero runtime dependencies: Verovio statically linked
- Complete API coverage: 100% of the Verovio C++ API wrapped in safe Rust
- Production ready: Comprehensive error handling and 95%+ test coverage
- PNG support: Verovioxide extends beyond the Verovio C++ API with PNG output (in-memory and to-file)
Installation
The first build compiles the Verovio C++ library from source, which takes several minutes. Subsequent builds use cached artifacts and are fast.
Faster Builds with Prebuilt Binaries
For faster initial builds, use the prebuilt feature which downloads a pre-compiled Verovio library:
Or in your Cargo.toml:
[]
= "0.3"
= { = "0.3", = ["prebuilt"] }
Prebuilt binaries are available for:
- macOS (x86_64, aarch64)
- Linux (x86_64, aarch64)
- Windows (x86_64 MSVC)
If prebuilt binaries aren't available for your platform, it automatically falls back to compiling from source.
Quick Start
use ;
use Path;
Rendering
Verovioxide provides a unified render API with builder pattern for type-safe, consistent output.
In-Memory Rendering
Use render() with format builders:
use ;
// SVG rendering
let svg: String = voxide.render?; // Single page
let svg: String = voxide.render?;
let pages: = voxide.render?; // All pages
let pages: = voxide.render?; // Page range
// Other formats
let midi: String = voxide.render?; // Base64-encoded MIDI
let mei: String = voxide.render?; // MEI XML
let humdrum: String = voxide.render?; // Humdrum/Kern
let pae: String = voxide.render?; // Plaine & Easie
let timemap: String = voxide.render?; // JSON timing data
let expansion: String = voxide.render?;
File Rendering
Use render_to() for simple cases (format inferred from extension):
voxide.render_to?; // SVG page 1
voxide.render_to?; // MIDI
voxide.render_to?; // MEI
Use render_to_as() for explicit control:
voxide.render_to_as?; // Specific page
voxide.render_to_as?; // Creates output/ directory
voxide.render_to_as?; // Disambiguate .json
Format-Specific Options
Timemap and MEI support typed options:
// Timemap with options
let timemap = voxide.render?;
// MEI with options
let mei = voxide.render?;
Page Information
let count = voxide.page_count;
println!;
Legacy Methods
The original render methods remain available for backwards compatibility:
let svg = voxide.render_to_svg?;
let pages = voxide.render_all_pages?;
let mei = voxide.get_mei?;
let humdrum = voxide.get_humdrum?;
let midi = voxide.render_to_midi?;
let timemap = voxide.render_to_timemap?;
Querying Elements
Verovioxide provides a unified query API with type-safe return values.
Element Queries
Use get() with query types for type-safe element information:
use ;
let mut voxide = new?;
voxide.load?;
// Get page containing an element
let page: u32 = voxide.get?;
// Get element attributes as JSON
let attrs: String = voxide.get?;
// Get timing information
let time: f64 = voxide.get?;
let times: String = voxide.get?;
Time-Based Queries
use ;
// Get elements sounding at 5000ms
let elements: String = voxide.get?;
Descriptive Features
use ;
let features: String = voxide.get?;
Legacy Methods
The original query methods remain available for backwards compatibility:
let page = voxide.get_page_with_element?;
let attrs = voxide.get_element_attr?;
let time = voxide.get_time_for_element?;
let elements = voxide.get_elements_at_time?;
Configuration
Options Builder
The Options builder provides type-safe configuration:
use ;
let options = builder
// Page dimensions (MEI units, 10 units = 1mm)
.page_width // A4 width
.page_height // A4 height
.adjust_page_height
// Margins
.page_margin
.page_margin_top
// Scale and spacing
.scale // Percentage
.spacing_staff
.spacing_system
// Font
.font // or "Bravura", "Gootville", "Leland", "Petaluma"
.lyric_size
// Layout
.breaks
.header
.footer
// SVG output
.svg_view_box
.svg_remove_xlink
.svg_css
// MIDI generation
.midi_tempo
.midi_velocity
// Transposition
.transpose // Up a major second
.build;
voxide.set_options?;
Available Options
| Category | Options |
|---|---|
| Page | page_width, page_height, adjust_page_height, page_margin, page_margin_top, page_margin_bottom, page_margin_left, page_margin_right |
| Scale/Spacing | scale, spacing_staff, spacing_system, spacing_linear, spacing_non_linear, even_note_spacing, min_measure_width |
| Font | font, lyric_size |
| Layout | breaks, condense, condense_first_page, condense_tempo_pages, header, footer |
| SVG | svg_xml_declaration, svg_bounding_boxes, svg_view_box, svg_remove_xlink, svg_css, svg_format_raw, svg_font_face_include |
| MIDI | midi_tempo, midi_velocity |
| Input | input_from, mdiv_x_path_query, expansion |
| Transposition | transpose, transpose_selected_only, transpose_to_sounding_pitch |
Option Modes
// Break modes
Auto // Automatic page/system breaks
None // No automatic breaks
Encoded // Use breaks from input file
Line // Break at each line
Smart // Smart break placement
// Condense modes
None
Auto
Encoded
// Header/Footer modes
None | Auto | Encoded
None | Auto | Encoded | Always
JSON Serialization
Options can be serialized/deserialized:
let json = options.to_json?;
let options = from_json?;
Supported Input Formats
| Format | Extensions | Description |
|---|---|---|
| MusicXML | .musicxml, .xml, .mxl |
Standard music interchange format |
| MEI | .mei |
Music Encoding Initiative XML |
| ABC | .abc |
Text-based notation format |
| Humdrum | .krn, .hmd |
Kern and other Humdrum formats |
| PAE | — | Plaine & Easie Code (RISM) |
Format detection is automatic based on file content.
Supported Output Formats
| Format | Unified API | Description |
|---|---|---|
| SVG | render(Svg::page(1)) |
Scalable vector graphics for display |
| MEI | render(Mei) |
Music Encoding Initiative XML |
| Humdrum | render(Humdrum) |
Humdrum/Kern format |
| PAE | render(Pae) |
Plaine & Easie Code |
| MIDI | render(Midi) |
Base64-encoded MIDI for playback |
| Timemap | render(Timemap) |
JSON timing data for synchronization |
| Expansion Map | render(ExpansionMap) |
JSON expansion/repeat data |
| PNG | render(Png::page(1)) |
Raster image for display/printing |
PNG Rendering
PNG support is enabled by default via the png feature. It uses resvg for high-quality SVG-to-PNG conversion.
In-Memory PNG
use Png;
// Basic rendering (returns Vec<u8>)
let png_bytes: = voxide.render?;
// With options
let png_bytes = voxide.render?;
// Custom background color
let png_bytes = voxide.render?;
// Render all pages
let all_pngs: = voxide.render?;
// Render page range
let pngs: = voxide.render?;
File Rendering
// Format inferred from extension
voxide.render_to?;
// Explicit control
voxide.render_to_as?;
voxide.render_to_as?; // Creates output/ directory
Terminal Display with viuer
The PNG bytes are compatible with the image crate for terminal display:
use Png;
use load_from_memory;
use Config;
let png_bytes = voxide.render?;
let img = load_from_memory?;
print?;
Disabling PNG
To disable PNG support (reduces compile time and binary size):
[]
= { = "0.3", = false, = ["bundled-data"] }
Feature Flags
verovioxide
| Feature | Default | Description |
|---|---|---|
bundled-data |
Yes | Include bundled SMuFL fonts and resources |
png |
Yes | PNG rendering support via resvg |
font-leipzig |
Yes | Leipzig SMuFL font (default font) |
font-bravura |
No | Bravura SMuFL font |
font-gootville |
No | Gootville SMuFL font |
font-leland |
No | Leland SMuFL font |
font-petaluma |
No | Petaluma SMuFL font |
all-fonts |
No | Enable all fonts |
Note: Bravura baseline data is always included as it is required for Verovio's glyph name table.
verovioxide-sys
| Feature | Default | Description |
|---|---|---|
bundled |
Yes | Compile Verovio C++ library from source |
prebuilt |
No | Download pre-built library from GitHub releases (faster) |
force-rebuild |
No | Force fresh compilation, bypassing cache |
The prebuilt and bundled features can be used together - if prebuilt download fails, it falls back to compilation.
Enable Additional Fonts
[]
= { = "0.3", = ["font-bravura", "font-leland"] }
Custom Resource Path
To use your own Verovio resources instead of bundled data:
[]
= { = "0.3", = false }
let voxide = with_resource_path?;
Building from Source
Clone with submodules:
Build and test:
Build Caching
The Verovio C++ library is compiled once and cached at target/verovio-cache/. Subsequent builds link to the cached library and complete in seconds.
To force a fresh recompilation:
Corporate/Restricted Networks
If your network blocks GitHub downloads, you can provide a local Verovio source:
VEROVIO_SOURCE_DIR=/path/to/verovio
Examples
Render MusicXML to SVG
Render ABC Notation
Render All Pages
Creating Verovio toolkit with bundled resources...
Verovio version: 5.7.0
Setting page dimensions: width=2100, height=2970 (A4-like)
Loading file: examples/Goldberg-Variationen-1-and-2.musicxml (format auto-detected)
[Warning] MusicXML import: Dangling ending tag skipped
Document loaded successfully. Total pages: 3
Rendering 3 pages...
Page 1/3: output-dir/-001.svg (380226 bytes)
Page 2/3: output-dir/-002.svg (424047 bytes)
Page 3/3: output-dir/-003.svg (121350 bytes)
Done! Rendered 3 pages.
Crate Structure
| Crate | Description |
|---|---|
| verovioxide | High-level safe Rust API |
| verovioxide-sys | Low-level FFI bindings to Verovio C API |
| verovioxide-data | Bundled SMuFL fonts and resources |
Technical Notes
Thread Safety
Toolkit implements Send but not Sync. You can move a toolkit between threads, but cannot share references across threads. For concurrent rendering, create separate toolkit instances.
Verovio Version
This release uses Verovio 5.7.0.
Logging
// Enable logging to stderr
enable_log;
// Or capture to buffer
enable_log_to_buffer;
// ... operations ...
let log = voxide.get_log;
License
This project is licensed under the Apache License 2.0.
Dependencies:
- Verovio is licensed under the LGPL-3.0
- SMuFL fonts have their own licenses (see the respective font directories)


