larsenwork / animalnoteheads

Musical noteheads shaped like animals
animalnoteheads.com
Other
13 stars 4 forks source link

Lilypond script #14

Open larsenwork opened 9 years ago

larsenwork commented 9 years ago

The script and necessary files have now been added to the Lilypond branch. https://github.com/andreaslarsen/animalnoteheads/tree/Lilypond

larsenwork commented 9 years ago

Work in progress http://animalnoteheads.com/assets/pdf/lillepeter.pdf

tisimst commented 9 years ago

Some thoughts:

  1. With LilyPond, everything comes from a command-line call (i.e., that's how you get the svg, too)
  2. I'm not sure that layers would work as an output from LilyPond. You might just want to create a script that can specify whether or not you want to use the animals or just a black note.
  3. Any other glyphs you want to use can be specified from an eps file (clefs, rests, etc.), so there's no need to create an actual font. That's certainly an option, too, though.
  4. I'll take care of the stem placement.

That's all for now. Are the animal glyphs changing? This will change how the stems are placed.

larsenwork commented 9 years ago

@tisimst perfect

The glyphs names and sizes will not change. They look perfectly placed to me now.

larsenwork commented 9 years ago

@ 1 What i figured - couldn't make it work though (got command line working but not that svg creation - gave me a .ps file I couldn't open)

@ 2 It has also been my thought to do exactly that - create an app/script where the user just types

  1. output dir
  2. title
  3. name
  4. language
  5. what's currently inside music = { }

and then the script creates the 2 (?) .ly files and outputs them to svg using command line call

@ 3 Yeah I figured that out by reading through the documentation - I haven't been able to find an example though and my attempts so far didn't go so well. There's a g-clef.eps in there somewhere I'd like changed :wink:

@ 4 The stem placement looks fine with the downwards stem - upwards needs fixing

larsenwork commented 9 years ago

@tisimst as you can see in .ily all the dimensions and lower are the same so they could probably be called just once?

Is it possible to insert a variable from the .ly in the .ily file like drafted below:

.ly 
Language = da
.ily
  \epsfile #X #1.2 #"G-" + Language + "color.eps" 
larsenwork commented 9 years ago

Ah, the black one isn't updated - I'll fix that now :)

tisimst commented 9 years ago

@andreaslarsen Yeah, building strings that have the language built-in shouldn't be a problem.

tisimst commented 9 years ago

PR #15 is ready for your review! Shouldn't be too hard to merge.

larsenwork commented 9 years ago

Beams and notehead placing looks great.

I also got exporting to svg working but the note heads were blank - I'm guessing it's a issue with lilypond not being able to convert eps into something embeddable in svg? Any ideas for a workaround?

tisimst commented 9 years ago

Unfortunately, this appears to be a known limitation. It looks like it might be possible to embed svg code directly, but this will take some work, I think.

larsenwork commented 9 years ago

Ok - I have searched quite a bit without finding any information on how to do so - found a reply that linked to a .ly file that wasn't there anymore :smile:

larsenwork commented 9 years ago

the only thing "missing" for the pdf part to work 99.99% (I wasn't able to get the beam absolutely perfectly aligned but I'm pretty sure no one except the two of us will ever notice) is changing the clef to the eps version. I'll push my changes right after this + give you write access to this repo so you don't need to work your own fork and do pr's

larsenwork commented 9 years ago

Did some last minute edits - it's up now. I restructured it a bit so what most users will see is less files + less code.

larsenwork commented 9 years ago

@tisimst I just found pdf2svg that makes it very easy to command line convert so no need to worry about lilypond and svg :)

tisimst commented 9 years ago

@andreaslarsen :+1: I did figure out how to do embedded-svg, by the way, but I'm not sure it's worth pursuing. :sweat: I'll abandon that ship unless you tell me otherwise. If you're interested, we can talk about it.

larsenwork commented 9 years ago

@tisimst Always interested :)

tisimst commented 9 years ago

Check out my latest commit to the LilyPond branch in the .svg folder. That should give you an idea of what is necessary to make it work. 774343958e199274f410349d0d65b02eea585166

larsenwork commented 9 years ago

cool, but as you say it's probably best to stay with pdf and pdf2svg - it looks really good now :grinning:

larsenwork commented 9 years ago

I'd like to add support for

𝅝𝅗𝅥

at some point - kan this also be done using \epsfile?

tisimst commented 9 years ago

huh?

larsenwork commented 9 years ago

Is it possible to have a different note head eps file for the half and full notes

tisimst commented 9 years ago

Absolutely! If you can add a file for both half and whole notes, I can adjust the code to allow it.

On May 23, 2015, at 8:32 AM, Andreas Larsen notifications@github.com wrote:

Is it possible to have a different note head eps file for the half and full notes

— Reply to this email directly or view it on GitHub.

larsenwork commented 9 years ago

