access content of lilypond files with ruby
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Jakub Pavlík jn b278dcf1c7 better list of features, code example 6 years ago
bin index: all header fields; check updated files by mtime 7 years ago
lib new parser: document 7 years ago
spec new parser: document 7 years ago
.gitignore musicreader.rb 8 years ago
.rspec musicreader.rb 8 years ago
Gemfile index: boilerplate code 7 years ago
Gemfile.lock index: boilerplate code 7 years ago
README.md better list of features, code example 6 years ago
lyv.gemspec the specification doesn't know anything about Gem::Specification#add_optional_dependency 7 years ago

README.md

lyv

lyv is a small set of tools to handle LilyPond data from Ruby. It is in no way general. Most of it was first written for my In adiutorium project and subsequently used also in other contexts. Thus the gem is primarily for my own purposes and available to anyone who might happen to need it.

It solves tasks like

  • how many scores are defined in a given file?
  • what, if any, are their lyrics?
  • which header fields do they have? With what values?
  • which fields does the top-level header have?
  • get whole source of the n-th score or score meeting some requirements
require 'lyv'

parser = LilyPondParser.new
doc = parser.parse_document(File.read('path/to/MyMusic.ly'))

# top-level header fields
puts "#{doc.header['composer']}: #{doc.header['title']}"

# traverse scores and process their header fields and lyrics
doc.scores.each do |s|
  puts "#{s.header['opus']}: #{s.lyrics}"
end

anti-advertisement

If you want to process LilyPond files, you should consider the fact that most of the notation geeks seem to prefer Python as their scripting language. Particularly the python-ly library might fit your needs.

If python-ly was there at the time my need to parse, split, rearrange, programatically modify etc. LilyPond files emerged, I wouldn't have created any of the scripts that later became lyv.

license

GNU/GPL 3.0 or newer

the name

Liv is a women's name of Nordic origin. ly is an extension commonly used for Lilypond files.