Initial commit: skills library
- 70 skills with code and documentation - Add .gitignore (ignore __pycache__, output/, temp/, venv/) - Clean up test intermediates and caches
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
# Verovio 渲染预览
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
pip install verovio
|
||||
```
|
||||
|
||||
## 渲染 MusicXML 为图片
|
||||
|
||||
```python
|
||||
import verovio
|
||||
|
||||
toolkit = verovio.toolkit()
|
||||
|
||||
# 加载 MusicXML
|
||||
toolkit.loadFile("score.musicxml")
|
||||
|
||||
# 渲染为 SVG
|
||||
svg = toolkit.renderToSVG()
|
||||
|
||||
# 保存 SVG
|
||||
with open("output.svg", "w") as f:
|
||||
f.write(svg)
|
||||
|
||||
# 渲染为 PNG
|
||||
toolkit.renderToPNG("output.png", 300) # 300 DPI
|
||||
|
||||
# 渲染为 PDF
|
||||
toolkit.renderToPDF("output.pdf")
|
||||
```
|
||||
|
||||
## 命令行工具
|
||||
|
||||
```bash
|
||||
# 安装命令行工具
|
||||
pip install verovio[commandline]
|
||||
|
||||
# 转换
|
||||
vrv tool -o output.png input.musicxml -r 300
|
||||
```
|
||||
|
||||
## 在 Jupyter 中预览
|
||||
|
||||
```python
|
||||
from IPython.display import SVG, display
|
||||
|
||||
toolkit = verovio.toolkit()
|
||||
toolkit.loadFile("score.musicxml")
|
||||
svg = toolkit.renderToSVG()
|
||||
display(SVG(svg))
|
||||
```
|
||||
|
||||
## 调整页面布局
|
||||
|
||||
```python
|
||||
toolkit.setOption("pageWidth", 2100) # 页面宽度(tenths)
|
||||
toolkit.setOption("pageHeight", 2970) # 页面高度
|
||||
toolkit.setOption("scale", 50) # 缩放比例
|
||||
toolkit.setOption("spacingSystem", 50) # 五线间距
|
||||
```
|
||||
|
||||
## 获取 MIDI
|
||||
|
||||
```python
|
||||
toolkit.loadFile("score.musicxml")
|
||||
midi = toolkit.renderToMIDI()
|
||||
with open("output.mid", "wb") as f:
|
||||
f.write(midi)
|
||||
```
|
||||
Reference in New Issue
Block a user