Perfect - I'll add the files very soon (they'll look a bit generic at first - I have to experiment a bit because I want to try and make look like they're yawning)

larsenwork commented 9 years ago

the danish, english and black are up. Called A-da-color-half A-da-bw-half and Black-half

screen shot 2015-05-23 at 21 15 49

larsenwork commented 9 years ago

is it possible to "tell" lilypond where to look for a font? Ideally I'd like to be able to put the font inside the .eps folder.

tisimst commented 9 years ago

The only way to tell LilyPond where to find anything is to use the --include="directory" commandline option. I've tried this with other fonts and it seems to work alright.

tisimst commented 9 years ago

I've got the code working so that it automatically selects the "normal" and "-half" noteheads. Do you plan on using the -half images for the whole notes, too? Right now that's how I've got it working, but it is easily extensible to further differentiated images based on note duration.

larsenwork commented 9 years ago

Perfect! Same head for half and whole, yes:)

larsenwork commented 9 years ago

The font thing will have to wait a bit then - I'm thinking about making an app using https://github.com/atom/electron that does everything with an easy to use interface.

larsenwork commented 9 years ago

I've been playing around a bit trying to hide objects - my problem is figuring out how to hide and object without affecting the layout in any way which \omit often seems to do.

What I'd like to do in web-terms is "visibility: hidden" - is this in any way possible?

larsenwork commented 9 years ago

Just tested the half/whole notes - works flawlessly. Added localised versions of the g-clef's just because I now know how :)

Scheme is a very very weird language - but it works :)

larsenwork commented 9 years ago

I'd like to replace following symbols:

flat, sharp, quarter rest, eight rest, eight flag

Am I correct to assume they can be replaced similar to how I've done with the clef or is there a smarter way?

defaultClefSymbol = \markup{
  \lower #2.85
  \epsfile #Y #7.5 #".eps/G-clef-black.eps"
}
  \override Staff.Clef #'stencil = #ly:text-interface::print
  \override Staff.Clef #'text = #myClefSymbol
tisimst commented 9 years ago

I've been playing around a bit trying to hide objects...

Have you tried \hide instead of \omit?

Am I correct to assume they can be replaced similar to how I've done with the clef...

Yes, but you can simplify it like we do in the code that selects noteheads by using something like (with the correct names, of course):

defaultClefSymbol = \markup { ... }
\override Staff.Clef #'stencil = 
  #(lambda (grob) 
    (grob-interpret-markup grob
      #{
         ...
      #}))

Or you can just do it the way you suggested using #ly:text-interface::print. However, it will probably be better to do it the way I've suggested (and is like the current code for selecting noteheads) since we'll need to iterate through various cases (e.g., rest duration, flag duration, which accidental, etc.), so we'll need some Scheme code to do that and then select the appropriate image file.

larsenwork commented 9 years ago

I haven't tried \hide - didn't know about it:) Will try that later.

I tried changing the rests, accidentals and flags just modifying ementhaler26 and that works. Lilypond gives me an error saying

programming error: FreeType error: SFNT font table missing
continuing, cross fingers

but output looks fine.

How do I ensure I export/generate the .otf correctly so I don't get this error message?

tisimst commented 9 years ago

Unfortunately, it's not a terribly easy problem to solve. It took me a good few months to figure it out. Embedded in each of the emmentaler-XX fonts are three subtables: LILY, LILC, and LILF. Each contains certain metadata about the glyphs so that LilyPond knows how to space things and attach stems. Normally, the process of collecting this data is tedious, but I have managed to automate this for the most part (that's why I've been able to make so many fonts that work nicely with LilyPond). However, if you are using FontForge, you can pretend to do what I've done (especially since it seems you aren't changing anything too dramatically).

Normally, you will see this error because FontForge doesn't see them as a "standard" subtable and it gets rid of them when you open the .otf file (you should see this warning when FontForge boots up). You can override this by going into File > Preferences > Open Font and you will see a field called PreserveTables. If you put in LILY,LILC,LILF without any quotes and no spaces, then next time, when you open any of the emmentaler-XX fonts, the warning should be gone and FontForge will keep the binary data intact for these subtables. Now, this can cause spacing issues, but I don't imagine you'll see any problems unless your designs are VERY different in size from those that are being replaced.

If this doesn't quite work for you, then send me the .sfd file and I'll compile the fonts for you with the correct data. It will take me all of a minute or two to do that :wink:.

andrewcsmith commented 6 years ago

@tisimst (sorry for the resurrection, but I can't find another way to reach you)

I'm looking for a script to collect all that SFNT table info that Lilypond needs for a font I made in fontforge. Would you mind sharing yours, perhaps in another repo? I can help write documentation if that would help. I'm pretty solid at python (which I assume this script is in given your other repos) so I can probably figure out usage just from looking at the source. Let me know. Thanks a lot!