Re: [frogs] Another new tadpole? |
[ Thread Index |
Date Index
| More lilynet.net/frogs Archives
]
On 09/08/10 00:05, Trevor Daniels wrote:
>
> Yes, diving into the chords engraver is the next step.
>
> Carl wrote a few generic words on engravers in the CG
> which will give you a start. Then read through the
> engraver to understand how it works, asking questions
> on the list as soon as you can't find an answer yourself
> within, say, 10 minutes thinking. Your C experience will
> help. Watch out for macros (in uppercase); see what they
> do. git grep will help you find things. When you have a
> feel for what is happening you can begin to plan what you
> need to do. Hopefully Carl will be back before then and
> can take over from me.
>
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.
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 )" )
The other thing I need to do is write a new engraver ...
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 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?
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".
Cheers,
Wol
---
----
Join the Frogs!