Re: [frogs] Another new tadpole?

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]



Wols Lists wrote Monday, August 09, 2010 9:30 PM

Let me say up-front I'm getting a little out of my depth
now, having never written an engraver myself ... and
Carl hasn't showed up yet.  And I'm not a guitar player,
so I may be missing something obvious in my comments,
But here goes - if anyone else can offer better advice
please step in.


On 09/08/10 00:05, Trevor Daniels wrote:

Yes, diving into the chords engraver is the next step.

 When you have a
feel for what is happening you can begin to plan what you
need to do.

Okay. I've looked through chord-name-engraver.cc, and I think I've
understood roughly what's going on. It looks like the main thing I've got to change is Chord_name_engraver::process_music(). As far as I can
see, this is building up a list of note pitches in the variable
"pitches" and then passing it to a function to convert it to a chord name.

This sounds right to me.

So what I need to do, is create a new variable "capo_pitches", and just
as pitches are assigned to "pitches", I need to transpose them and
assign them to "capo_pitches". I can then create "capo_markup", which will (if I've understood the code correctly) contain a text description of the transposed chord. So I now have - hopefully - "markup" == eg "Gm"
giving me "capo_markup" == "Em" if capo is 3. I now need
chord_name_->set_property("text", "markup ( capo_markup )" )

So far so good, but I'm beginning to wonder if this is not
duplicating something...

The other thing I need to do is write a new engraver ...

Hhm.  Why is that?  Would that be better than modifying
the existing chord name engraver to be aware of capos (capi?).

I've tried to look at the key signature engraver, but that doesn't seem to be so simple (I'm not surprised ...). What I need to do is have some lilypond syntax "\capo 3 vertical|horizontal", with it defaulting to
horizontal.

This sounds like a new context property set in the ChordName
context and used by the ChordName engraver to decide whether
to transpose and by how much.

This will then need to get the key signature and print
(assuming a key of G minor, the example in front of me) "Capo 3 (Em)", transposing the key down three semitones. It'll also need to leave the 3 somewhere (along with vertical/horizontal), so the chord engraver knows what to do. Wherever it stores the transposition, should that default to
null or 0?

I'm getting puzzled now.  \transpose can already be invoked to
change chord names, can't it?  What functionality does
it lack that you need?  (Sorry if the answer's obvious - I'm not
a guitar player.)  I can see the capo is not fully supported in
fret diagrams.  AFAICS this currently has to be provided for every
fret diagram.  But if you only want chord names perhaps a slightly
different way of invoking \transpose would suffice?

Okay. Where do I start with writing my new engraver? And have I got my changes to chord-name-engraver close? One of the things that gets me (dunno if it's common practice, it isn't to me) is the almost complete lack of comments in the code. What I'll probably do is write up what I'm doing as I do it, and heavily comment my engraver so that even if the comments don't make it into production code, they can make documentation
as a "sample engraver".

Assuming you really do need a new engraver this is where
I have to hand over to someone more competent.  But a commented
engraver would be a useful addition to the CG.

Wol

Trevor



---
----
Join the Frogs!


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/